AP Credit Note API v2: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
No edit summary
No edit summary
Line 19: Line 19:
doc.DocDate = new DateTime(2018, 6, 22);
doc.DocDate = new DateTime(2018, 6, 22);
doc.Description = "Discount";
doc.Description = "Discount";
doc.SupplierCNNo = "";
doc.SupplierCNNo = "DSC-00015";
doc.SupplierInvoiceNo = "";
doc.SupplierInvoiceNo = "BIL-00101";


//Default value: "PURCHASE", "GENERAL"
//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";
doc.JournalType = "PURCHASE";


//Default value: "DISCOUNT", "RETURN"
//Default available values: "DISCOUNT", "RETURN"
//Values are maintained in General Maintenance > C/N Type Maintenance
doc.CNType = "DISCOUNT";
doc.CNType = "DISCOUNT";


//Add a new detail record
dtl = doc.NewDetail();
dtl.AccNo = "520-0000";
dtl.AccNo = "520-0000";
dtl.Description = "Item Sale Discount";
dtl.Description = "Item Sale Discount";
Line 51: Line 56:


===Edit===
===Edit===
<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;

try
{
cmd.SaveAPCN(doc, userSession.LoginUserID);
//Log success
AutoCount.AppMessage.ShowMessage($"New ARCN '{doc.DocNo}' is Created.");
}
catch (AutoCount.AppException ex)
{
//Log fail
AutoCount.AppMessage.ShowMessage("Fail to create new ARCN.\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);
AutoCount.AppMessage.ShowMessage($"ARCN 'docNo' is Created.");
}
catch (AutoCount.AppException ex)
{
//Log fail
AutoCount.AppMessage.ShowMessage($"Fail to cancel ARCN {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 ARCN {docNo}.\n" + ex.Message);
}
}
</syntaxhighlight>


==Get Document No. from Supplier Invoice No.==
==Get Document No. from Supplier Invoice No.==

Revision as of 04:11, 25 June 2018

Technical Specification

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

AP Credit Note API Usage

New

public void New(AutoCount.Authentication.UserSession userSession)
{
    AutoCount.ARAP.APCN.APCNDataAccess cmd = AutoCount.ARAP.APCN.APCNDataAccess.Create(userSession, userSession.DBSetting);
    AutoCount.ARAP.APCN.APCNEntity doc = cmd.NewAPCN();
    AutoCount.ARAP.APCN.APCNDTLEntity dtl = null;

    //doc.DocNo = "<<New>>";
    doc.CreditorCode = "400-X001";
    doc.DocDate = new DateTime(2018, 6, 22);
    doc.Description = "Discount";
    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"
    //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";
    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 ARCN '{doc.DocNo}' is Created.");
    }
    catch (AutoCount.AppException ex)
    {
        //Log fail
        AutoCount.AppMessage.ShowMessage("Fail to create new ARCN.\n" + ex.Message);
    }
}

Edit

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;

    try
    {
        cmd.SaveAPCN(doc, userSession.LoginUserID);
        //Log success
        AutoCount.AppMessage.ShowMessage($"New ARCN '{doc.DocNo}' is Created.");
    }
    catch (AutoCount.AppException ex)
    {
        //Log fail
        AutoCount.AppMessage.ShowMessage("Fail to create new ARCN.\n" + ex.Message);
    }
}

Cancel (Void)

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);
        AutoCount.AppMessage.ShowMessage($"ARCN 'docNo' is Created.");
    }
    catch (AutoCount.AppException ex)
    {
        //Log fail
        AutoCount.AppMessage.ShowMessage($"Fail to cancel ARCN {docNo}.\n" + ex.Message);
    }
}

Delete

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 ARCN {docNo}.\n" + ex.Message);
    }
}

Get Document No. from Supplier Invoice No.

public string GetDocNoOfSupplierInvNo(string supplierInvNo, AutoCount.Authentication.UserSession userSession) {

   object oDocNo = userSession.DBSetting.ExecuteScalar("SELECT DocNo FROM APInvoice WHERE SupplierInvoiceNo=?", supplierInvNo);
   //C# 6.0
   return oDocNo?.ToString();  //return oDocNo != null ? oDocNo.ToString() : null;

}


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