AP Credit Note API v2: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1:
 
==Technical Specification==
#'''Net Total''' is a read-only field that is calculated from the total amount of detail (APCNDTLEntity).
#Net Total must be positive value
#'''Knockoff Total Amount''' must be equal or smaller than Net Total
 
==References of AutoCount Accounting version 2.0==
Line 7 ⟶ 9:
 
==AP Credit Note API Usage==
===New with knockoff AP Invoice===
<syntaxhighlight lang="csharp">
public void New(AutoCount.Authentication.UserSession userSession)
Line 19 ⟶ 21:
doc.DocDate = new DateTime(2018, 6, 22);
doc.Description = "Discount";
doc.SupplierCNNo = "DSC-00015";
doc.SupplierInvoiceNo = "BIL-00101";
 
//Default valueavailable values: "PURCHASE", "GENERAL"
//Note that user is able to change the above values
//that is maintained in General Maintenance > Journal Type Maintenance
doc.JournalType = "PURCHASE";
 
//Default valueavailable values: "DISCOUNT", "RETURN"
//Values are maintained in General Maintenance > C/N Type Maintenance
doc.CNType = "DISCOUNT";
 
//Add a new detail record
dtl = doc.NewDetail();
dtl.AccNo = "520-0000";
dtl.Description = "Item Sale Discount";
Line 40 ⟶ 47:
cmd.SaveAPCN(doc, userSession.LoginUserID);
//Log success
AutoCount.AppMessage.ShowMessage($"New ARCNAPCN '{doc.DocNo}' is Created.");
}
catch (AutoCount.AppException ex)
{
//Log fail
AutoCount.AppMessage.ShowMessage("Fail to create new ARCNAPCN.\n" + ex.Message);
}
}
</syntaxhighlight>
 
===Edit with knockoff AP Invoice===
====Load AP C/N with ''Document No''====
<syntaxhighlight lang="csharp">
public void Edit(AutoCount.Authentication.UserSession userSession)
{
AutoCount.ARAP.APCN.APCNDataAccess cmd = AutoCount.ARAP.APCN.APCNDataAccess.Create(userSession, userSession.DBSetting);
AutoCount.ARAP.APCN.APCNEntity doc = cmd.GetAPCN("CN-00001");
AutoCount.ARAP.APCN.APCNDTLEntity dtl = null;
 
if (doc == null)
{
//log unable to load "CN-00001", or not found
return;
}
 
//Clear all details of this document
doc.ClearDetails();
doc.ClearKnockOff();
 
doc.DocDate = new DateTime(2018, 6, 21);
doc.Description = "Discount";
doc.Reason = "Pricing Adjustment";
doc.SupplierCNNo = "DSC-00015";
doc.SupplierInvoiceNo = "BIL-00101";
 
//Default available values: "PURCHASE", "GENERAL"
//Note that user is able to change the above values
//that is maintained in General Maintenance > Journal Type Maintenance
doc.JournalType = "PURCHASE";
 
//Default available values: "DISCOUNT", "RETURN"
//Note that user is able to change the above values
doc.CNType = "RETURN";
 
dtl = doc.NewDetail();
dtl.AccNo = "520-0000";
dtl.Description = "Return of Item A";
dtl.Amount = 50.00M;
 
//Knockoff AP Invoice or AP Debit Note
//"PI-00001" is AP Invoice Document Number
doc.KnockOff(AutoCount.Document.DocumentType.APInvoice, "PI-00001", 50M);
 
try
{
cmd.SaveAPCN(doc, userSession.LoginUserID);
//Log success
AutoCount.AppMessage.ShowMessage($"New APCN '{doc.DocNo}' is Created.");
}
catch (AutoCount.AppException ex)
{
//Log fail
AutoCount.AppMessage.ShowMessage("Fail to create new APCN.\n" + ex.Message);
}
}
</syntaxhighlight>
 
