Programmer:Earn Point with Sale Invoice v2

From AutoCount Resource Center
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Technical Specifications

  1. Requires Bonus Point module.
  2. To learn how AutoCount Bonus Point works, click Bonus Point.
  3. MemberNo must be assigned with valid value.
    Value must be maintained at Bonus Point > Member Maintenance

Assemblies version 2.0


Create Sale Invoice and assign bonus point programmatically

  • This sample code shows how to create Sale Invoice with Bonus Point.
  • When Bonus Point is calculated from external system, programmer can assign the bonus point earning to each item.
  • Highlighted lines are the assignment of bonus point to each item.
  • The total earning point of this document must be the sum of dtl.BonusPoint.
public void NewInvoiceWithBonusPoint(AutoCount.Authentication.UserSession userSession)
    AutoCount.Invoicing.Sales.Invoice.InvoiceCommand cmd
        = AutoCount.Invoicing.Sales.Invoice.InvoiceCommand.Create(userSession, userSession.DBSetting);
    AutoCount.Invoicing.Sales.Invoice.Invoice doc = cmd.AddNew();
    AutoCount.Invoicing.Sales.Invoice.InvoiceDetail dtl;

    doc.RecalculateMemberPoint = true;
    doc.DebtorCode = "300-A001";
    doc.Description = "Test API Bonus Point";
    doc.MemberNo = "M-0001";

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";
    dtl.Qty = 1;
    dtl.UnitPrice = 100;
    //Manual set bonus point earn
    dtl.BonusPoint = 50;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";
    dtl.Description = "Test Item";
    dtl.Qty = 1;
    dtl.UnitPrice = 200;
    dtl.BonusPoint = 20;

    //without ItemCode test
    dtl = doc.AddDetail();
    dtl.Description = "Test Item";
    dtl.SubTotal = 200;
    dtl.BonusPoint = 20;

    //Call CalcNetTotal to update document total Bonus Point.
    //If CalcNetTotal() method is not called, total Bonus Point result can be incorrect.

        //Log success
        AutoCount.AppMessage.ShowMessage($"Invoice {doc.DocNo} is created.");
    catch (AutoCount.AppException ex)
        //Log failure
        AutoCount.AppMessage.ShowMessage($"Fail to create new Invoice.\n{ex.Message}");

See Also

Maintenance (Master Data)



  • 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