Programmer:Cash Sale with Payment: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
No edit summary
No edit summary
Line 164: Line 164:
BCE.AutoCount.ARAP.ARPayment.ARPaymentDTLEntity payDtl = cs.CashSalePayment.ARPayment.NewDetail();
BCE.AutoCount.ARAP.ARPayment.ARPaymentDTLEntity payDtl = cs.CashSalePayment.ARPayment.NewDetail();


//"CASH" must be maintained
payDtl.PaymentMethod = BCE.AutoCount.Invoicing.CommonFunction.GetFirstCashAccount(dbSetting);
//in General Maintenance | Payment Method Maintenance
payDtl.PaymentMethod = "CASH";
payDtl.PaymentAmt = cashAmt;
payDtl.PaymentAmt = cashAmt;


Line 172: Line 174:
</syntaxhighlight>
</syntaxhighlight>
</tabber>
</tabber>
<br/>
*Use method '''GetFirstCashAccount(BCE.Data.DBSetting)''' can retrieve the first row of the payment type that is Cash.
<syntaxhighlight lang="c#">
//Get the first row payment type that is "CASH"
//Must have a Payment Method's "Payment Type" that is "CASH"
//in General Maintenance | Payment Method Maintenance
payDtl.PaymentMethod = BCE.AutoCount.Invoicing.CommonFunction.GetFirstCashAccount(dbSetting);
</syntaxhighlight>


<br/>
==Edit Cash Sale that has payment==
==Edit Cash Sale that has payment==
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">

Revision as of 01:10, 7 March 2019

Technical Specification

  1. NetTotal must not be negative amount
  2. Negative Quantity is allowed, if it does not violate the NetTotal rule.

References of AutoCount Accounting 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.Invoicing.dll
BCE.AutoCount.Invoicing.Sales.dll

Cash Sale API Usage

New

public void NewCashSale(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand cmd =
        BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand.Create(dbSetting);
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSale doc = cmd.AddNew();
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleDetail dtl;

    doc.DebtorCode = "300-C001";
    doc.DocNo = "CS-00011";
    doc.DocDate = DateTime.Today.Date;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";
    dtl.Qty = 1;
    dtl.UOM = "UNIT";
    dtl.UnitPrice = 50.20M;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00002";
    dtl.Qty = 10;
    dtl.UOM = "UNIT";
    dtl.UnitPrice = 60.20M;
    dtl.Discount = "30%";

    doc.Save();
}

Edit

public void EditCashSale(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand cmd =
        BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand.Create(dbSetting);
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSale doc = cmd.Edit("CS-00011");
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleDetail dtl;

    if (doc != null)
    {
        doc.ClearDetails();
                    
        dtl = doc.AddDetail();
        dtl.ItemCode = "FG00001";
        dtl.Qty = 1;
        dtl.UOM = "UNIT";
        dtl.UnitPrice = 50.20M;

        dtl = doc.AddDetail();
        dtl.ItemCode = "FG00003";
        dtl.Qty = 10;
        dtl.UOM = "UNIT";
        dtl.UnitPrice = 6.30M;
        dtl.Discount = "30%";

        doc.Save();
    }
}

Cancel

public void CancelCashSale(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand cmd =
        BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand.Create(dbSetting);

    cmd.CancelDocument("CS-00011", BCE.AutoCount.Authentication
        .UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
}

Delete

public void DeleteCashSale(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand cmd =
        BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand.Create(dbSetting);

    cmd.Delete("CS-00011");
}


New Cash Sale with Cash Sale Payment

[DRAFT]

In writing.

public void NewCashSaleWithCash(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand cmd =
        BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleCommand.Create(dbSetting);
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSale doc = cmd.AddNew();
    BCE.AutoCount.Invoicing.Sales.CashSale.CashSaleDetail dtl;

    //doc.DocNo = "CS-00011";
    doc.DebtorCode = "300-C001";
    doc.DocDate = DateTime.Today.Date;

    //Enable 5 cents rounding in this document
    //Ensure the "5 Cents Rounding Adjustment Account" is set to an account,
    //in Tools | Options > G/L | G/L Posting...
    doc.IsRoundAdj = true;

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00001";
    dtl.Qty = 1;
    dtl.UOM = "UNIT";
    dtl.UnitPrice = 50.20M;
    dtl.TaxType = "S-10";

    dtl = doc.AddDetail();
    dtl.ItemCode = "FG00002";
    dtl.Qty = 10;
    dtl.UOM = "UNIT";
    dtl.UnitPrice = 60.20M;
    dtl.Discount = "30%";
    dtl.TaxType = "S-10";

    //FinalTotal is the total after 5 cents rounding
    MakeCashPayment(doc, doc.FinalTotal, dbSetting);

    try
    {
        doc.Save();
        BCE.Application.AppMessage.ShowMessage($"{doc.DocNo} is created.");
    }
    catch (Exception ex)
    {
        BCE.Application.AppMessage.ShowErrorMessage($"Failed to save Cash Sale.\n{ex.Message}");
    }
}

//Create a Cash Payment for a Cash Sale
private void MakeCashPayment(BCE.AutoCount.Invoicing.Sales.CashSale.CashSale cs, decimal cashAmt, BCE.Data.DBSetting dbSetting)
{
    //PaymentMode 1 indicate the payment in this Cash Sale is by Cash
    cs.PaymentMode = 1;

    cs.CashPayment = cashAmt;
    cs.CCApprovalCode = DBNull.Value;
    cs.CashSalePayment.ARPayment.ClearDetails();

    cs.CashSalePayment = BCE.AutoCount.Invoicing.Sales.SalesPayment.Create(
        cs.ReferPaymentDocKey, cs.DocKey,
        BCE.AutoCount.Document.DocumentType.CashSale, dbSetting);

    cs.CashSalePayment.DebtorCode = cs.DebtorCode;
    cs.CashSalePayment.CurrencyCode = cs.CurrencyCode;
    cs.CashSalePayment.DocDate = cs.DocDate;

    BCE.AutoCount.ARAP.ARPayment.ARPaymentDTLEntity payDtl = cs.CashSalePayment.ARPayment.NewDetail();

    //"CASH" must be maintained
    //in General Maintenance | Payment Method Maintenance
    payDtl.PaymentMethod = "CASH";
    payDtl.PaymentAmt = cashAmt;

    if (cs.CashSalePayment.PaymentAmt > 0)
        cs.ReferPaymentDocKey = cs.CashSalePayment.DocKey;
}


  • Use method GetFirstCashAccount(BCE.Data.DBSetting) can retrieve the first row of the payment type that is Cash.
//Get the first row payment type that is "CASH"
//Must have a Payment Method's "Payment Type" that is "CASH"
//in General Maintenance | Payment Method Maintenance
payDtl.PaymentMethod = BCE.AutoCount.Invoicing.CommonFunction.GetFirstCashAccount(dbSetting);


Edit Cash Sale that has payment



See Also

Go to menu

Go to top
Resources For AutoCount Software Developers