AP Deposit API: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
No edit summary
No edit summary
Line 1: Line 1:
==Technical Specification==
==Technical Specification==
#'''Forfeit Account''' can be predefined under Tools | Options > G/L | Default Accounts
#Deposit Account (Deposit Payment Method) is a Payment Method that is maintained in '''G/L | Account Maintenance''' & '''General Maintenance | Payment Method Maintenance'''.
#Deposit Account (Deposit Payment Method) is a Payment Method that is maintained in '''G/L | Account Maintenance''' & '''General Maintenance | Payment Method Maintenance'''.
#:[[AR Deposit#Method_to_check_the_validity_of_.28Deposit.29_Payment_Method|Method to check the validity of Deposit Payment Method]]
#:[[AR Deposit#Method_to_check_the_validity_of_.28Deposit.29_Payment_Method|Method to check the validity of Deposit Payment Method]]
#'''Forfeit Account''' can be predefined under Tools | Options > G/L | Default Accounts


==Assemblies version 1.8, 1.9==
==Assemblies version 1.8, 1.9==
Line 46: Line 46:


====New AP Deposit with Refund====
====New AP Deposit with Refund====
<syntaxhighlight lang="csharp" highlight="19-26">
<syntaxhighlight lang="csharp" highlight="19-27">
public void NewWithRefund(BCE.Data.DBSetting dbSetting)
public void NewWithRefund(BCE.Data.DBSetting dbSetting)
{
{
Line 94: Line 94:
{
{
BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);
BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);
BCE.AutoCount.ARAP.APDeposit.APDeposit doc = cmd.Edit("PV-00002");
BCE.AutoCount.ARAP.APDeposit.APDeposit doc = cmd.Edit("PV-000002");
BCE.AutoCount.ARAP.APDeposit.APDepositDetail dtl = null;
BCE.AutoCount.ARAP.APDeposit.APDepositDetail dtl = null;


if (doc == null)
if (doc == null)
{
{
//log unable to load "PV-00002", or not found
//log unable to load "PV-000002", or not found
return;
return;
}
}
Line 105: Line 105:
doc.ClearRefundDetails();
doc.ClearRefundDetails();
doc.ClearDetails();
doc.ClearDetails();

doc.DepositPaymentMethod = "DEPOSIT RECEIVED";
doc.DocDate = new DateTime(2018, 6, 25);
doc.CreditorCode = "400-X001";
doc.Attention = "Jerry";
doc.Description = "Deposit to ordering of books";

//Add a payment that is made for this deposit
dtl = doc.AddDetail();
dtl.PaymentMethod = "BANK";
dtl.PaymentAmt = 200M;

try
{
doc.Save();
//Log success
BCE.Application.AppMessage.ShowMessage($"Updated AP Deposit '{doc.DocNo}'.");
}
catch (BCE.Application.AppException ex)
{
//Log error
BCE.Application.AppMessage.ShowMessage("Error when edit AP Deposit.\n" + ex.Message);
}
}
</syntaxhighlight>
====Edit AP Deposit with Refund====
<syntaxhighlight lang="csharp">
public void EditWithRefund(BCE.Data.DBSetting dbSetting)
{
BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);
BCE.AutoCount.ARAP.APDeposit.APDeposit doc = cmd.Edit("PV-000005");
BCE.AutoCount.ARAP.APDeposit.APDepositDetail dtl = null;
BCE.AutoCount.ARAP.APDeposit.APDepositRefundDetail refundDtl = null;

if (doc == null)
{
//log unable to load "PV-000005", or not found
return;
}

doc.ClearRefundDetails();
doc.ClearDetails();

//Refund
doc.HasRefund = false;
//Assign RefundDocNo if not using running number
//doc.RefundDocNo = "<<New>>";
//doc.RefundDate = new DateTime(2018, 7, 20);
//refundDtl = doc.AddRefundDetail();
//refundDtl.PaymentMethod = "BANK";
//refundDtl.ChequeNo = "MB8294758";
//refundDtl.PaymentAmount = 50M; //refund 50


doc.DepositPaymentMethod = "DEPOSIT RECEIVED";
doc.DepositPaymentMethod = "DEPOSIT RECEIVED";

Revision as of 07:29, 26 June 2018

Technical Specification

  1. Deposit Account (Deposit Payment Method) is a Payment Method that is maintained in G/L | Account Maintenance & General Maintenance | Payment Method Maintenance.
    Method to check the validity of Deposit Payment Method
  2. Forfeit Account can be predefined under Tools | Options > G/L | Default Accounts

Assemblies version 1.8, 1.9

BCE.AutoCount.dll
BCE.AutoCount.CommonAccounting.dll
BCE.AutoCount.MainEntry.dll
BCE.Utils.dll
BCE.Utils.UI.dll
BCE.AutoCount.ARAP.dll

AP Credit Note API Usage

New

public void New(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);
    BCE.AutoCount.ARAP.APDeposit.APDeposit doc = cmd.AddNew();
    BCE.AutoCount.ARAP.APDeposit.APDepositDetail dtl = null;

    //The value of Deposit Payment Method is defined by user,
    //must check the Deposit setting in General Maintenance > Payment Method Maintenance,
    //to get correct value
    doc.DepositPaymentMethod = "DEPOSIT RECEIVED";
    doc.DocDate = new DateTime(2018, 6, 25);
    doc.CreditorCode = "400-X001";
    doc.Attention = "Jerry";
    doc.Description = "Deposit to ordering of books";

    //Add a payment that is made for this deposit
    dtl = doc.AddDetail();
    dtl.PaymentMethod = "BANK";
    dtl.PaymentAmt = 200M;

    try
    {
        doc.Save();
        //Log success
        BCE.Application.AppMessage.ShowMessage($"New AP Deposit '{doc.DocNo}' is created.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log error
        BCE.Application.AppMessage.ShowMessage("Error when create new AP Deposit.\n" + ex.Message);
    }
}

New AP Deposit with Refund

public void NewWithRefund(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);
    BCE.AutoCount.ARAP.APDeposit.APDeposit doc = cmd.AddNew();
    BCE.AutoCount.ARAP.APDeposit.APDepositDetail dtl = null;
    BCE.AutoCount.ARAP.APDeposit.APDepositRefundDetail refundDtl = null;

    doc.DepositPaymentMethod = "DEPOSIT RECEIVED";
    doc.DocDate = new DateTime(2018, 6, 25);
    doc.CreditorCode = "400-X001";
    doc.Attention = "Jerry";
    doc.Description = "Deposit to ordering of books";

    //Add a payment that is made for this deposit
    dtl = doc.AddDetail();
    dtl.PaymentMethod = "BANK";
    dtl.PaymentAmt = 200M;

    //Refund
    doc.HasRefund = true;
    //Assign RefundDocNo if not using running number
    //doc.RefundDocNo = "<<New>>";
    doc.RefundDate = new DateTime(2018, 7, 20);
    refundDtl = doc.AddRefundDetail();
    refundDtl.PaymentMethod = "BANK";
    refundDtl.ChequeNo = "MB8294758";
    refundDtl.PaymentAmount = 50M;  //refund 50

    try
    {
        doc.Save();
        //Log success
        BCE.Application.AppMessage.ShowMessage($"New AP Deposit '{doc.DocNo}' is created.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log error
        BCE.Application.AppMessage.ShowMessage("Error when create new AP Deposit.\n" + ex.Message);
    }
}

Edit

public void Edit(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);
    BCE.AutoCount.ARAP.APDeposit.APDeposit doc = cmd.Edit("PV-000002");
    BCE.AutoCount.ARAP.APDeposit.APDepositDetail dtl = null;

    if (doc == null)
    {
        //log unable to load "PV-000002", or not found
        return;
    }

    doc.ClearRefundDetails();
    doc.ClearDetails();

    doc.DepositPaymentMethod = "DEPOSIT RECEIVED";
    doc.DocDate = new DateTime(2018, 6, 25);
    doc.CreditorCode = "400-X001";
    doc.Attention = "Jerry";
    doc.Description = "Deposit to ordering of books";

    //Add a payment that is made for this deposit
    dtl = doc.AddDetail();
    dtl.PaymentMethod = "BANK";
    dtl.PaymentAmt = 200M;

    try
    {
        doc.Save();
        //Log success
        BCE.Application.AppMessage.ShowMessage($"Updated AP Deposit '{doc.DocNo}'.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log error
        BCE.Application.AppMessage.ShowMessage("Error when edit AP Deposit.\n" + ex.Message);
    }
}

Edit AP Deposit with Refund

public void EditWithRefund(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);
    BCE.AutoCount.ARAP.APDeposit.APDeposit doc = cmd.Edit("PV-000005");
    BCE.AutoCount.ARAP.APDeposit.APDepositDetail dtl = null;
    BCE.AutoCount.ARAP.APDeposit.APDepositRefundDetail refundDtl = null;

    if (doc == null)
    {
        //log unable to load "PV-000005", or not found
        return;
    }

    doc.ClearRefundDetails();
    doc.ClearDetails();

    //Refund
    
    doc.HasRefund = false;
    //Assign RefundDocNo if not using running number
    //doc.RefundDocNo = "<<New>>";
    //doc.RefundDate = new DateTime(2018, 7, 20);
    //refundDtl = doc.AddRefundDetail();
    //refundDtl.PaymentMethod = "BANK";
    //refundDtl.ChequeNo = "MB8294758";
    //refundDtl.PaymentAmount = 50M;  //refund 50

    doc.DepositPaymentMethod = "DEPOSIT RECEIVED";
    doc.DocDate = new DateTime(2018, 6, 25);
    doc.CreditorCode = "400-X001";
    doc.Attention = "Jerry";
    doc.Description = "Deposit to ordering of books";

    //Add a payment that is made for this deposit
    dtl = doc.AddDetail();
    dtl.PaymentMethod = "BANK";
    dtl.PaymentAmt = 200M;

    try
    {
        doc.Save();
        //Log success
        BCE.Application.AppMessage.ShowMessage($"Updated AP Deposit '{doc.DocNo}'.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log error
        BCE.Application.AppMessage.ShowMessage("Error when edit AP Deposit.\n" + ex.Message);
    }
}

Cancel (Void)

public void Cancel(BCE.Data.DBSetting dbSetting)
{
    string userId = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
    string docNo = "PV-00002";
    BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);

    try
    {
        cmd.CancelDocument(docNo, userId);
        //Log success
        BCE.Application.AppMessage.ShowMessage($"AP Deposit '{docNo}' is cancelled.");
    }
    catch (BCE.Application.AppException ex)
    {
        //Log error
        BCE.Application.AppMessage.ShowMessage("Error when cancel AP Deposit.\n" + ex.Message);
    }
}

Delete

public void Delete(BCE.Data.DBSetting dbSetting)
{
    string userId = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
    string docNo = "PV-00002";
    BCE.AutoCount.ARAP.APDeposit.APDepositCommand cmd = BCE.AutoCount.ARAP.APDeposit.APDepositCommand.Create(dbSetting);

    try
    {
        long? docKey = GetAPDepositDocKey(docNo, dbSetting);
        if (docKey.HasValue)
        {
            //AP Deposit only provide parameter of DocKey in Delete Command
            cmd.Delete(docKey.Value);
            //Log success
            BCE.Application.AppMessage.ShowMessage($"AP Deposit '{docNo}' is cancelled.");
        }
    }
    catch (BCE.Application.AppException ex)
    {
        //Log error
        BCE.Application.AppMessage.ShowMessage("Error when cancel AP Deposit.\n" + ex.Message);
    }
}

Convert AP Deposit DocNo to DocKey

public long? GetAPDepositDocKey(string docNo, BCE.Data.DBSetting dbSetting)
{
    object oDocKey = dbSetting.ExecuteScalar("SELECT DocKey FROM APDeposit WHERE DocNo=?", docNo);
    return oDocKey == null ? default(long?) : BCE.Data.Convert.ToInt64(oDocKey);
}


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