AR Debtor: Difference between revisions

7,666 bytes added ,  4 years ago
no edit summary
mNo edit summary
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 1:
==Technical Specification==
===References of AutoCount Accounting version 1.8===
# Edit and amend '''AccNo''' is not allowed
# Deletion is not allowed, when '''AccNo''' has been referred.
 
==References of AutoCount Accounting version 1.8, 1.9==
{{BaseReferenceAC18}}
'''BCE.AutoCount.ARAP.dll'''
 
===CreateLoad newData ARwith Debtor=API==
===Single Record===
Load one debtor by specifying the DebtorCode (AccNo).
<syntaxhighlight lang="csharp">
public void CreateNewDebtorExampleOfSingleDebtorRecord(string accNo, BCE.Data.DBSetting dbSetting, DebtorSource sourcedbset)
{
BCE.AutoCount.Data.DebtorRecord debtorRec = BCE.AutoCount.Data.CommonRecordUtils.GetDebtor(dbset, accNo);
string newDebtorCode = GetNewDebtorCode(dbSetting, source.ControlAccount, source.CompanyName);
if (debtorRec != null)
{
string companyName = debtorRec.CompanyName;
string addr1 = debtorRec.Address1;
string addr2 = debtorRec.Address2;
string addr3 = debtorRec.Address3;
string addr4 = debtorRec.Address4;
string attention = debtorRec.Attention;
string phone = debtorRec.Phone1;
decimal creditLimit = debtorRec.CreditLimit;
decimal overdueLimit = debtorRec.OverdueLimit;
}
}
</syntaxhighlight>
 
===Multiple Records with Filter===
Load more than one debtor.<br/>
Programmer can specify which columns to load, while defining the filter of which debtor to be loaded.<br/>
This example shows how to load debtor that was modified since a specific date.<br/>
<syntaxhighlight lang="csharp">
public System.Data.DataTable GetModifiedDebtorData(DateTime filterFromDate, BCE.Data.DBSetting dbset)
{
//Create a DataAccess object of Debtor
BCE.AutoCount.ARAP.Debtor.DebtorDataAccess cmd =
BCE.AutoCount.ARAP.Debtor.DebtorDataAccess.Create(dbset);
 
//Create debtor data loading criteria
BCE.AutoCount.SearchFilter.SearchCriteria loadDebtorCriteria =
new BCE.AutoCount.SearchFilter.SearchCriteria();
 
//SearchCriteria requires a SearchFilter
//Create the SearchFilter by Range
BCE.AutoCount.SearchFilter.Filter filterLastModified =
new BCE.AutoCount.SearchFilter.Filter("a", "LastModified");
filterLastModified.Type = BCE.AutoCount.SearchFilter.FilterType.ByRange;
 
//When .To is not define, the filter is from the lastModifiedDate onwards
filterLastModified.From = filterFromDate;
//When a range of date that requires "to date", assign .To to implement from...to.
//filterLastModified.To = new DateTime(2018, 12, 31);
 
//Add the Filter to Criteria
//Can support more than one filter
loadDebtorCriteria.AddFilter(filterLastModified);
 
//fields to be loaded into DataTable
string[] columns = { "AccNo", "CompanyName", "Address1", "Address2",
"DeliverAddr1", "DeliverAddr2", "Attention", "Phone1", "AreaCode", "SalesAgent", "EmailAddress", "CreditLimit", "LastModified"};
 
return cmd.LoadDebtorData(columns, loadDebtorCriteria);
}
</syntaxhighlight>
 
