AR Received Payment

Revision as of 09:10, 22 December 2017 by DanielY (talk | contribs)

Go to menu

  Go to top
  Resources For AutoCount Software Developers


Incomplete (new document flow writing)

Rules in AR Payment

  1. Payment Knockoff Date must be greater than the Payment Date.
  2. Payment net total must be greater than 0.

Assemblies in AutoCount Accounting version 1.8

BCE.AutoCount.dll
BCE.AutoCount.CommonAccounting.dll
BCE.AutoCount.MainEntry.dll
BCE.Utils.dll
BCE.Utils.UI.dll
BCE.AutoCount.ARAP.dll

Complete Sample Code for Testing

Source Data Modal (Example for reference Only)

Source is the DataModel of your source data that is implemented to update data to AutoCount Accounting.
The Source DataModal designed here is for reference only.
You may either create your own data source modal, or read from your database and assign value to transaction/document of AutoCount Accounting without source data modal.
public class ARPaymentSource
{
    public string DebtorCode { get; set; }
    public string DocumentNo { get; set; }
    public string ReceiptNo2 { get; set; }
    public DateTime DocumentDate { get; set; } = DateTime.Today.Date;
    public string Description { get; set; }
    public string DepositMethod { get; set; }
    //When not defined (null), system will apply the Debtor Account's default currency code
    public string PaymentCurrencyCode { get; set; }
    public decimal? PaymentToHomeCurrencyRate { get; set; }
    public decimal? PaymentToDebtorCurrencyRate { get; set; }
    public string Project { get; set; }
    public string Department { get; set; }

    public List<ARPaymentDetailSource> PaymentDetail = new List<ARPaymentDetailSource>();
    public List<PaymentKnockoffSource> PaymentKnockoff = new List<PaymentKnockoffSource>();
}

public class ARPaymentDetailSource
{
    public string PaymentMethod { get; set; }
    public string ChequeNo { get; set; }
    public decimal PaymentAmount { get; set; }
    public decimal BankCharge { get; set; }
    public string BankChargeTaxCode { get; set; }
    public string BankChargeBillNoForGst { get; set; }
    public string PaymentBy { get; set; }
    //If this cheque is returned/bounced cheque
    //Set the returned/bounced date. Otherwise it is null
    public DateTime? ReturnChequeDate { get; set; }
}

public class PaymentKnockoffSource
{
    public const string ARInvoiceDocType = BCE.AutoCount.Document.DocumentType.ARInvoice;
    public const string ARDebitNoteDocType = BCE.AutoCount.Document.DocumentType.ARDN;

    public string DocType { get; set; }
    public string DocNo { get; set; }
    public decimal Amount { get; set; }
    //When knockoff date is null,
    //system will use Payment Date as knockoff date
    public DateTime? Date { get; set; }
}

Create New ARPayment

public void NewARPayment(ARPaymentSource source, BCE.Data.DBSetting dbSetting)
{
    string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess cmd =
        BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess.Create(dbSetting);
    BCE.AutoCount.ARAP.ARPayment.ARPaymentEntity doc = cmd.NewARPayment();

    doc.DebtorCode = source.DebtorCode;
    doc.DocNo = source.DocumentNo;
    doc.DocNo2 = source.ReceiptNo2;
    doc.DocDate = source.DocumentDate;
    doc.CurrencyCode = source.PaymentCurrencyCode ?? doc.CurrencyCode;
    doc.ToHomeRate = source.PaymentToHomeCurrencyRate ?? doc.ToHomeRate;
    doc.ToDebtorRate = source.PaymentToDebtorCurrencyRate ?? doc.ToDebtorRate;
    doc.ProjNo = source.Project;
    doc.DeptNo = source.Department;

    source.PaymentDetail.ForEach(s => AddARPaymentDetail(s, doc.NewDetail));

    foreach (ARPaymentKnockoff knockoff in source.PaymentKnockoff)
    {
        //DBDateTime is an AutoCount Accounting data type for DateTime
        //The difference of DBDateTime and DateTime is DBDateTime supports DBNull.Value input
        doc.KnockOff(knockoff.DocType, knockoff.DocNo, knockoff.Amount, knockoff.DBDate);
    }

    try
    {
        cmd.SaveARPayment(doc, userID);
        //BCE.Application.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
    }
    catch (BCE.Application.AppException ex)
    {
        //BCE.Application.AppMessage.ShowMessage(ex.Message);
        //log error
    }
}

====Add New AR Payment Detail====
private void AddARPaymentDetail(ARPaymentDetailSource source, Func<BCE.AutoCount.ARAP.ARPayment.ARPaymentDTLEntity> addPaymentDetail)
{
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDTLEntity dtl = addPaymentDetail();
    dtl.PaymentMethod = source.PaymentMethod;
    dtl.ChequeNo = source.ChequeNo;
    dtl.PaymentAmt = source.PaymentAmount;
    dtl.BankCharge = source.BankCharge;
    dtl.BankChargeTaxType = source.BankChargeTaxCode;
    dtl.BankChargeTaxRefNo = source.BankChargeBillNoForGst;
    dtl.PaymentBy = source.PaymentBy;

    if (source.ReturnChequeDate.HasValue)
    {
        dtl.IsRCHQ = true;
        dtl.RCHQDate = source.ReturnChequeDate.Value;
    }
}


See Also