Programmer AP Creditor

Revision as of 02:40, 28 May 2018 by DanielY (talk | contribs) (Created page with "===References of AutoCount Accounting version 1.8=== {{BaseReferenceAC18}} '''BCE.AutoCount.ARAP.dll''' ===Create new AP Creditor=== <syntaxhighlight lang="csharp"> public v...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

Create new AP Creditor

public void CreateNewCreditor(BCE.Data.DBSetting dbSetting, CreditorSource source)
{
    string newCreditorCode = GetNewCreditorCode(dbSetting, source.ControlAccount, source.CompanyName);
    if (newCreditorCode == null)
        return;

    string userId = BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).LoginUserID;
    BCE.AutoCount.ARAP.Creditor.CreditorDataAccess cmd = BCE.AutoCount.ARAP.Creditor.CreditorDataAccess.Create(dbSetting);
    BCE.AutoCount.ARAP.Creditor.CreditorEntity creditor = cmd.NewCreditor();

    creditor.ControlAccount = source.ControlAccount;
    creditor.AccNo = newCreditorCode;
    creditor.CompanyName = source.CompanyName;
    creditor.Address1 = source.Addr1;
    creditor.Address2 = source.Addr2;
    creditor.Address3 = source.Addr3;
    creditor.Address4 = source.Addr4;
    creditor.Phone1 = source.Phone;
    creditor.Phone2 = source.Mobile;
    creditor.Attention = source.ContactPerson;
    creditor.EmailAddress = source.Email;
    creditor.CurrencyCode = AccountBookLocalCurrency(dbSetting);

    try
    {
        cmd.SaveCreditor(creditor, userId);
        //Log Success
    }
    catch (BCE.Application.AppException ex)
    {
        //Log fail
    }
}

Get New Creditor Code

public string GetNewCreditorCode(BCE.Data.DBSetting dbSetting, string controlAccNo, string companyName)
{
    try
    {
        return BCE.AutoCount.Common.AccountCodeHelper.Create(dbSetting)
            .GetNextCreditorCode(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());
}

Class of source data

public class CreditorSource
{
    public string ControlAccount { get; set; }
    public string CreditorCode { 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 TesterMain(BCE.Data.DBSetting dbSetting)
{
    CreditorSource newCreditor = new CreditorSource()
    {
        ControlAccount = "400-0000",
        //CreditorCode = "410C001",     //Ignore CreditorCode, if let system auto assign
        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",
    };

    CreateNewCreditor(dbSetting, newCreditor);
}

See Also

Go to menu

  Go to top
  Resources For AutoCount Software Developers