AR Debtor: Difference between revisions

From AutoCount Resource Center
Content added Content deleted
mNo edit summary
No edit summary
Line 1: Line 1:
==Rules in AR Debtor==
===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==
{{BaseReferenceAC18}}
{{BaseReferenceAC18}}
'''BCE.AutoCount.ARAP.dll'''
'''BCE.AutoCount.ARAP.dll'''


==API Usage==
===Create new AR Debtor===
===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">
<syntaxhighlight lang="csharp">
public void CreateNewDebtor(BCE.Data.DBSetting dbSetting, DebtorSource source)
public void NewDebtor(BCE.Data.DBSetting dbSetting)
{
{
string customerName = "CALIFORNIA SB";
string newDebtorCode = GetNewDebtorCode(dbSetting, source.ControlAccount, source.CompanyName);

//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)
if (newDebtorCode == null)
return;
return;
Line 15: Line 26:
BCE.AutoCount.ARAP.Debtor.DebtorEntity debtor = cmd.NewDebtor();
BCE.AutoCount.ARAP.Debtor.DebtorEntity debtor = cmd.NewDebtor();


debtor.ControlAccount = source.ControlAccount;
debtor.ControlAccount = "300-0000";
debtor.AccNo = newDebtorCode;
debtor.AccNo = newDebtorCode;
debtor.CompanyName = source.CompanyName;
debtor.CompanyName = customerName;
debtor.Address1 = source.Addr1;
debtor.Address1 = "1, Jalan SS 1/1,";
debtor.Address2 = source.Addr2;
debtor.Address2 = "Taman Gembira,";
debtor.Address3 = source.Addr3;
debtor.Address3 = "Selangor Darah Ehsan,";
debtor.Address4 = source.Addr4;
debtor.Address4 = "41300 Malaysia.";
debtor.Phone1 = source.Phone;
debtor.Phone1 = "603-719 1992";
debtor.Phone2 = source.Mobile;
debtor.Phone2 = "016-221 2222";
debtor.Attention = source.ContactPerson;
debtor.Attention = "Ben";
debtor.EmailAddress = source.Email;
debtor.EmailAddress = "ben@calimail.com";
debtor.CurrencyCode = AccountBookLocalCurrency(dbSetting);
debtor.CurrencyCode = AccountBookLocalCurrency(dbSetting);


Line 31: Line 42:
{
{
cmd.SaveDebtor(debtor, userId);
cmd.SaveDebtor(debtor, userId);
BCE.Application.AppMessage.ShowMessage(string.Format("New customer code '{0}' is added.", newDebtorCode));
//Log Success
}
}
catch (BCE.Application.AppException ex)
catch (BCE.Application.AppException ex)
{
{
//Log fail
//Log fail
BCE.Application.AppMessage.ShowMessage(
string.Format("Fail to create customer '{0}'.\n{1}", customerName, ex.Message));
}
}
}
}
</syntaxhighlight>
</syntaxhighlight>


===Get New Debtor Code===
===Edit/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">
<syntaxhighlight lang="csharp">
public string GetNewDebtorCode(BCE.Data.DBSetting dbSetting, string controlAccNo, string companyName)
public string GetNewDebtorCode(BCE.Data.DBSetting dbSetting, string controlAccNo, string companyName)
Line 62: Line 162:
}
}
</syntaxhighlight>
</syntaxhighlight>
<br />

===Get Local Currency Code===
==Get Local Currency Code==
<syntaxhighlight lang="csharp">
<syntaxhighlight lang="csharp">
public string AccountBookLocalCurrency(BCE.Data.DBSetting dbSetting)
public string AccountBookLocalCurrency(BCE.Data.DBSetting dbSetting)
{
{
return BCE.Data.DBRegistry.Create(dbSetting).GetString(new BCE.AutoCount.RegistryID.LocalCurrencyCode());
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>
</syntaxhighlight>
Line 91: Line 230:
===Implementation===
===Implementation===
<syntaxhighlight lang="csharp">
<syntaxhighlight lang="csharp">
public MainEntry(BCE.Data.DBSetting dbSetting)
public void Implementation(BCE.Data.DBSetting dbSetting)
{
{
DebtorSource newDebtor = new DebtorSource()
DebtorSource newDebtor = new DebtorSource()

Revision as of 03:22, 4 June 2018

Rules in AR Debtor

  1. Edit and amend AccNo is not allowed
  2. Deletion is not allowed, when AccNo has been referred.

References of AutoCount Accounting version 1.8

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);
}

Template:SeeAlsoAccount

Go to menu

Go to top
Resources For AutoCount Software Developers