AR Received Payment: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
No edit summary
No edit summary
Line 1: Line 1:
{{NavigateDeveloper}}
{{NavigateDeveloper}}
==Incomplete (new document flow writing)==
{{Warn|Incomplete (new document flow writing)}}


==Rules in AR Payment==
==Rules in AR Payment==
# Payment '''Knockoff Date''' must be greater than the '''Payment Date'''.
# Payment '''Knockoff Date''' must be greater than the '''Payment Date'''.
# Payment net total must be greater than 0.
# Payment net total must be greater than 0.
# Payment net total must be the sum of Payment Amount in '''Payment Detail'''
# Total of '''knockoff Amount''' must not exceed the sum of Payment Amount.


==Assemblies in AutoCount Accounting version 1.8==
==Assemblies in AutoCount Accounting version 1.8==
Line 16: Line 18:
</pre>
</pre>


==AR Payment API Usage==
==Complete Sample Code for Testing==
===New===
===Edit===
===Delete===
===Cancel===

==Sample Code 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 Data Modal (Example for reference Only)===
'''Source''' is the '''DataModel''' of your source data that is implemented to update data to AutoCount Accounting.
'''Source''' is the '''DataModel''' of your source data that is implemented to update data to AutoCount Accounting.
Line 47: Line 61:
public string ChequeNo { get; set; }
public string ChequeNo { get; set; }
public decimal PaymentAmount { get; set; }
public decimal PaymentAmount { get; set; }
public decimal BankCharge { get; set; }
public decimal? BankCharge { get; set; }
public string BankChargeTaxCode { get; set; }
public string BankChargeTaxCode { get; set; }
public string BankChargeBillNoForGst { get; set; }
public string BankChargeBillNoForGst { get; set; }
Line 58: Line 72:
public class PaymentKnockoffSource
public class PaymentKnockoffSource
{
{
//Document Type of ARPayment knockoff
public const string ARInvoiceDocType = BCE.AutoCount.Document.DocumentType.ARInvoice;
public const string ARInvoiceDocType = BCE.AutoCount.Document.DocumentType.ARInvoice;
public const string ARDebitNoteDocType = BCE.AutoCount.Document.DocumentType.ARDN;
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; }
public string DocType { get; set; }

//The DocNo must already exist in the respective document type
public string DocNo { get; set; }
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; }
public decimal Amount { get; set; }

//When knockoff date is null,
//When knockoff date is null,
//system will use Payment Date as knockoff date
//system will use Payment Date as knockoff date
Line 74: Line 98:
public void NewARPayment(ARPaymentSource source, BCE.Data.DBSetting dbSetting)
public void NewARPayment(ARPaymentSource source, BCE.Data.DBSetting dbSetting)
{
{
//Get the login user id
string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
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 cmd =
BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess.Create(dbSetting);
BCE.AutoCount.ARAP.ARPayment.ARPaymentDataAccess.Create(dbSetting);
//Create a new ARPayment transaction
BCE.AutoCount.ARAP.ARPayment.ARPaymentEntity doc = cmd.NewARPayment();
BCE.AutoCount.ARAP.ARPayment.ARPaymentEntity doc = cmd.NewARPayment();


//Assign value to master table
doc.DebtorCode = source.DebtorCode;
doc.DebtorCode = source.DebtorCode;
doc.DocNo = source.DocumentNo;
doc.DocNo = source.DocumentNo;
Line 89: Line 117:
doc.DeptNo = source.Department;
doc.DeptNo = source.Department;


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


//Knockoff document
foreach (ARPaymentKnockoff knockoff in source.PaymentKnockoff)
foreach (PaymentKnockoffSource knockoff in source.PaymentKnockoff)
{
{
if (knockoff.Date.HasValue)
//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);
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);
}
}
}


Line 109: Line 145:
}
}
}
}
</syntaxhighlight>


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


if (source.ReturnChequeDate.HasValue)
if (source.ReturnChequeDate.HasValue)

Revision as of 09:44, 22 December 2017

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.

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

Edit

Delete

Cancel

Sample Code 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; }
    //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
{
    //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