AR Debtor
Technical Specification
- 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
BCE.AutoCount.dll BCE.AutoCount.CommonAccounting.dll BCE.AutoCount.MainEntry.dll BCE.Utils.dll BCE.Utils.UI.dll BCE.AutoCount.ARAP.dll
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
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;
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 = "300-0000";
debtor.AccNo = newDebtorCode;
debtor.CompanyName = customerName;
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("New customer code '{0}' is added.", newDebtorCode));
}
catch (BCE.Application.AppException ex)
{
//Log fail
BCE.Application.AppMessage.ShowMessage(
string.Format("Fail to create customer '{0}'.\n{1}", customerName, ex.Message));
}
}
Edit/Update
- Amend the profile of a customer.
- Changing of customer's AccNo is not allowed
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));
}
}
Inactive
- Customer whom has been set to Inactive will not appear in customer selection of new transaction.
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));
}
}
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.
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));
}
}
Auto Generate New Debtor Code
public string GetNewDebtorCode(BCE.Data.DBSetting dbSetting, string controlAccNo, string companyName)
{
try
{
return BCE.AutoCount.Common.AccountCodeHelper.Create(dbSetting)
.GetNextDebtorCode(controlAccNo, companyName);
}
catch (BCE.AutoCount.Common.InvalidAutoDebtorCodeFormatException ex)
{
//Log error ex.Message;
}
catch (BCE.Data.DataAccessException ex)
{
//Log error ex.Message;
}
//If the catch throw out exception, then return null is not necessary.
return null;
}
Get Local Currency Code
public string AccountBookLocalCurrency(BCE.Data.DBSetting dbSetting)
{
return BCE.Data.DBRegistry.Create(dbSetting).GetString(new BCE.AutoCount.RegistryID.LocalCurrencyCode());
}
Sample with Data Model
Create new AR Debtor
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
}
}
Class of source data
public class DebtorSource
{
public string ControlAccount { get; set; }
public string DebtorCode { get; set; }
public string CompanyName { get; set; }
public string Addr1 { get; set; }
public string Addr2 { get; set; }
public string Addr3 { get; set; }
public string Addr4 { get; set; }
public string Phone { get; set; }
public string Mobile { get; set; }
public string ContactPerson { get; set; }
public string Email { get; set; }
}
Implementation
public void Implementation(BCE.Data.DBSetting dbSetting)
{
DebtorSource newDebtor = new DebtorSource()
{
ControlAccount = "300-0000",
CompanyName = "CALIFORNIA SB",
Addr1 = "1, Jalan SS 1/1,",
Addr2 = "Taman Gembira,",
Addr3 = "Selangor Darah Ehsan,",
Addr4 = "41300 Malaysia.",
Phone = "603-719 1992",
Mobile = "016-221 2222",
ContactPerson = "Ben",
Email = "ben@calimail.com",
};
CreateNewDebtor(dbSetting, newDebtor);
}
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 top
|
Resources For AutoCount Software Developers
|