AR Received Payment

Revision as of 07:49, 22 December 2017 by DanielY (talk | contribs)

Go to menu

  Go to top
  Resources For AutoCount Software Developers


Incomplete

Assemblies version 1.8

BCE.AutoCount.ARAP.dll


Sample Code

Source Data Modal (Example Only)

Source is the DataModel of your source data that is to update into AutoCount Accounting.
The Source DataModal is for reference only.
You may either create your own data source, or direct read from your database and assign value to document of AutoCount Accounting.
Example here is to after data is loaded from database, then assign data to data source.
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<ARPaymentKnockoff> PaymentKnockoff = new List<ARPaymentKnockoff>();
}

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; }
    /// <summary>
    /// If this cheque is returned/bounced cheque
    /// Set the returned/bounced date. Otherwise it is null
    /// </summary>
    public DateTime? ReturnChequeDate { get; set; }
}

public class ARPaymentKnockoff
{
    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; }
    public BCE.Data.DBDateTime DBDate { get; set; } = DBNull.Value;
}

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)
    {
        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