AR Received Payment

Revision as of 08:02, 28 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.
  3. Payment net total must be the sum of Payment Amount in Payment Detail
  4. Total of knockoff Amount must not exceed the sum of Payment Amount.
  5. Payment Method is created in General Maintenance | Payment Method Maintenance.

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

AR Payment API Usage

New

public void NewARPayment(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess cmd = BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess.Create(dbSetting);
    BCE.AutoCount.ARAP.ARPayment.ARPaymentEntity doc = cmd.NewARPayment();
    //If you want to set your own Payment Voucher number, uncomment the next line, otherwise, the system will use running number.
    //doc.DocNo = “RC-0001″;
    doc.DebtorCode = "300-A001";

    // Add one payment detail
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDTLEntity paymentDetail = doc.NewDetail();
    paymentDetail.PaymentMethod = "CASH";
    paymentDetail.PaymentAmt = 100;
    paymentDetail.ChequeNo = "MBB 123456";
    //Knockoff Invoice
    doc.KnockOff(BCE.AutoCount.Document.DocumentType.ARInvoice, "IV-0001", 100);

    cmd.SaveARPayment(doc, BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
}

Edit

public void EditARPayment(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess cmd = BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess.Create(dbSetting);
    BCE.AutoCount.ARAP.ARPayment.ARPaymentEntity doc = cmd.GetARPayment("RC-0001");
    //If doc (arPayment) is null, doc (arPayment) does not exist in AR Payment;
    //Then exit this function
    if (doc == null)
        return;

    doc.ClearDetails();
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDTLEntity paymentDetail = doc.NewDetail();
    paymentDetail.PaymentMethod = "CARD";
    paymentDetail.PaymentAmt = 600;
    cmd.SaveARPayment(doc, BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
}

Delete

private void DeleteARPayment(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess cmd = BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess.Create(dbSetting);
    cmd.DeleteARPayment("RC-0001", BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID);
}

Cancel


Sample Code with Data Model for Testing

In this sample code provide the concept of how to create a new AR Payment with tested data.

Test Sample Result

Test Sample Data

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; }

    //PaymentCurrencyCode will be the currency code of Debtor's Account.
    //Need to define only when PaymentCurrencyCode is different from Debtor's Account Currency
    public string PaymentCurrencyCode { get; set; }

    //Require PaymentToHomeCurrencyRate,
    //when PaymentCurrencyCode is in Foreign Currency 
    public decimal? PaymentToHomeCurrencyRate { get; set; }

    //Require PaymentToDebtorCurrencyRate,
    //when PaymentCurrencyCode is different from Debtor CurrencyCode
    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
{
    //Document Type of ARPayment knockoff
    public const string ARInvoiceDocType = BCE.AutoCount.Document.DocumentType.ARInvoice;
    public const string ARDebitNoteDocType = BCE.AutoCount.Document.DocumentType.ARDN;

    //Must assign with valid document type
    //in this class, you may find both possible document type for ARPayment Knockoff
    //(1) ARInvoiceDocType, and (2) ARDebitNoteDocType
    public string DocType { get; set; }

    //The DocNo must already exist in the respective document type
    public string DocNo { get; set; }

    //The amount to be used to knockoff invoice,
    //the total must not be more than sum of Payment Amount
    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)
{
    //Get the login user id
    string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
    //Create command object of ARPayment
    BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess cmd =
        BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess.Create(dbSetting);
    //Create a new ARPayment transaction
    BCE.AutoCount.ARAP.ARPayment.ARPaymentEntity doc = cmd.NewARPayment();

    //Assign value to master table
    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;

    //Loop and assign value to payment detail
    source.PaymentDetail.ForEach(s => AddARPaymentDetail(s, doc.NewDetail));

    //Knockoff document
    foreach (PaymentKnockoffSource knockoff in source.PaymentKnockoff)
    {
        if (knockoff.Date.HasValue)
        {
            doc.KnockOff(knockoff.DocType, knockoff.DocNo, knockoff.Amount, knockoff.Date.Value);
        }
        else
        {
            //If Knockoff date is not defined, system will assign Payment Date to Knockoff Date
            doc.KnockOff(knockoff.DocType, knockoff.DocNo, knockoff.Amount);
        }
    }

    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.ChequeNo;
    dtl.PaymentAmt = source.PaymentAmount;
    dtl.BankCharge = source.BankCharge ?? dtl.BankCharge;
    dtl.BankChargeTaxType = source.BankChargeTaxCode ?? dtl.BankChargeTaxType;
    dtl.BankChargeTaxRefNo = source.BankChargeBillNoForGst ?? dtl.BankChargeTaxRefNo;
    dtl.PaymentBy = source.PaymentBy ?? source.PaymentBy;

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


See Also