AR Refund: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
m (Protected "AR Refund" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite) [Delete=Allow only administrators] (indefinite)))
mNo edit summary
Line 32: Line 32:
</syntaxhighlight>
</syntaxhighlight>


===Class for source data===
===Class of source data===
<syntaxhighlight lang="csharp">
<syntaxhighlight lang="csharp">
public class RefundSource
public class RefundSource

Revision as of 08:32, 27 November 2017

Go to menu

Go to top
Resources For AutoCount Software Developers


Create new AR Refund

public void CreateNewARRefund(BCE.Data.DBSetting dbSetting, RefundSource source)
{
    string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
    BCE.AutoCount.ARAP.ARRefund.ARRefundDataAccess cmd = BCE.AutoCount.ARAP.ARRefund.ARRefundDataAccess.Create(dbSetting);
    BCE.AutoCount.ARAP.ARRefund.ARRefundEntity doc = cmd.NewARRefund();

    doc.DocNo = source.DocNo;
    doc.DocDate = source.Date;
    doc.Description = source.Description;

    BCE.AutoCount.ARAP.ARRefund.ARRefundDTLEntity dtl = doc.NewDetail();
    dtl.PaymentMethod = "CASH";
    dtl.PaymentAmt = source.RefundAmount;
    dtl.BankCharge = source.BankCharge;

    //Only ARPayment & ARCreditNote allowed to knockoff by ARRefund
    doc.KnockOff(BCE.AutoCount.Document.DocumentType.ARPayment, source.PaymentToRefund, source.RefundAmount);

    try
    {
        cmd.SaveARRefund(doc, userID);
    }
    catch (BCE.Application.AppException ex)
    {
        BCE.Application.AppMessage.ShowMessage(ex.Message);
    }
}

Class of source data

public class RefundSource
{
    public string DocNo { get; set; }
    public DateTime Date { get; set; }
    public string Description { get; set; }
    public decimal RefundAmount { get; set; }
    public decimal BankCharge { get; set; }
    public string PaymentToRefund { get; set; }
}