AP Invoice: Difference between revisions

5,475 bytes added ,  5 years ago
no edit summary
(Created page with "==Under Construction== ===Rules in APInvoice=== # AccNo (Purchase A/C) cannot be empty or null. # AccNo (Purchase A/C) cannot be Creditor Account No. # NetTotal cannot be in...")
 
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1:
==Technical Specification==
==Under Construction==
 
 
===Rules in APInvoice===
# AccNo (Purchase A/C) cannot be empty or null.
# AccNo (Purchase A/C) cannot be Creditor Account No.
Line 8 ⟶ 5:
# '''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 it is empty, set to '''DBNull.Value'''.
 
===References of AutoCount Accounting version 1.8=, 1.9==
{{BaseReferenceAC18}}
'''BCE.AutoCount.ARAP.dll'''
Line 15 ⟶ 13:
<br />
==API Usage==
===New AP Invoice===
<syntaxhighlight lang="csharp">
public void NewAPInvoiceEntry(BCE.Data.DBSetting dbSetting)
{
string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd = BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(dbSetting);
BCE.AutoCount.ARAP.APInvoice.APInvoiceEntity doc = cmd.NewAPInvoice();
BCE.AutoCount.ARAP.APInvoice.APInvoiceDTLEntity dtl = null;
 
doc.DocNo = "<<New>>";
doc.CreditorCode = "400-X001";
doc.DocDate = new DateTime(2018, 5, 28);
doc.Description = "Purchase Generated";
doc.PurchaseAgent = "TOM";
doc.JournalType = "PURCHASE";
 
doc.RoundingMethod = BCE.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 = DBNull.Value;
dtl.Amount = 1000.00M;
 
dtl = doc.NewDetail();
dtl.AccNo = "700-1010";
dtl.Description = "Process Cost";
dtl.ProjNo = DBNull.Value;
dtl.Amount = 150.00M;
 
try
{
cmd.SaveAPInvoice(doc, userID);
//log success
//BCE.Application.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
}
catch (BCE.Application.AppException ex)
{
//log ex.Message
//BCE.Application.AppMessage.ShowMessage(ex.Message);
}
}
</syntaxhighlight>
 
===Edit AP Invoice===
<syntaxhighlight lang="csharp">
public void EditAPInvoiceEntry(BCE.Data.DBSetting dbSetting)
{
string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(dbSetting);
 
BCE.AutoCount.ARAP.APInvoice.APInvoiceEntity doc = cmd.GetAPInvoice("PI-000001");
BCE.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, 5, 28);
doc.Description = "Purchase Generated";
doc.PurchaseAgent = "TOM";
doc.JournalType = "PURCHASE";
 
doc.RoundingMethod = BCE.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, userID);
//log success
//BCE.Application.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
}
catch (BCE.Application.AppException ex)
{
//log ex.Message
//BCE.Application.AppMessage.ShowMessage(ex.Message);
}
}
</syntaxhighlight>
 
===Cancel (void) AP Invoice===
<syntaxhighlight lang="csharp">
public void CancelAPInvoice(BCE.Data.DBSetting dbSetting)
{
string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(dbSetting);
 
try
{
cmd.CancelAPInvoice("PI-000001", userID);
}
catch (BCE.Application.AppException ex)
{
BCE.Application.AppMessage.ShowMessage(ex.Message);
}
}
</syntaxhighlight>
 
===Delete AP Invoice===
<syntaxhighlight lang="csharp">
public void DeleteAPInvoice(BCE.Data.DBSetting dbSetting)
{
string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(dbSetting);
 
try
{
cmd.DeleteAPInvoice("PI-000001");
}
catch (BCE.Application.AppException ex)
{
BCE.Application.AppMessage.ShowMessage(ex.Message);
}
}
</syntaxhighlight>
 
==Sample==
===Create new AP Invoice from DataModel===
<syntaxhighlight lang="csharp">
public void NewAPInvoiceEntry(BCE.Data.DBSetting dbSetting, APInvoiceSource source)
{
string userID = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess cmd =
BCE.AutoCount.ARAP.APInvoice.APInvoiceDataAccess.Create(dbSetting);
 
BCE.AutoCount.ARAP.APInvoice.APInvoiceEntity doc = cmd.NewAPInvoice();
BCE.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, userID);
//log success
//AutoCount.AppMessage.ShowMessage(string.Format("{0} is created.", doc.DocNo));
}
catch (BCE.Application.AppException ex)
{
//log ex.Message
//AutoCount.AppMessage.ShowMessage(ex.Message);
}
}
</syntaxhighlight>
 
===Classes of Source (DataModel)===
<syntaxhighlight lang="csharp">
public class APInvoiceSource
Line 53 ⟶ 235:
 
===Implementation===
<syntaxhighlight lang="csharp">
[[File:GenerateSaleInAR.PNG|link=]]
<syntaxhighlight lang="csharp" highlight="16,17">
public void MainEntry(BCE.Data.DBSetting dbSetting)
{
ARInvoiceSourceAPInvoiceSource newDoc = new ARInvoiceSourceAPInvoiceSource()
{
CustomerCodeSupplierCode = "300400-A001X001",
Description = "SALESPURCHASE GENERATED",
Document = "<<New>>",
Date = new DateTime(20172018, 115, 2728),
PurchaseAgent = "TOM",
JournalType = "PURCHASE",
RoundMethod = BCE.AutoCount.Document.DocumentRoundingMethod.LineByLine_Ver2,
Inclusive = true
};
 
newDoc.Details.Add(new ARInvoiceDetailAPInvoiceDetail() { Account = "500700-00001010", Description = "APPLERaw IPHONEMaterial XMetal", Amount = 5000, GSTCode = "SR-S"1000M });
newDoc.Details.Add(new ARInvoiceDetailAPInvoiceDetail() { Account = "520700-00001010", Description = "DiscountProcess 10%Cost", Project = Amount"Project = -500A", GSTCodeAmount = "SR-S" 150M});
//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" });
 
NewARInvoiceEntryNewAPInvoiceEntry(dbSetting, newDoc);
}
</syntaxhighlight>
 
{{SeeAlsoAPIAccount}}
{{SeeAlsoAccount}}
 
[[Category:Programmer]]
[[Category:API]]