Difference between revisions of "AR Deposit - Create New or Update with Refund & Forfeit"

From AutoCount Resource Center
Jump to navigation Jump to search
(Created page with "==(Not Complete)== ===Rules in AR Deposit Refund & Forfeit=== # One AR Deposit allows only one Refund # One AR Deposit allows only one Forfeit ===Assemblies version 1.8=== <...")
 
 
(24 intermediate revisions by the same user not shown)
Line 1: Line 1:
==(Not Complete)==
+
==Technical Specification==
 
+
# One AR Deposit allows only one Refund, and one Payment Voucher is created.
===Rules in AR Deposit Refund & Forfeit===
 
# One AR Deposit allows only one Refund
 
 
# One AR Deposit allows only one Forfeit
 
# One AR Deposit allows only one Forfeit
 
+
# Refund created in AR Deposit will auto create GL Cash Book Payment Voucher under GL | Cash Book Entry.
===Assemblies version 1.8===
+
<br />
<pre>
+
==References of AutoCount Accounting version 1.8, 1.9==
BCE.AutoCount.ARAP.dll
+
{{BaseReferenceAC18}}
</pre>
+
'''BCE.AutoCount.ARAP.dll'''
 
+
<br />
 +
==Sample with data model==
 
===Add New or Edit Existing AR Deposit with Deposit Refund and Forfeit===
 
===Add New or Edit Existing AR Deposit with Deposit Refund and Forfeit===
 
<syntaxhighlight lang="csharp">
 
<syntaxhighlight lang="csharp">
public void AddUpdateDepositWithRefundForfeit(ARDepositSource source, BCE.Data.DBSetting dbSetting)
+
public string AddUpdateDepositWithRefundForfeit(ARDepositSource source, BCE.Data.DBSetting dbSetting)
 
{
 
{
 
     BCE.AutoCount.ARAP.ARDeposit.ARDepositCommand cmd = BCE.AutoCount.ARAP.ARDeposit.ARDepositCommand.Create(dbSetting);
 
     BCE.AutoCount.ARAP.ARDeposit.ARDepositCommand cmd = BCE.AutoCount.ARAP.ARDeposit.ARDepositCommand.Create(dbSetting);
     BCE.AutoCount.ARAP.ARDeposit.ARDeposit doc = cmd.Edit(source.DocumentNo);
+
     BCE.AutoCount.ARAP.ARDeposit.ARDeposit doc = null;
 +
    //Only possible to edit a document when document number is provided,
 +
    //and exist in the record
 +
    if (source.DocumentNo != null)
 +
    {
 +
        doc = cmd.Edit(source.DocumentNo);
 +
    }
  
 
     if (doc == null)
 
     if (doc == null)
Line 21: Line 26:
 
         //Add New ARDeposit
 
         //Add New ARDeposit
 
         doc = cmd.AddNew();
 
         doc = cmd.AddNew();
        UpdateARDeposit(doc, source, dbSetting);
 
 
     }
 
     }
 
     else
 
     else
Line 27: Line 31:
 
         //Edit existing ARDeposit
 
         //Edit existing ARDeposit
 
         doc.ClearDetails();
 
         doc.ClearDetails();
         UpdateARDeposit(doc, source, dbSetting);
+
         doc.ClearRefundDetails();
 
     }
 
     }
 +
 +
    return UpdateARDeposit(doc, source, dbSetting);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
====Update AR Deposit with Refund and Forfeit====
 
<syntaxhighlight lang="csharp">
 
<syntaxhighlight lang="csharp">
private void UpdateARDeposit(BCE.AutoCount.ARAP.ARDeposit.ARDeposit doc, ARDepositSource source, BCE.Data.DBSetting dbSetting)
+
/// <summary>
 +
///
 +
/// </summary>
 +
/// <param name="doc"></param>
 +
/// <param name="source"></param>
 +
/// <param name="dbSetting"></param>
 +
/// <returns>DocNo</returns>
 +
private string UpdateARDeposit(BCE.AutoCount.ARAP.ARDeposit.ARDeposit doc, ARDepositSource source, BCE.Data.DBSetting dbSetting)
 
