AP Invoice v2: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
==Technical Specification== |
|||
==Rules in APInvoice== |
|||
# AccNo (Purchase A/C) cannot be empty or null. |
# AccNo (Purchase A/C) cannot be empty or null. |
||
# AccNo (Purchase A/C) cannot be Creditor Account No. |
# AccNo (Purchase A/C) cannot be Debtor or Creditor Account No. |
||
# NetTotal cannot be in negative value. |
# NetTotal cannot be in negative value. |
||
# '''NetTotal''' is the sum of amount & GST from details, this field is '''ReadOnly'''. |
# '''NetTotal''' is the sum of amount & GST from details, this field is '''ReadOnly'''. |
||
# Total '''GST''' is the sum of GST & GST Adjustment from details, this field is '''ReadOnly'''. |
# Total '''GST''' is the sum of GST & GST Adjustment from details, this field is '''ReadOnly'''. |
||
# Do not set '''empty string''' to '''ProjNo''' and '''DeptNo |
# 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'''.<syntaxhighlight lang="csharp" highlight="3,6"> |
|||
//dtl.ProjNo in AR & AP is an object type, not string type |
|||
dtl.ProjNo = null; |
dtl.ProjNo = null; |
||
if (dtl.ProjNo == null) |
if (dtl.ProjNo == null) |
||
Line 14: | Line 16: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
#:The above code will always prompt "Project has value". |
#:The above code will always prompt "Project has value". |
||
#*When change '''null''' to '''DBNull.Value''' |
#*When change '''null''' to '''DBNull.Value''' at the comparison<syntaxhighlight lang="csharp" highlight="2,3"> |
||
dtl.ProjNo = null; |
dtl.ProjNo = null; |
||
if (dtl.ProjNo == DBNull.Value) |
if (dtl.ProjNo == DBNull.Value) |
||
Line 173: | Line 175: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
==Sample== |
==Sample with data model== |
||
===Create new AP Invoice from DataModel=== |
===Create new AP Invoice from DataModel=== |
||
<syntaxhighlight lang="csharp"> |
<syntaxhighlight lang="csharp"> |
Revision as of 02:35, 5 June 2018
Technical Specification
- AccNo (Purchase A/C) cannot be empty or null.
- AccNo (Purchase A/C) cannot be Debtor or Creditor Account No.
- NetTotal cannot be in negative value.
- NetTotal is the sum of amount & GST from details, this field is ReadOnly.
- Total GST is the sum of GST & GST Adjustment from details, this field is ReadOnly.
- 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."
Assemblies 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
API Usage
New AP Invoice
public void NewAPInvoiceEntry(AutoCount.Authentication.UserSession userSession)
{
AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(userSession, userSession.DBSetting);
AutoCount.ARAP.APInvoice.APInvoiceEntity doc = cmd.NewAPInvoice();
AutoCount.ARAP.APInvoice.APInvoiceDTLEntity dtl = null;
doc.DocNo = "<<New>>";
doc.CreditorCode = "400-X001";
doc.DocDate = new DateTime(2018, 6, 4);
doc.Description = "Purchase Generated";
doc.PurchaseAgent = "TOM";
doc.JournalType = "PURCHASE";
doc.RoundingMethod = AutoCount.Document.DocumentRoundingMethod.LineByLine_Ver2;
//Document Level Inclusive Tax
doc.InclusiveTax = true;
//Add two lines of detail
dtl = doc.NewDetail();
dtl.AccNo = "700-1010";
dtl.Description = "Raw Material Metal";
dtl.ProjNo = null;
dtl.Amount = 1000.00M;
dtl = doc.NewDetail();
dtl.AccNo = "700-1010";
dtl.Description = "Process Cost";
dtl.ProjNo = null;
dtl.Amount = 150.00M;
try
{
cmd.SaveAPInvoice(doc, userSession.LoginUserID);
//log success
//AutoCount.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
}
catch (AutoCount.AppException ex)
{
//log ex.Message
//AutoCount.AppMessage.ShowMessage(ex.Message);
}
}
Edit AP Invoice
public void EditAPInvoiceEntry(AutoCount.Authentication.UserSession userSession)
{
AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(userSession, userSession.DBSetting);
AutoCount.ARAP.APInvoice.APInvoiceEntity doc = cmd.GetAPInvoice("PI-000001");
AutoCount.ARAP.APInvoice.APInvoiceDTLEntity dtl = null;
//if this AP Invoice has been knockoff(offset) with payment or credit note,
//Changing of CreditorCode is not allowed.
//Therefore, when such case arise, it is advised to issue Credit Note and issue a new AP Invoice
//doc.CreditorCode = "400-X001";
doc.DocDate = new DateTime(2018, 6, 4);
doc.Description = "Purchase Generated";
doc.PurchaseAgent = "TOM";
doc.JournalType = "PURCHASE";
//Set Total Calculation Method
doc.RoundingMethod = AutoCount.Document.DocumentRoundingMethod.LineByLine_Ver2;
//Document Level Inclusive Tax
doc.InclusiveTax = true;
doc.ClearDetails();
//Add two lines of detail
dtl = doc.NewDetail();
dtl.AccNo = "700-1010";
dtl.Description = "Raw Material Metal";
dtl.ProjNo = DBNull.Value;
dtl.Amount = 1000.00M;
dtl = doc.NewDetail();
dtl.AccNo = "700-1010";
dtl.Description = "Process Cost";
dtl.ProjNo = "Project A";
dtl.Amount = 150.00M;
try
{
cmd.SaveAPInvoice(doc, userSession.LoginUserID);
//log success
//AutoCount.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
}
catch (AutoCount.AppException ex)
{
//log ex.Message
//AutoCount.AppMessage.ShowMessage(ex.Message);
}
}
Cancel (void) AP Invoice
public void CancelAPInvoice(AutoCount.Authentication.UserSession userSession)
{
string docNo = "PI-000001";
AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(userSession, userSession.DBSetting);
try
{
cmd.CancelAPInvoice(docNo, userSession.LoginUserID);
}
catch (AutoCount.AppException ex)
{
AutoCount.AppMessage.ShowMessage(
string.Format("Fail to Cancel AP Invoice '{0}'.\n {1}", docNo, ex.Message));
}
}
Delete AP Invoice
public void DeleteAPInvoice(AutoCount.Authentication.UserSession userSession)
{
string docNo = "PI-000001";
AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(userSession, userSession.DBSetting);
try
{
cmd.DeleteAPInvoice(docNo);
}
catch (AutoCount.AppException ex)
{
AutoCount.AppMessage.ShowMessage(
string.Format("Fail to delete of document '{0}'.\n{1}", docNo, ex.Message));
}
}
Sample with data model
Create new AP Invoice from DataModel
public void NewAPInvoice(AutoCount.Authentication.UserSession userSession, APInvoiceSource source)
{
AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(userSession, userSession.DBSetting);
AutoCount.ARAP.APInvoice.APInvoiceEntity doc = cmd.NewAPInvoice();
AutoCount.ARAP.APInvoice.APInvoiceDTLEntity dtl = null;
doc.CreditorCode = source.SupplierCode;
doc.DocNo = source.Document;
doc.DocDate = source.Date;
doc.CurrencyRate = source.CurrencyRate;
doc.Description = source.Description;
doc.PurchaseAgent = source.PurchaseAgent;
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 (APInvoiceDetail 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.SaveAPInvoice(doc, userSession.LoginUserID);
//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 (DataModel)
public class APInvoiceSource
{
public string SupplierCode { 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 PurchaseAgent { get; set; }
public string JournalType { get; set; } = "PURCHASE";
public AutoCount.Document.DocumentRoundingMethod RoundMethod { get; set; } =
AutoCount.Document.DocumentRoundingMethod.LineByLine_Ver2;
public bool Inclusive { get; set; } = false;
public List<APInvoiceDetail> Details { get; set; } = new List<APInvoiceDetail>();
}
public class APInvoiceDetail
{
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)
{
APInvoiceSource newDoc = new APInvoiceSource()
{
SupplierCode = "400-X001",
Description = "PURCHASE GENERATED",
Document = "<<New>>",
Date = new DateTime(2018, 5, 28),
PurchaseAgent = "TOM",
JournalType = "PURCHASE",
RoundMethod = AutoCount.Document.DocumentRoundingMethod.LineByLine_Ver2,
Inclusive = true
};
newDoc.Details.Add(new APInvoiceDetail() { Account = "700-1010", Description = "Raw Material Metal", Amount = 1000M });
newDoc.Details.Add(new APInvoiceDetail() { Account = "700-1010", Description = "Process Cost", Project = "Project A", Amount = 150M });
NewAPInvoice(userSession, newDoc);
}
Go to top
|
Resources For AutoCount Software Developers
|