Difference between revisions of "Programmer:Bonus Point Redemption"

From AutoCount Resource Center
Jump to navigation Jump to search
m
Line 15: Line 15:
 
| DocNo || string || 20 || Yes || If apply system running number,<br/>do not assign or assigned with "<<New>>"
 
| DocNo || string || 20 || Yes || If apply system running number,<br/>do not assign or assigned with "<<New>>"
 
|-
 
|-
| DocDate || DateTime || || Yes || '''Date only, without time'''<br/>Eg. DateTime.Today.Date
+
| DocDate || DateTime || || Yes || '''Date only, without time'''<br/>Eg. DateTime.Today.Date
  +
|-
  +
| Description || string || 80 || No || Earlier version, field is not available.<br/>See sample code on how to assign value when field is not presented.<br/>However, if field is available, '''strongly advise to use field assignment'''.
 
|}
 
|}
   
Line 28: Line 30:
 
| Location || string || 8 || No || Value must be maintained at Stock > Stock Location Maintenance
 
| Location || string || 8 || No || Value must be maintained at Stock > Stock Location Maintenance
 
|-
 
|-
| BatchNo || string || 20 || No || Value must be maintained at Stock > [[Programmer:Stock Item|Item Maintenance]] > Item Batch<br/>Requires enable "Item Batch No." module,<br/>and Item is controlled by BatchNo.
+
| BatchNo || string || 20 || No || Value must be maintained at Stock > [[Programmer:Stock Item|Item Maintenance]] > Item Batch<br/>Requires enable "Item Batch No." module,<br/>and Item is controlled by BatchNo.<br/>Default: DBNull.Value
 
|-
 
|-
 
| Description || string || 100 || No ||
 
| Description || string || 100 || No ||
Line 34: Line 36:
 
| FurtherDescription || string || Max || No ||
 
| FurtherDescription || string || Max || No ||
 
|-
 
|-
| ProjNo || string || 10 || No || Value must be maintained at General Maintenance > Project Maintenance
+
| 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
 
| DeptNo || string || 10 || No || Value must be maintained at General Maintenance > Department Maintenance
 
|-
 
|-
| UOM || string || 8 || No || [[Programmer:Stock Item|Item Maintenance]]
+
| UOM || string || 8 || No || Value must be maintained at Stock > [[Programmer:Stock Item|Item Maintenance]]
 
|-
 
|-
| Qty || long || || No || Qty is usually a decimal type,<br/>at '''Point Redemption''' must be absolute number.
+
| Qty || long || || No || Qty is usually a decimal type,<br/>the value at '''Bonus Point Redemption''' is absolute number.
 
|-
 
|-
| UnitPoint || decimal || 19,2|| No ||
+
| UnitPoint || decimal || 19,2|| No || Expend of Bonus Point for this item as in per unit.
  +
|-
  +
| SubTotal || decimal || 19,2|| No || Auto calculated by Qty x UnitPoint.<br/>'''SubTotal''' is the total value that is used to deduct the member (bonus) point.
 
|}
 
|}
   
 
==API Usage==
 
==API Usage==
  +
===New===
  +
<syntaxhighlight lang="csharp">
  +
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 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 assigment
  +
  +
//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;
  +
  +
//Expend of Bonus Point for this item as in per unit
  +
dtl.UnitPoint = 10;
  +
  +
//Subtotal of total point expend is auto calculated by system
  +
//However, the final point deduction is based on SubTotal,
  +
//Regardless of UnitPoint value
  +
//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}");
  +
}
  +
}
  +
  +
</syntaxhighlight>
  +
  +
===Update / Edit===
  +
<syntaxhighlight lang="csharp">
  +
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}");
  +
}
  +
}
  +
</syntaxhighlight>
  +
  +
===Cancel (Void)===
  +
<syntaxhighlight lang="csharp">
  +
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}");
  +
}
  +
}
  +
</syntaxhighlight>
  +
  +
===Uncancel (Unvoid)===
  +
<syntaxhighlight lang="csharp">
  +
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}");
  +
}
  +
}
  +
</syntaxhighlight>
  +
  +
===Delete===
  +
<syntaxhighlight lang="csharp">
  +
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);
  +
}
  +
</syntaxhighlight>
   
 
<br/>
 
<br/>

Revision as of 07:41, 6 August 2018

Technical Specifications

  1. Bonus Point Redemption is to exchange Item with Points.

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 Expend 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 value that is used to deduct the member (bonus) point.

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 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 assigment

    //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;

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

    //Subtotal of total point expend is auto calculated by system
    //However, the final point deduction is based on SubTotal,
    //Regardless of UnitPoint value
    //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

    IconAC81.png Go to top
    ProgrammerGo.jpg Resources For AutoCount Software Developers