==API Usage==
===New===
*When create new customer, '''ControlAccount''' and '''AccNo''' are required.
*Control Account can be determined at '''GL | Account Maintenance''', where the '''SpecialAccType''' is '''SDC'''
<syntaxhighlight lang="csharp">
public void NewDebtor(BCE.Data.DBSetting dbSetting)
{
string customerName = "CALIFORNIA SB";
 
//300-0000 is the default ControlAccount.
//However it is not a fixed account code, which the code can be changed by user
string newDebtorCode = GetNewDebtorCode(dbSetting, "300-0000", customerName);
if (newDebtorCode == null)
return;
Line 15 ⟶ 86:
BCE.AutoCount.ARAP.Debtor.DebtorEntity debtor = cmd.NewDebtor();
 
debtor.ControlAccount = source.ControlAccount"300-0000";
debtor.AccNo = newDebtorCode;
debtor.CompanyName = source.CompanyNamecustomerName;
debtor.Address1 = source.Addr1"1, Jalan SS 1/1,";
debtor.Address2 = source.Addr2"Taman Gembira,";
debtor.Address3 = source.Addr3"Selangor Darah Ehsan,";
debtor.Address4 = source"41300 Malaysia.Addr4";
debtor.Phone1 = source.Phone"603-719 1992";
debtor.Phone2 = source.Mobile"016-221 2222";
debtor.Attention = source.ContactPerson"Ben";
debtor.EmailAddress = source"ben@calimail.Emailcom";
debtor.CurrencyCode = AccountBookLocalCurrency(dbSetting);
 
Line 31 ⟶ 102:
{
cmd.SaveDebtor(debtor, userId);
BCE.Application.AppMessage.ShowMessage(string.Format("New customer code '{0}' is added.", newDebtorCode));
//Log Success
}
catch (BCE.Application.AppException ex)
{
//Log fail
BCE.Application.AppMessage.ShowMessage(
string.Format("Fail to create customer '{0}'.\n{1}", customerName, ex.Message));
}
}
</syntaxhighlight>
 
