AP Deposit API: Difference between revisions

m
no edit summary
(Created page with "==Technical Specification== ==Assemblies version 1.8, 1.9== {{BaseReferenceAC18}} '''BCE.AutoCount.ARAP.dll''' ==AP Credit Note API Usage== ===New=== <syntaxhighlight lang...")
 
mNo edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1:
==Technical Specification==
#Deposit Account (Deposit Payment Method) is mandatory field
 
#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]]
#'''Forfeit Account''' can be predefined under Tools | Options > G/L | Default Accounts
 
==Assemblies version 1.8, 1.9==
Line 9 ⟶ 12:
===New===
<syntaxhighlight lang="csharp">
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 PAYABLE";
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);
}
}
</syntaxhighlight>
 
====New AP Deposit with Refund====
<syntaxhighlight lang="csharp" highlight="19-27">
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 PAYABLE";
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);
}
}
</syntaxhighlight>
 
===Edit===
<syntaxhighlight lang="csharp">
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 PAYABLE";
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" highlight="17-18">
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);
}
}
</syntaxhighlight>
 
===Cancel (Void)===
<syntaxhighlight lang="csharp">
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);
}
}
</syntaxhighlight>
 
===Delete===
*The '''Delete''' method does not provide parameter of '''DocNo'''
<syntaxhighlight lang="csharp">
*:Function '''GetAPDepositDocKey''' is to [[AP_Deposit_API#Convert_AP_Deposit_DocNo_to_DocKey|Convert AP Deposit DocNo to '''DocKey''']]
<syntaxhighlight lang="csharp" highlight="9">
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 deleted.");
}
else
{
//Log unable to locate docNo
BCE.Application.AppMessage.ShowMessage($"AP Deposit '{docNo}' is not a valid document no.");
}
}
catch (BCE.Application.AppException ex)
{
//Log error
BCE.Application.AppMessage.ShowMessage("Error when deleting AP Deposit.\n" + ex.Message);
}
}
</syntaxhighlight>
 
==Convert AP Deposit DocNo to '''DocKey'''==
<syntaxhighlight lang="csharp">
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);
}
</syntaxhighlight>