Programmer:Cash Sale with Payment: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 95:
<br/>
==New Cash Sale with Cash Sale Payment==
{{DRAFT|In writing.}}
<tabber>
CASH=
Line 168 ⟶ 167:
payDtl.PaymentMethod = "CASH";
payDtl.PaymentAmt = cashAmt;
 
if (cs.CashSalePayment.PaymentAmt > 0)
cs.ReferPaymentDocKey = cs.CashSalePayment.DocKey;
}
</syntaxhighlight>
|-|
Credit Card=
<syntaxhighlight lang="c#">
public void NewCashSaleWithCreditCard(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";
 
MakeCreditCardPayment(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}");
}
}
 
private void MakeCreditCardPayment(BCE.AutoCount.Invoicing.Sales.CashSale.CashSale cs, decimal cardAmt, BCE.Data.DBSetting dbSetting)
{
//PaymentMode 2 indicate the payment with Card
//or similar payment mode that requires "Approval Code" and "Card No".
cs.PaymentMode = 2;
cs.CashPayment = 0M;
cs.CCApprovalCode = "ABC0100123";
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();
 
//"MASTER" must be maintained
//in General Maintenance | Payment Method Maintenance
payDtl.PaymentMethod = "MASTER";
payDtl.ChequeNo = "12XXXX-YYY-ZZZ-1234";
payDtl.PaymentAmt = cardAmt;
 
if (cs.CashSalePayment.PaymentAmt > 0)
Line 182 ⟶ 257:
payDtl.PaymentMethod = BCE.AutoCount.Invoicing.CommonFunction.GetFirstCashAccount(dbSetting);
</syntaxhighlight>
 
<br/>
==Edit Cash Sale that has payment==
<syntaxhighlight lang="c#">
</syntaxhighlight>