{
 
{
 +
    string retDocNo = null;
 
     if (IsValidDepositMethod(source.DepositMethod, dbSetting))
 
     if (IsValidDepositMethod(source.DepositMethod, dbSetting))
 
     {
 
     {
Line 42: Line 57:
 
     else
 
     else
 
     {
 
     {
         BCE.Application.AppMessage.ShowErrorMessage(string.Format("Invalid Deposit Payment Method of \"{0}\"", source.DepositMethod));
+
         //BCE.Application.AppMessage.ShowErrorMessage(string.Format("Invalid Deposit Payment Method of \"{0}\"", source.DepositMethod));
 
         //log error on Deposit Payment Method error
 
         //log error on Deposit Payment Method error
         return;
+
         return retDocNo;
 
     }
 
     }
  
Line 61: Line 76:
 
     doc.ProjNo = source.Project;
 
     doc.ProjNo = source.Project;
 
     doc.DeptNo = source.Department;
 
     doc.DeptNo = source.Department;
 +
    //Deposit Payment Detail
 +
    source.PaymentDetail.ForEach(s => AddARDepositDetail(s, doc.AddDetail));
  
     source.Detail.ForEach(s => AddARDepositDetail(s, doc.AddDetail));
+
     //Refund
 +
    if (source.Refund == null)
 +
    {
 +
        //No refund
 +
        doc.HasRefund = false;
 +
    }
 +
    else
 +
    {
 +
        doc.HasRefund = true;
 +
        if (doc.RefundDocNo != null && doc.RefundDocNo == source.Refund.DocumentNo)
 +
        {
 +
            //Do nothing when no changed in Refund Document number
 +
            //and doc.RefundDocNo is not null
 +
        }
 +
        else if (source.Refund.DocumentNo == null && doc.RefundDocNo.Length == 0)
 +
        {
 +
            //Reference to version 1.8.28.184, the RefundDocNo is empty string, instead of "<<New>>".
 +
            //To ensure that RefundDocNo is running number, set it to "<<New>>"
 +
            doc.RefundDocNo = "<<New>>";
 +
        }
 +
        else
 +
        {
 +
            //If source.Refund.DocumentNo is not null, assign source to RefundDocNo;
 +
            //Otherwise, use the existing RefundDocNo.
 +
            doc.RefundDocNo = source.Refund.DocumentNo ?? doc.RefundDocNo;
 +
        }
 +
 
 +
        doc.RefundName = source.Refund.Description;
 +
        doc.RefundDate = source.Refund.RefundDate;
 +
        //Deposit Refund Payment Detail
 +
        source.Refund.PaymentDetail.ForEach(s => AddARRefundDetail(s, doc.AddRefundDetail));
 +
    }
 +
 
 +
    //Forfeit
 +
    if (source.Forfeit == null)
 +
    {
 +
        //No forfeit
 +
        doc.HasForfeited = false;
 +
        doc.MasterRow["ForfeitedAmt"] = 0.00M;
 +
        doc.ForfeitedDate = null;
 +
    }
 +
    else
 +
    {
 +
        doc.HasForfeited = true;
 +
        doc.ForFeitedAccNo = source.Forfeit.ForfeitAccNo ?? doc.ForFeitedAccNo;
 +
        //Reference to version 1.8.28.184, doc.ForfeitedAmt is read only field,
 +
        //but it is a required amount when forfeited is true.
 +
        //Therefore, in this case we have to direct update the DataRow
 +
        doc.MasterRow["ForfeitedAmt"] = source.Forfeit.ForfeitAmount;
 +
        doc.ForfeitedDate = source.Forfeit.ForfeitDate;
 +
    }
  
 
     try
 
     try
 
     {
 
     {
 
         doc.Save();
 
         doc.Save();
         BCE.Application.AppMessage.ShowMessage(string.Format("{0} is Created.", doc.DocNo));
+
         retDocNo = doc.DocNo;
 +
        //BCE.Application.AppMessage.ShowMessage(string.Format("{0} is Created/Updated.", doc.DocNo));
 
         //Log Success created
 
         //Log Success created
 
     }
 
     }
 
     catch (BCE.Application.AppException ex)
 
     catch (BCE.Application.AppException ex)
 
     {
 
     {
         BCE.Application.AppMessage.ShowErrorMessage(ex.Message);
+
         //BCE.Application.AppMessage.ShowErrorMessage(ex.Message);
 
         //Log Error saving
 
         //Log Error saving
 
     }
 
     }
 +
 +
    //Return null if document is not created or updated.
 +
    //If successfully saved, Document number is returned.
 +
    return retDocNo;
 
}
 
}
 +
</syntaxhighlight>
  
 +
====Add Deposit Payment Detail====
 +
<syntaxhighlight lang="csharp">
 
private void AddARDepositDetail(ARDepositDetailSource source, Func<BCE.AutoCount.ARAP.ARDeposit.ARDepositDetail> addDepositDetail)
 
private void AddARDepositDetail(ARDepositDetailSource source, Func<BCE.AutoCount.ARAP.ARDeposit.ARDepositDetail> addDepositDetail)
 
{
 
{
Line 100: Line 175:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
====Add Deposit Refund Payment Detail====
 +
<syntaxhighlight lang="csharp">
 +
private void AddARRefundDetail(ARDepositDetailSource source, Func<BCE.AutoCount.ARAP.ARDeposit.ARDepositRefundDetail> addRefundDetail)
 +
{
 +
    BCE.AutoCount.ARAP.ARDeposit.ARDepositRefundDetail dtl = addRefundDetail();
 +
    dtl.PaymentMethod = source.PaymentMethod;
 +
    dtl.ChequeNo = source.ChequeNo;
 +
    dtl.PaymentAmount = source.DepositAmount;
 +
    dtl.BankCharge = source.BankCharge;
 +
    dtl.BankChargeTaxType = source.BankChargeTaxCode;
 +
    dtl.BankChargeTaxRefNo = source.BankChargeBillNoForGst;
 +
    dtl.PaymentBy = source.PaymentBy;
 +
 +
    //Returned Cheque
 +
    if (source.ReturnChequeDate.HasValue)
 +
    {
 +
        dtl.IsReturnedCheque = true;
 +
        dtl.ReturnedChequeDate = source.ReturnChequeDate.Value;
 +
    }
 +
    else
 +
    {
 +
        dtl.IsReturnedCheque = false;
 +
    }
 +
}
 +
</syntaxhighlight>
 +
 +
====Check Deposit Payment Method Validity====
 
<syntaxhighlight lang="csharp">
 
<syntaxhighlight lang="csharp">
 
private bool IsValidDepositMethod(string depositMethod, BCE.Data.DBSetting dbSetting)
 
private bool IsValidDepositMethod(string depositMethod, BCE.Data.DBSetting dbSetting)
Line 112: Line 214:
 
         new BCE.AutoCount.XtraUtils.LookupEditBuilder.DepositPaymentMethodLookupEditBuilder();
 
         new BCE.AutoCount.XtraUtils.LookupEditBuilder.DepositPaymentMethodLookupEditBuilder();
  
     //The return table contains of 3 columns: (1) PaymentMethod, (2) BankAccount, (3) CurrencyCode (in version 1.8.28.184)
+
     //The return table contains of 3 columns: (1) PaymentMethod, (2) BankAccount, (3) CurrencyCode (Reference of version 1.8.28.184)
 
     return depositBuilder.BuildDataTable(dbSetting);
 
     return depositBuilder.BuildDataTable(dbSetting);
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==See Also==
+
===Classes of Deposit source===
* [[AR Debtor]]
+
<syntaxhighlight lang="csharp">
* [[AR Invoice]]
+
public class ARDepositSource
* [[AR Received Payment]]
+
{
* [[AR Debit Note]]
+
    public string DocumentNo { get; set; }
* [[AR Credit Note]]
+
    public DateTime DocumentDate { get; set; } = DateTime.Today.Date;
* [[AR Refund]]
+
    public string Description { get; set; }
* [[AR Deposit]]
+
    public string DepositMethod { get; set; }
* [[AR Deposit (NewUpdate) with Refund & Forfeit]]
+
 
 +
    //Currency Code that is used to pay the deposit
 +
    public string CurrencyCode { get; set; }
 +
    public string CustomerAccount { get; set; }
 +
    public string CustomerName { get; set; }
 +
    public string Attention { get; set; }
 +
    public string Phone { get; set; }
 +
    public string Fax { get; set; }
 +
    public string Project { get; set; }
 +
    public string Department { get; set; }
 +
    //IsSecurityDeposit is to decide whether this deposit is subject to GST
 +
    //true: not subject to GST until this deposit is convert to payment or payment of a sale
 +
    //false: subject to GST and is considered as "Advance Payment"
 +
    public bool IsSecurityDeposit { get; set; }
 +
    public ARDepositRefundSource Refund { get; set; }
 +
    public ARDepositForfeitSource Forfeit { get; set; }
 +
 
 +
    public List<ARDepositDetailSource> PaymentDetail = new List<ARDepositDetailSource>();
 +
}
 +
public class ARDepositDetailSource
 +
{
 +
    public string PaymentMethod { get; set; }
 +
    public string ChequeNo { get; set; }
 +
    public decimal DepositAmount { get; set; }
 +
    public decimal BankCharge { get; set; }
 +
    public string BankChargeTaxCode { get; set; }
 +
    public string BankChargeBillNoForGst { get; set; }
 +
    public string PaymentBy { get; set; }
 +
 
 +
    //If this cheque is returned/bounced cheque
 +
    //Set the returned/bounced date. Otherwise it is null
 +
    public DateTime? ReturnChequeDate { get; set; }
 +
}
 +
</syntaxhighlight>
 +
 
 +
====Deposit Refund Source====
 +
<syntaxhighlight lang="csharp">
 +
public class ARDepositRefundSource
 +
{
 +
    public string DocumentNo { get; set; }
 +
    public string Description { get; set; }
 +
    public DateTime RefundDate { get; set; }
 +
    public List<ARDepositRefundDetailSource> PaymentDetail { get; set; } = new List<ARDepositRefundDetailSource>();
 +
}
 +
 
 +
public class ARDepositRefundDetailSource : ARDepositDetailSource
 +
{ }
 +
</syntaxhighlight>
 +
 
 +
====Deposit Forfeit source====
 +
<syntaxhighlight lang="csharp">
 +
public class ARDepositForfeitSource
 +
{
 +
    public string ForfeitAccNo { get; set; }
 +
    public decimal ForfeitAmount { get; set; }
 +
    public DateTime ForfeitDate { get; set; }
 +
}
 +
</syntaxhighlight>
 +
 
 +
===Implementation===
 +
<syntaxhighlight lang="csharp" highlight="44,45">
 +
public void MainEntry(BCE.Data.DBSetting dbSetting)
 +
{
 +
    string docNo = "";
 +
    //Example of First Deposit with Refund and with New Document Number
 +
    ARDepositSource newDoc = new ARDepositSource()
 +
    {
 +
        //DEPOSIT RECEIVED must be a Payment Method created for Deposit Account
 +
        DepositMethod = "DEPOSIT RECEIVED",
 +
        Description = "DEPOSIT",
 +
        DocumentDate = new DateTime(2017, 11, 25)
 +
    };
 +
 
 +
    newDoc.PaymentDetail.Add(new ARDepositDetailSource()
 +
    {
 +
        PaymentMethod = "BANK",
 +
        ChequeNo = "CHQ00021",
 +
        PaymentBy = "CHEQUE",
 +
        DepositAmount = 500
 +
    });
 +
 
 +
    newDoc.Refund = new ARDepositRefundSource()
 +
    {
 +
        Description = "Refund of Deposit",
 +
        RefundDate = new DateTime(2017, 11, 26)
 +
    };
 +
 
 +
    newDoc.Refund.PaymentDetail.Add(new ARDepositRefundDetailSource()
 +
    {
 +
        //Return to customer
 +
        PaymentMethod = "BANK",
 +
        ChequeNo = "C00101",
 +
        PaymentBy = "Bank Transfer",
 +
        DepositAmount = 200
 +
    });
 +
 
 +
    docNo = AddUpdateDepositWithRefundForfeit(newDoc, dbSetting);
 +
 
 +
    //Add Forfeit amount to 1st Deposit with Refund
 +
    newDoc = new ARDepositSource()
 +
    {
 +
        //DEPOSIT RECEIVED must be a Payment Method created for Deposit Account
 +
        DepositMethod = "DEPOSIT RECEIVED",
 +
        Description = "DEPOSIT",
 +
        //Assign an existing document number to "DocumentNo" will edit & update this deposit.
 +
        DocumentNo = docNo,
 +
        DocumentDate = new DateTime(2017, 11, 25)
 +
    };
 +
 
 +
    newDoc.PaymentDetail.Add(new ARDepositDetailSource()
 +
    {
 +
        PaymentMethod = "BANK",
 +
        ChequeNo = "CHQ00021",
 +
        PaymentBy = "CHEQUE",
 +
        DepositAmount = 500
 +
    });
 +
 
 +
    newDoc.Refund = new ARDepositRefundSource()
 +
    {
 +
        Description = "Refund of Deposit",
 +
        RefundDate = new DateTime(2017, 11, 26)
 +
    };
  
 +
    newDoc.Refund.PaymentDetail.Add(new ARDepositRefundDetailSource()
 +
    {
 +
        //Return to customer
 +
        PaymentMethod = "BANK",
 +
        ChequeNo = "C00101",
 +
        PaymentBy = "Bank Transfer",
 +
        DepositAmount = 250
 +
    });
 +
    //Forfeit
 +
    newDoc.Forfeit = new ARDepositForfeitSource()
 +
    {
 +
        //Forfeit AccNo can be maintained in Tools | Option
 +
        //G/L | Default Accounts
 +
        //If Default Account is maintained, ForfeitAccNo can be null
 +
        ForfeitAccNo = "550-0000",
 +
        ForfeitAmount = 100,
 +
        ForfeitDate = new DateTime(2017, 12, 2)
 +
    };
 +
 +
    AddUpdateDepositWithRefundForfeit(newDoc, dbSetting);
 +
}
 +
</syntaxhighlight>
 +
<br/>
 +
{{SeeAlsoAPIAccount}}
 
[[Category:Programmer]]
 
[[Category:Programmer]]
 
[[Category:API]]
 
[[Category:API]]
 
[[Category:Integrate]]
 
[[Category:Integrate]]
 
[[Category:Plug-In]]
 
[[Category:Plug-In]]
 +
{{NavigateDeveloper}}

Latest revision as of 04:13, 14 June 2018

Technical Specification

  1. One AR Deposit allows only one Refund, and one Payment Voucher is created.
  2. One AR Deposit allows only one Forfeit
  3. Refund created in AR Deposit will auto create GL Cash Book Payment Voucher under GL | Cash Book Entry.


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


Sample with data model

Add New or Edit Existing AR Deposit with Deposit Refund and Forfeit

public string AddUpdateDepositWithRefundForfeit(ARDepositSource source, BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.ARAP.ARDeposit.ARDepositCommand cmd = BCE.AutoCount.ARAP.ARDeposit.ARDepositCommand.Create(dbSetting);
    BCE.AutoCount.ARAP.ARDeposit.ARDeposit doc = null;
    //Only possible to edit a document when document number is provided,
    //and exist in the record
    if (source.DocumentNo != null)
    {
        doc = cmd.Edit(source.DocumentNo);
    }

    if (doc == null)
    {
        //Add New ARDeposit
        doc = cmd.AddNew();
    }
    else
    {
        //Edit existing ARDeposit
        doc.ClearDetails();
        doc.ClearRefundDetails();
    }

    return UpdateARDeposit(doc, source, dbSetting);
}

Update AR Deposit with Refund and Forfeit

/// <summary>
/// 
/// </summary>
/// <param name="doc"></param>
/// <param name="source"></param>
/// <param name="dbSetting"></param>
/// <returns>DocNo</returns>
private string UpdateARDeposit(BCE.AutoCount.ARAP.ARDeposit.ARDeposit doc, ARDepositSource source, BCE.Data.DBSetting dbSetting)
{
    string retDocNo = null;
    if (IsValidDepositMethod(source.DepositMethod, dbSetting))
    {
        if (doc.DepositPaymentMethod != source.DepositMethod)
            doc.DepositPaymentMethod = source.DepositMethod;
    }
    else
    {
        //BCE.Application.AppMessage.ShowErrorMessage(string.Format("Invalid Deposit Payment Method of \"{0}\"", source.DepositMethod));
        //log error on Deposit Payment Method error
        return retDocNo;
    }

    if (doc.DocNo != source.DocumentNo)
        doc.DocNo = source.DocumentNo ?? doc.DocNo;
    if (doc.DocDate != source.DocumentDate)
        doc.DocDate = source.DocumentDate;

    doc.Description = source.Description ?? doc.Description;
    doc.CurrencyCode = source.CurrencyCode ?? doc.CurrencyCode;
    doc.DebtorCode = source.CustomerAccount;
    doc.DebtorName = source.CustomerName;
    doc.Attention = source.Attention;
    doc.Phone1 = source.Phone;
    doc.Fax1 = source.Fax;
    doc.ProjNo = source.Project;
    doc.DeptNo = source.Department;
    //Deposit Payment Detail
    source.PaymentDetail.ForEach(s => AddARDepositDetail(s, doc.AddDetail));

    //Refund
    if (source.Refund == null)
    {
        //No refund
        doc.HasRefund = false;
    }
    else
    {
        doc.HasRefund = true;
        if (doc.RefundDocNo != null && doc.RefundDocNo == source.Refund.DocumentNo)
        {
            //Do nothing when no changed in Refund Document number
            //and doc.RefundDocNo is not null
        }
        else if (source.Refund.DocumentNo == null && doc.RefundDocNo.Length == 0)
        {
            //Reference to version 1.8.28.184, the RefundDocNo is empty string, instead of "<<New>>".
            //To ensure that RefundDocNo is running number, set it to "<<New>>"
            doc.RefundDocNo = "<<New>>";
        }
        else
        {
            //If source.Refund.DocumentNo is not null, assign source to RefundDocNo;
            //Otherwise, use the existing RefundDocNo.
            doc.RefundDocNo = source.Refund.DocumentNo ?? doc.RefundDocNo;
        }

        doc.RefundName = source.Refund.Description;
        doc.RefundDate = source.Refund.RefundDate;
        //Deposit Refund Payment Detail
        source.Refund.PaymentDetail.ForEach(s => AddARRefundDetail(s, doc.AddRefundDetail));
    }

    //Forfeit
    if (source.Forfeit == null)
    {
        //No forfeit
        doc.HasForfeited = false;
        doc.MasterRow["ForfeitedAmt"] = 0.00M;
        doc.ForfeitedDate = null;
    }
    else
    {
        doc.HasForfeited = true;
        doc.ForFeitedAccNo = source.Forfeit.ForfeitAccNo ?? doc.ForFeitedAccNo;
        //Reference to version 1.8.28.184, doc.ForfeitedAmt is read only field,
        //but it is a required amount when forfeited is true.
        //Therefore, in this case we have to direct update the DataRow
        doc.MasterRow["ForfeitedAmt"] = source.Forfeit.ForfeitAmount;
        doc.ForfeitedDate = source.Forfeit.ForfeitDate;
    }

    try
    {
        doc.Save();
        retDocNo = doc.DocNo;
        //BCE.Application.AppMessage.ShowMessage(string.Format("{0} is Created/Updated.", doc.DocNo));
        //Log Success created
    }
    catch (BCE.Application.AppException ex)
    {
        //BCE.Application.AppMessage.ShowErrorMessage(ex.Message);
        //Log Error saving
    }

    //Return null if document is not created or updated.
    //If successfully saved, Document number is returned.
    return retDocNo;
}

Add Deposit Payment Detail

private void AddARDepositDetail(ARDepositDetailSource source, Func<BCE.AutoCount.ARAP.ARDeposit.ARDepositDetail> addDepositDetail)
{
    BCE.AutoCount.ARAP.ARDeposit.ARDepositDetail dtl = addDepositDetail();
    dtl.PaymentMethod = source.PaymentMethod;
    dtl.ChequeNo = source.ChequeNo;
    dtl.PaymentAmt = source.DepositAmount;
    dtl.BankCharge = source.BankCharge;
    dtl.BankChargeTaxType = source.BankChargeTaxCode;
    dtl.BankChargeTaxRefNo = source.BankChargeBillNoForGst;
    dtl.PaymentBy = source.PaymentBy;

    //Returned Cheque
    if (source.ReturnChequeDate.HasValue)
    {
        dtl.IsRCHQ = true;
        dtl.RCHQDate = source.ReturnChequeDate.Value;
    }
    else
    {
        dtl.IsRCHQ = false;
    }
}

Add Deposit Refund Payment Detail

private void AddARRefundDetail(ARDepositDetailSource source, Func<BCE.AutoCount.ARAP.ARDeposit.ARDepositRefundDetail> addRefundDetail)
{
    BCE.AutoCount.ARAP.ARDeposit.ARDepositRefundDetail dtl = addRefundDetail();
    dtl.PaymentMethod = source.PaymentMethod;
    dtl.ChequeNo = source.ChequeNo;
    dtl.PaymentAmount = source.DepositAmount;
    dtl.BankCharge = source.BankCharge;
    dtl.BankChargeTaxType = source.BankChargeTaxCode;
    dtl.BankChargeTaxRefNo = source.BankChargeBillNoForGst;
    dtl.PaymentBy = source.PaymentBy;

    //Returned Cheque
    if (source.ReturnChequeDate.HasValue)
    {
        dtl.IsReturnedCheque = true;
        dtl.ReturnedChequeDate = source.ReturnChequeDate.Value;
    }
    else
    {
        dtl.IsReturnedCheque = false;
    }
}

Check Deposit Payment Method Validity

private bool IsValidDepositMethod(string depositMethod, BCE.Data.DBSetting dbSetting)
{
    return GetDepositPaymentMethod(dbSetting).AsEnumerable()
        .Count(r => r.Field<string>("PaymentMethod") == depositMethod) > 0;
}

private DataTable GetDepositPaymentMethod(BCE.Data.DBSetting dbSetting)
{
    BCE.AutoCount.XtraUtils.LookupEditBuilder.DepositPaymentMethodLookupEditBuilder depositBuilder =
        new BCE.AutoCount.XtraUtils.LookupEditBuilder.DepositPaymentMethodLookupEditBuilder();

    //The return table contains of 3 columns: (1) PaymentMethod, (2) BankAccount, (3) CurrencyCode (Reference of version 1.8.28.184)
    return depositBuilder.BuildDataTable(dbSetting);
}

Classes of Deposit source

public class ARDepositSource
{
    public string DocumentNo { get; set; }
    public DateTime DocumentDate { get; set; } = DateTime.Today.Date;
    public string Description { get; set; }
    public string DepositMethod { get; set; }

    //Currency Code that is used to pay the deposit
    public string CurrencyCode { get; set; }
    public string CustomerAccount { get; set; }
    public string CustomerName { get; set; }
    public string Attention { get; set; }
    public string Phone { get; set; }
    public string Fax { get; set; }
    public string Project { get; set; }
    public string Department { get; set; }
    //IsSecurityDeposit is to decide whether this deposit is subject to GST
    //true: not subject to GST until this deposit is convert to payment or payment of a sale
    //false: subject to GST and is considered as "Advance Payment"
    public bool IsSecurityDeposit { get; set; }
    public ARDepositRefundSource Refund { get; set; }
    public ARDepositForfeitSource Forfeit { get; set; }

    public List<ARDepositDetailSource> PaymentDetail = new List<ARDepositDetailSource>();
}
public class ARDepositDetailSource
{
    public string PaymentMethod { get; set; }
    public string ChequeNo { get; set; }
    public decimal DepositAmount { get; set; }
    public decimal BankCharge { get; set; }
    public string BankChargeTaxCode { get; set; }
    public string BankChargeBillNoForGst { get; set; }
    public string PaymentBy { get; set; }

    //If this cheque is returned/bounced cheque
    //Set the returned/bounced date. Otherwise it is null
    public DateTime? ReturnChequeDate { get; set; }
}

Deposit Refund Source

public class ARDepositRefundSource
{
    public string DocumentNo { get; set; }
    public string Description { get; set; }
    public DateTime RefundDate { get; set; }
    public List<ARDepositRefundDetailSource> PaymentDetail { get; set; } = new List<ARDepositRefundDetailSource>();
}

public class ARDepositRefundDetailSource : ARDepositDetailSource
{ }

Deposit Forfeit source

public class ARDepositForfeitSource
{
    public string ForfeitAccNo { get; set; }
    public decimal ForfeitAmount { get; set; }
    public DateTime ForfeitDate { get; set; }
}

Implementation

public void MainEntry(BCE.Data.DBSetting dbSetting)
{
    string docNo = "";
    //Example of First Deposit with Refund and with New Document Number
    ARDepositSource newDoc = new ARDepositSource()
    {
        //DEPOSIT RECEIVED must be a Payment Method created for Deposit Account
        DepositMethod = "DEPOSIT RECEIVED",
        Description = "DEPOSIT",
        DocumentDate = new DateTime(2017, 11, 25)
    };

    newDoc.PaymentDetail.Add(new ARDepositDetailSource()
    {
        PaymentMethod = "BANK",
        ChequeNo = "CHQ00021",
        PaymentBy = "CHEQUE",
        DepositAmount = 500
    });

    newDoc.Refund = new ARDepositRefundSource()
    {
        Description = "Refund of Deposit",
        RefundDate = new DateTime(2017, 11, 26)
    };

    newDoc.Refund.PaymentDetail.Add(new ARDepositRefundDetailSource()
    {
        //Return to customer
        PaymentMethod = "BANK",
        ChequeNo = "C00101",
        PaymentBy = "Bank Transfer",
        DepositAmount = 200
    });

    docNo = AddUpdateDepositWithRefundForfeit(newDoc, dbSetting);

    //Add Forfeit amount to 1st Deposit with Refund
    newDoc = new ARDepositSource()
    {
        //DEPOSIT RECEIVED must be a Payment Method created for Deposit Account
        DepositMethod = "DEPOSIT RECEIVED",
        Description = "DEPOSIT",
        //Assign an existing document number to "DocumentNo" will edit & update this deposit.
        DocumentNo = docNo,
        DocumentDate = new DateTime(2017, 11, 25)
    };

    newDoc.PaymentDetail.Add(new ARDepositDetailSource()
    {
        PaymentMethod = "BANK",
        ChequeNo = "CHQ00021",
        PaymentBy = "CHEQUE",
        DepositAmount = 500
    });

    newDoc.Refund = new ARDepositRefundSource()
    {
        Description = "Refund of Deposit",
        RefundDate = new DateTime(2017, 11, 26)
    };

    newDoc.Refund.PaymentDetail.Add(new ARDepositRefundDetailSource()
    {
        //Return to customer
        PaymentMethod = "BANK",
        ChequeNo = "C00101",
        PaymentBy = "Bank Transfer",
        DepositAmount = 250
    });
    //Forfeit
    newDoc.Forfeit = new ARDepositForfeitSource()
    {
        //Forfeit AccNo can be maintained in Tools | Option
        //G/L | Default Accounts
        //If Default Account is maintained, ForfeitAccNo can be null
        ForfeitAccNo = "550-0000",
        ForfeitAmount = 100,
        ForfeitDate = new DateTime(2017, 12, 2)
    };

    AddUpdateDepositWithRefundForfeit(newDoc, dbSetting);
}


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 menu

IconAC81.png Go to top
ProgrammerGo.jpg Resources For AutoCount Software Developers