Cash Book Payment Voucher v2

From AutoCount Resource Center
Revision as of 08:28, 7 June 2018 by DanielY (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Technical Specification

  1. Net Total of the voucher must be positive;
  2. Net Total of the voucher must not be zero.
  3. Total Payment amounts must be tally with the total amounts in details.

References of AutoCount Accounting 2.0

AutoCount.Accounting.dll
AutoCount.Accounting.UI.dll
AutoCount.dll
AutoCount.MainEntry.dll
AutoCount.UI.dll
AutoCount.GL.dll



Sample with data model

Create new Cash Book Payment Voucher

internal void NewCashBookPayment(UserSession userSession, CashBookPaySource source)
{
    AutoCount.GL.CashBook.CashBookCommand cmd =
        AutoCount.GL.CashBook.CashBookCommand.Create(userSession, userSession.DBSetting);

    AutoCount.GL.CashBook.CashBook doc = cmd.AddNew(AutoCount.GL.CashBook.CashBookType.CashPayment);
    AutoCount.GL.CashBook.CashBookPaymentDetail payment = null;
    AutoCount.GL.CashBook.CashBookDetail cbdtl = null;

    doc.PayTo = source.Payee;
    doc.Description = source.Description;
    doc.CurrencyCode = source.CurrencyCode;
    doc.CurrencyRate = source.CurrencyRate;
    doc.DocNo = source.VoucherNo;
    doc.DocDate = source.VoucherDate;

    foreach (PaymentDetail pay in source.Payments)
    {
        payment = doc.AddPaymentDetail();
        payment.PaymentMethod = pay.PaymentMethod;
        payment.ChequeNo = pay.ChequeNo;
        payment.BankCharge = pay.BankCharge;
        payment.PaymentAmount = pay.Amount;
    }

    foreach (CashBookDetail dtl in source.Details)
    {
        cbdtl = doc.AddDetail();
        cbdtl.AccNo = dtl.Account;
        cbdtl.Description = dtl.Description;
        cbdtl.Amount = dtl.Amount;
        cbdtl.TaxType = dtl.GSTCode;
        cbdtl.InclusiveTax = dtl.Inclusive;
    }

    try
    {
        doc.Save();
        //log success
    }
    catch (AutoCount.AppException ex)
    {
        //log ex.Message
    }
}

Classes of source (data model)

public class CashBookPaySource
{
    public string Payee { get; set; }
    public string Description { get; set; }
    public string CurrencyCode { get; set; }
    public decimal CurrencyRate { get; set; }
    public string VoucherNo { get; set; }
    public DateTime VoucherDate { get; set; }
    public List<PaymentDetail> Payments { get; set; } = new List<PaymentDetail>();
    public List<CashBookDetail> Details { get; set; } = new List<CashBookDetail>();
}

public class PaymentDetail
{
    public string PaymentMethod { get; set; }
    public string ChequeNo { get; set; }
    public decimal BankCharge { get; set; }
    public decimal Amount { get; set; }
}

public class CashBookDetail
{
    public string Account { get; set; }
    public string Description { get; set; }
    public decimal Amount { get; set; }
    public string GSTCode { get; set; }
    public bool Inclusive { get; set; } = false;
}

Implementation

public MainEntry(AutoCount.Authentication.UserSession userSession)
{
    CashBookSource newCB = new CashBookSource()
    {
        Payee = "ELECTRICITY COMPANY",
        Description = "June 2017 Electricity",
        CurrencyCode = "MYR",
        CurrencyRate = 1,
        VoucherNo = "<<New>>",
        VoucherDate = new DateTime(2018, 5, 10),
    };

    newCB.Payments.Add(new PaymentDetail(){ PaymentMethod = "CHQ", ChequeNo = "P00012", Amount = 500 });
    newCB.Payments.Add(new PaymentDetail(){ PaymentMethod = "CASH",                     Amount = 20.15M });

    newCB.Details.Add(new CashBookDetail()
    {
        Account = "900-1025",
        Description = "ELECTRICITY BILL JUNE 2017",
        Amount = 520.15M,
        GSTCode = "TX-S",
        Inclusive = true
    });

    NewCashBookPayment(userSession, newCB);
}
Two types of payments are added to a single payment voucher.
When the electricity bill is GST inclusive, set the InclusiveTax to true.



See Also



Go to menu

Go to top
Resources For AutoCount Software Developers