===Get Next Debtor CodeEdit/Update===
*Amend the profile of a customer.
*Changing of customer's '''AccNo''' is '''not allowed'''
<syntaxhighlight lang="csharp">
public void EditDebtor(string debtorCode, BCE.Data.DBSetting dbSetting)
{
string userId = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.Debtor.DebtorDataAccess cmd = BCE.AutoCount.ARAP.Debtor.DebtorDataAccess.Create(dbSetting);
BCE.AutoCount.ARAP.Debtor.DebtorEntity debtor = cmd.GetDebtor(debtorCode);
 
//debtor is null, when debtorCode is not found
if (debtor == null)
return;
 
debtor.CompanyName = "CALIFORNIA SB";
debtor.Address1 = "1, Jalan SS 1/1,";
debtor.Address2 = "Taman Gembira,";
debtor.Address3 = "Selangor Darah Ehsan,";
debtor.Address4 = "41300 Malaysia.";
debtor.Phone1 = "603-719 1992";
debtor.Phone2 = "016-221 2222";
debtor.Attention = "Ben";
debtor.EmailAddress = "ben@calimail.com";
debtor.CurrencyCode = AccountBookLocalCurrency(dbSetting);
 
try
{
cmd.SaveDebtor(debtor, userId);
BCE.Application.AppMessage.ShowMessage(string.Format("Customer '{0}' has been updated.", debtor.AccNo));
}
catch (BCE.Application.AppException ex)
{
//Log fail
BCE.Application.AppMessage.ShowMessage(
string.Format("Fail to update customer '{0}'.\n{1}", debtor.CompanyName, ex.Message));
}
}
</syntaxhighlight>
 
====Inactive====
*Customer whom has been set to '''Inactive''' will not appear in customer selection of new transaction.
<syntaxhighlight lang="csharp">
public void SetCustomerToInactive(string debtorCode, BCE.Data.DBSetting dbSetting)
{
string userId = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.Debtor.DebtorDataAccess cmd = BCE.AutoCount.ARAP.Debtor.DebtorDataAccess.Create(dbSetting);
BCE.AutoCount.ARAP.Debtor.DebtorEntity debtor = cmd.GetDebtor(debtorCode);
 
debtor.IsActive = false;
 
try
{
cmd.SaveDebtor(debtor, userId);
BCE.Application.AppMessage.ShowMessage(string.Format("Customer '{0}' is now Inactive.", debtor.AccNo));
}
catch (BCE.Application.AppException ex)
{
//Log fail
BCE.Application.AppMessage.ShowMessage(
string.Format("Fail to update customer '{0}'.\n{1}", debtor.CompanyName, ex.Message));
}
}
</syntaxhighlight>
 
===Delete===
*Customer can only be deleted when the customer is not being referred in transaction and document.
*If the customer is not allowed to be deleted, set the customer status to '''Inactive'''.
<syntaxhighlight lang="csharp">
public void DeleteDebtor(string debtorCode, BCE.Data.DBSetting dbSetting)
{
BCE.AutoCount.ARAP.Debtor.DebtorDataAccess cmd = BCE.AutoCount.ARAP.Debtor.DebtorDataAccess.Create(dbSetting);
 
try
{
cmd.DeleteDebtor(debtorCode);
BCE.Application.AppMessage.ShowMessage(string.Format("Customer code '{0}' is deleted.", debtorCode));
}
catch (BCE.Application.AppException ex)
{
//Log fail
BCE.Application.AppMessage.ShowMessage(
string.Format("Fail to delete customer code '{0}'", debtorCode));
}
}
</syntaxhighlight>
 
<br /><br />
==Auto Generate New Debtor Code==
<syntaxhighlight lang="csharp">
public string GetNewDebtorCode(BCE.Data.DBSetting dbSetting, string controlAccNo, string companyName)
Line 62 ⟶ 222:
}
</syntaxhighlight>
<br />
 
===Get Local Currency Code===
<syntaxhighlight lang="csharp">
public string AccountBookLocalCurrency(BCE.Data.DBSetting dbSetting)
{
return BCE.Data.DBRegistry.Create(dbSetting).GetString(new BCE.AutoCount.RegistryID.LocalCurrencyCode());
}
</syntaxhighlight>
 
<br /><br />
==Sample with Data Model==
===Create new AR Debtor===
<syntaxhighlight lang="csharp">
public void CreateNewDebtor(BCE.Data.DBSetting dbSetting, DebtorSource source)
{
string newDebtorCode = GetNewDebtorCode(dbSetting, source.ControlAccount, source.CompanyName);
if (newDebtorCode == null)
return;
 
string userId = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
BCE.AutoCount.ARAP.Debtor.DebtorDataAccess cmd = BCE.AutoCount.ARAP.Debtor.DebtorDataAccess.Create(dbSetting);
BCE.AutoCount.ARAP.Debtor.DebtorEntity debtor = cmd.NewDebtor();
 
debtor.ControlAccount = source.ControlAccount;
debtor.AccNo = newDebtorCode;
debtor.CompanyName = source.CompanyName;
debtor.Address1 = source.Addr1;
debtor.Address2 = source.Addr2;
debtor.Address3 = source.Addr3;
debtor.Address4 = source.Addr4;
debtor.Phone1 = source.Phone;
debtor.Phone2 = source.Mobile;
debtor.Attention = source.ContactPerson;
debtor.EmailAddress = source.Email;
debtor.CurrencyCode = AccountBookLocalCurrency(dbSetting);
 
try
{
cmd.SaveDebtor(debtor, userId);
//Log Success
}
catch (BCE.Application.AppException ex)
{
//Log fail
}
}
</syntaxhighlight>
Line 76 ⟶ 275:
{
public string ControlAccount { get; set; }
public string DebtorCode { get; set; }
public string CompanyName { get; set; }
public string Addr1 { get; set; }
Line 90 ⟶ 290:
===Implementation===
<syntaxhighlight lang="csharp">
public MainEntryvoid Implementation(BCE.Data.DBSetting dbSetting)
{
DebtorSource newDebtor = new DebtorSource()
Line 110 ⟶ 310:
</syntaxhighlight>
 
{{SeeAlsoAPIAccount}}
==See Also==
* [[AR Debtor]]
* [[AR Invoice]]
* [[AR Received Payment]]
* [[AR Debit Note]]
* [[AR Credit Note]]
* [[AR Refund]]
* [[AR Deposit]]
* [[AR Deposit - Create New or Update with Refund & Forfeit]]
 
[[Category:Programmer]]
[[Category:API]]