====Load AP C/N with ''SupplierCNNo''====
<syntaxhighlight lang="csharp">
public void EditWithSupplierCreditNoteNo(AutoCount.Authentication.UserSession userSession)
{
string supplierCNNo = "DSC-00015";
string creditorCode = "400-X001";
 
AutoCount.ARAP.APCN.APCNDataAccess cmd = AutoCount.ARAP.APCN.APCNDataAccess.Create(userSession, userSession.DBSetting);
AutoCount.ARAP.APCN.APCNEntity doc = cmd.GetAPCN(supplierCNNo, creditorCode);
AutoCount.ARAP.APCN.APCNDTLEntity dtl = null;
 
if (doc == null)
{
//log unable to load "CN-00001", or not found
return;
}
 
//Clear all details of this document
doc.ClearDetails();
doc.ClearKnockOff();
 
doc.DocDate = new DateTime(2018, 6, 21);
doc.Description = "Discount";
doc.Reason = "Pricing Adjustment";
doc.SupplierCNNo = supplierCNNo;
doc.SupplierInvoiceNo = "BIL-00101";
 
//Default available values: "PURCHASE", "GENERAL"
//Note that user is able to change the above values
//that is maintained in General Maintenance > Journal Type Maintenance
doc.JournalType = "PURCHASE";
 
//Default available values: "DISCOUNT", "RETURN"
//Note that user is able to change the above values
doc.CNType = "RETURN";
 
dtl = doc.NewDetail();
dtl.AccNo = "520-0000";
dtl.Description = "Return of Item A";
dtl.Amount = 50.00M;
 
//Knockoff AP Invoice or AP Debit Note
//"PI-00001" is AP Invoice Document Number
doc.KnockOff(AutoCount.Document.DocumentType.APInvoice, "PI-00001", 50M);
 
try
{
cmd.SaveAPCN(doc, userSession.LoginUserID);
//Log success
AutoCount.AppMessage.ShowMessage($"New APCN '{doc.DocNo}' is Created.");
}
catch (AutoCount.AppException ex)
{
//Log fail
AutoCount.AppMessage.ShowMessage("Fail to create new APCN.\n" + ex.Message);
}
}
</syntaxhighlight>
 
===Cancel (Void)===
<syntaxhighlight lang="csharp">
public void Cancel(AutoCount.Authentication.UserSession userSession)
{
AutoCount.ARAP.APCN.APCNDataAccess cmd = AutoCount.ARAP.APCN.APCNDataAccess.Create(userSession, userSession.DBSetting);
string docNo = "CN-00001";
 
try
{
cmd.CancelAPCN(docNo, userSession.LoginUserID);
//cmd.CancelAPCN("DSC-00015", "400-X001", userSession.LoginUserID); //Cancel with SupplierCNNo
AutoCount.AppMessage.ShowMessage($"APCN 'docNo' is Created.");
}
catch (AutoCount.AppException ex)
{
//Log fail
AutoCount.AppMessage.ShowMessage($"Fail to cancel APCN {docNo}.\n" + ex.Message);
}
}
</syntaxhighlight>
 
===Delete===
<syntaxhighlight lang="csharp">
public void Delete(AutoCount.Authentication.UserSession userSession)
{
AutoCount.ARAP.APCN.APCNDataAccess cmd = AutoCount.ARAP.APCN.APCNDataAccess.Create(userSession, userSession.DBSetting);
string docNo = "CN-00001";
 
try
{
cmd.DeleteAPCN(docNo, userSession.LoginUserID);
AutoCount.AppMessage.ShowMessage($"ARCN 'docNo' is Deleted.");
}
catch (AutoCount.AppException ex)
{
//Log fail
AutoCount.AppMessage.ShowMessage($"Fail to delete APCN {docNo}.\n" + ex.Message);
}
}
</syntaxhighlight>
 
==Get Document No. from Supplier Invoice No.==
<syntaxhighlight lang="csharp">
public string GetDocNoOfSupplierInvNo(string supplierInvNo, AutoCount.Authentication.UserSession userSession)
{
Line 61 ⟶ 223:
return oDocNo?.ToString(); //return oDocNo != null ? oDocNo.ToString() : null;
}
</syntaxhighlight>
 
<br />