AR Invoice v2

From AutoCount Resource Center

Technical Specification

  1. AccNo (Sales A/C) cannot be empty or null.
  2. AccNo (Sales A/C) cannot be Debtor or Creditor Account No.
  3. NetTotal cannot be in negative value.
  4. NetTotal is the sum of amount & GST from details, this field is ReadOnly.
  5. Total GST is the sum of GST & GST Adjustment from details, this field is ReadOnly.
  6. Do not set empty string to ProjNo and DeptNo.
    When the value of ProjNo and DeptNo is empty, set to null or DBNull.Value.
    • Note that when null is assigned to ProjNo and DeptNo in AR & AP that is an object type, the value of the field is converted to DBNull.Value.
      //dtl.ProjNo in AR & AP is an object type, not string type
      dtl.ProjNo = null;
      if (dtl.ProjNo == null)
          AutoCount.AppMessage.ShowMessage("Project is empty.");
      else
          AutoCount.AppMessage.ShowMessage("Project has value.");
      
    The above code will always prompt "Project has value".
    • When change null to DBNull.Value at the comparison
      dtl.ProjNo = null;
      if (dtl.ProjNo == DBNull.Value)
          AutoCount.AppMessage.ShowMessage("Project is empty.");
      else
          AutoCount.AppMessage.ShowMessage("Project has value.");
      
    The above code will prompt "Project is empty."


References of AutoCount Accounting version 2.0

AutoCount.Accounting.dll
AutoCount.Accounting.UI.dll
AutoCount.dll
AutoCount.MainEntry.dll
AutoCount.UI.dll
AutoCount.ARAP.dll


Sample with data model

Create new AR Invoice

public void NewARInvoiceEntry(AutoCount.Authentication.UserSession userSession, ARInvoiceSource source)
{
    string userID = userSession.LoginUserID;
    AutoCount.ARAP.ARInvoice.ARInvoiceDataAccess cmd = AutoCount.ARAP.ARInvoice.ARInvoiceDataAccess.Create(userSession, userSession.DBSetting);
    AutoCount.ARAP.ARInvoice.ARInvoiceEntity doc = cmd.NewARInvoice();
    AutoCount.ARAP.ARInvoice.ARInvoiceDTLEntity dtl = null;

    doc.DebtorCode = source.CustomerCode;
    doc.Description = source.Description;
    doc.CurrencyRate = source.CurrencyRate;
    doc.DocNo = source.Document;
    doc.DocDate = source.Date;
    doc.SalesAgent = source.SalesPerson;
    doc.JournalType = source.JournalType;
    //Set whether to apply rounding method of either by Document or by Each Line,
    //this may affect different result in GST Calculation due to decimal point rounding.
    doc.RoundingMethod = source.RoundMethod;
    //Document Level Inclusive Tax
    doc.InclusiveTax = source.Inclusive;

    foreach (ARInvoiceDetail ivDtl in source.Details)
    {
        dtl = doc.NewDetail();

        dtl.AccNo = ivDtl.Account;
        dtl.Description = ivDtl.Description;
        dtl.ProjNo = ivDtl.Project;
        dtl.DeptNo = ivDtl.Department;
        dtl.TaxType = ivDtl.GSTCode;
        dtl.Amount = ivDtl.Amount ?? 0;
        dtl.TaxAdjustment = ivDtl.GSTAdjustment;
    }

    try
    {
        cmd.SaveARInvoice(doc, userID);
        //log success
        //AutoCount.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
    }
    catch (AutoCount.AppException ex)
    {
        //log ex.Message
        //AutoCount.AppMessage.ShowMessage(ex.Message);
    }
}

Classes of Source

public class ARInvoiceSource
{
    public string CustomerCode { get; set; }
    public string Description { get; set; }
    public decimal CurrencyRate { get; set; } = 1;
    public string Document { get; set; }
    public DateTime Date { get; set; }
    public string SalesPerson { get; set; }
    public string JournalType { get; set; } = "SALES";
    public AutoCount.Document.DocumentRoundingMethod RoundMethod { get; set; } =
        AutoCount.Document.DocumentRoundingMethod.LineByLine_Ver2;
    public bool Inclusive { get; set; } = false;
    public List<ARInvoiceDetail> Details { get; set; } = new List<ARInvoiceDetail>();
}

public class ARInvoiceDetail
{
    public string Account { get; set; }
    public string Description { get; set; }
    public string Project { get; set; }
    public string Department { get; set; }
    public decimal? Amount { get; set; }
    public string GSTCode { get; set; }
    public decimal GSTAdjustment { get; set; }
}

Implementation

public void MainEntry(AutoCount.Authentication.UserSession userSession)
{
    ARInvoiceSource newDoc = new ARInvoiceSource()
    {
        CustomerCode = "300-A001",
        Description = "SALES GENERATED",
        Document = "<<New>>",
        Date = new DateTime(2018, 5, 18),
        Inclusive = true
    };

    newDoc.Details.Add(new ARInvoiceDetail() { Account = "500-0000", Description = "APPLE IPHONE X", Amount = 5000, GSTCode = "SR-S" });
    newDoc.Details.Add(new ARInvoiceDetail() { Account = "520-0000", Description = "Discount 10%", Amount = -500, GSTCode = "SR-S" });
    //No error while the Account is empty, because the amount is zero;
    //Hence no posting to account is required.
    newDoc.Details.Add(new ARInvoiceDetail() { Description = "GIFT", Amount = 0, GSTCode = "SR-S" });
    newDoc.Details.Add(new ARInvoiceDetail() { Account = "500-0000", Description = "FREE Screen Protector", GSTCode = "SR-S" });

    NewARInvoiceEntry(userSession, newDoc);
}

See Also

AutoCount Accounting Account API
AR AP
Transactions Version Transactions Version
AR Debtor (Customer) 1.8, 1.9
2.0
AP Creditor (Supplier) 1.8, 1.9
2.0
AR Invoice 1.8, 1.9
2.0
AP Invoice 1.8, 1.9
2.0
AR Received Payment 1.8, 1.9
2.0
AP Payment 1.8, 1.9
2.0
AR Debit Note 1.8, 1.9
2.0
AP Debit Note 1.8, 1.9
2.0
AR Credit Note 1.8, 1.9
2.0
AP Credit Note 1.8, 1.9
2.0
AR Refund 1.8, 1.9
2.0
AP Refund 1.8, 1.9
2.0
AR Deposit 1.8, 1.9
2.0
AP Deposit 1.8, 1.9
2.0
AR Deposit - Create New or Update
with Refund & Forfeit
1.8, 1.9
2.0
A/R and A/P Contra Entry 1.8, 1.9
2.0

Go to menu

Go to top
Resources For AutoCount Software Developers