Programmer:Bonus Point Redemption

From AutoCount Resource Center

Technical Specifications

  1. Bonus Point Redemption is to exchange Item with Points.
  2. To learn how AutoCount Bonus Point works, click Bonus Point

Columns Specification

Master Table Columns

Master Table Columns
Column Name Data Type Size Mandatory Remark
MemberNo string 20 Yes Value must be maintained at Bonus Point > Member Maintenance
DebtorCode string 12 No Value is maintained at A/R > Debtor Maintenance
DocNo string 20 Yes If apply system running number,
do not assign or assigned with "<<New>>"
DocDate DateTime Yes Date only, without time
Eg. DateTime.Today.Date
Description string 80 No Earlier version, field is not available.
See sample code on how to assign value when field is not presented.
However, if field is available, strongly advise to use field assignment.

Detail Table Columns

Detail Table Columns
Column Name Data Type Size Mandatory Remark
ItemCode string 30 No Value must be maintained at Stock > Item Maintenance
Location string 8 No Value must be maintained at Stock > Stock Location Maintenance
BatchNo string 20 No Value must be maintained at Stock > Item Maintenance > Item Batch
Requires enable "Item Batch No." module,
and Item is controlled by BatchNo.
Default: DBNull.Value
Description string 100 No
FurtherDescription string Max No
ProjNo string 10 No Value must be maintained at General Maintenance > Project Maintenance.
DeptNo string 10 No Value must be maintained at General Maintenance > Department Maintenance
UOM string 8 No Value must be maintained at Stock > Item Maintenance
Qty long No Qty is usually a decimal type,
the value at Bonus Point Redemption is absolute number.
UnitPoint decimal 19,2 No Expense of Bonus Point for this item as in per unit.
SubTotal decimal 19,2 No Auto calculated by Qty x UnitPoint.
SubTotal is the total point that applies to deduction of member (bonus) point.

Assemblies version 1.8, 1.9

BCE.AutoCount.dll
BCE.AutoCount.CommonAccounting.dll
BCE.AutoCount.MainEntry.dll
BCE.Utils.dll
BCE.Utils.UI.dll
BCE.AutoCount.GeneralMaint.dll
BCE.AutoCount.Invoicing.dll
BCE.AutoCount.Invoicing.Sales

API Usage

New

public void NewBonusPointRedemption(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand cmd
        = BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand.Create(dbSetting);
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemption doc
        = cmd.AddNewMasterRow();
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionDetail dtl;

    //When apply system running number,
    //do not assign or assigned with "<<New>>"
    //doc.DocNo = "<<New>>";
    doc.DocDate = DateTime.Today.Date;
    doc.MemberNo = "M-0001";

    //Missing "Description" field in earlier version
    //doc.Description = "";
    doc.DataRow["Description"] = "API Test Bonus Point Redemption";

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";

    //If use default from system Item Maintenance,
    //ignore assign value to Item Description
    //dtl.Description = "FINISHED GOODS 01";

    dtl.UOM = "UNIT";
    //dtl.BatchNo = DBNull.Value; //when value is null, set to DBNull.Value, or ignore assignment

    //If not assign, it uses system auto assign default value.
    dtl.Location = "HQ";

    //If not assign, it uses system auto assign default value.
    //dtl.ProjNo = DBNull.Value;

    //If not assign, it uses system auto assign default value.
    //dtl.DeptNo = DBNull.Value;

    dtl.Qty = 2M;

    //Expense of Bonus Point for this item as in per unit
    dtl.UnitPoint = 10;

    //SubTotal is auto calculated by system which it is based on UnitPoint x Qty.
    //However, programmer is allowed to update the SubTotal (total point) without UnitPoint.
    //dtl.SubTotal = 20;

    try
    {
        doc.Save(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
        //Log success
        BCE.Application.AppMessage.ShowMessage($"New redemption '{doc.DocNo}' is created.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log failure
        BCE.Application.AppMessage.ShowMessage($"Fail to create new redemption.\n{ex.Message}");
    }
}

Update / Edit

public void UpdateBonusPointRedemption(string docNo, BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand cmd
        = BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand.Create(dbSetting);
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemption doc = cmd.Edit(docNo);
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionDetail dtl;

    if (doc == null)
    {
        //Log document not found
        return;
    }

    doc.ClearDetails();

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";
    dtl.Description = "FINISHED GOODS 01";
    dtl.UOM = "UNIT";
    dtl.Location = "HQ";
    dtl.Qty = 2M;
    dtl.UnitPoint = 19;

    try
    {
        doc.Save(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
        //Log success
        BCE.Application.AppMessage.ShowMessage($"Redemption '{doc.DocNo}' is updated.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log failure
        BCE.Application.AppMessage.ShowMessage($"Fail to update redemption '{doc.DocNo}'.\n{ex.Message}");
    }
}

Cancel (Void)

public void CancelBonusPointRedemption(string docNo, BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand cmd
        = BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand.Create(dbSetting);
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemption doc = cmd.View(docNo);

    try
    {
        doc.CancelDocument(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
        //Log success
        BCE.Application.AppMessage.ShowMessage($"Redemption '{doc.DocNo}' is cancelled.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log failure
        BCE.Application.AppMessage.ShowMessage($"Fail to cancel redemption '{doc.DocNo}'.\n{ex.Message}");
    }
}

Uncancel (Unvoid)

public void UncancelBonusPointRedemption(string docNo, BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand cmd
        = BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand.Create(dbSetting);
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemption doc = cmd.View(docNo);

    try
    {
        doc.UncancelDocument(BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
        //Log success
        BCE.Application.AppMessage.ShowMessage($"Redemption '{doc.DocNo}' is uncancelled.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log failure
        BCE.Application.AppMessage.ShowMessage($"Fail to uncancel redemption '{doc.DocNo}'.\n{ex.Message}");
    }
}

Delete

public void DeleteBonusPointRedemption(string docNo, BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand cmd
        = BCE.AutoCount.Invoicing.Sales.BonusPointRedemption.BonusPointRedemptionCommand.Create(dbSetting);

    long? docKey = GetDocKeyByDocNo(docNo, dbSetting);

    if (!docKey.HasValue)
    {
        //log document not found
        return;
    }

    try
    {
        //BonusPointRedemption Delete() method support multiple dockey deletion.
        cmd.Delete(new long[] { docKey.Value });
        //Log success
        BCE.Application.AppMessage.ShowMessage($"Redemption '{docNo}' is deleted.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log failure
        BCE.Application.AppMessage.ShowMessage($"Fail to delete redemption '{docNo}'.\n{ex.Message}");
    }
}

private long? GetDocKeyByDocNo(string docNo, BCE.Data.DBSetting dbSetting)
{
    object obj = dbSetting.ExecuteScalar("SELECT DocKey FROM BonusPointRedemption WHERE DocNo=?", docNo);
    return obj == null ? default(long?) : BCE.Data.Convert.ToInt64(obj);
}


See Also

Maintenance (Master Data)

Transactions

Reporting

  • Member List and Point Balance - [1.8, 1.9] [2.0]

    Go to menu

    Go to top
    Resources For AutoCount Software Developers