[doubtful debt] Adds new accounts for provision and adds posting for payment
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Mon, 17 Dec 2012 20:31:37 +0100
changeset 19558 8b820b97e17e
parent 19557 776f16fff90f
child 19559 7c61fc6eae44
[doubtful debt] Adds new accounts for provision and adds posting for payment
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
src-db/database/model/tables/C_BP_GROUP_ACCT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
src/org/openbravo/erpCommon/ad_forms/DocDoubtfulDebt.java
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
src/org/openbravo/erpCommon/ad_forms/DocLine_FINPayment.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Thu Dec 13 10:47:35 2012 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Mon Dec 17 20:31:37 2012 +0100
@@ -191,19 +191,26 @@
             List<FIN_PaymentScheduleDetail> outStandingPSDs = getOutstandingPSDs(paymentScheduleDetail);
             BigDecimal difference = paymentScheduleDetail.getAmount().subtract(paymentDetailAmount);
             // Assume doubtful debt is always positive
-            BigDecimal debtAmountDifferenceAbs = paymentScheduleDetail.getDebtAmount().subtract(
-                paymentDetailAmount);
+            BigDecimal doubtFulDebtAmount = BigDecimal.ZERO;
             if (outStandingPSDs.size() == 0) {
+              doubtFulDebtAmount = getDoubtFulDebtAmount(
+                  paymentScheduleDetail.getAmount().add(paymentScheduleDetail.getWriteoffAmount()),
+                  paymentDetailAmount, paymentScheduleDetail.getDebtAmount());
               if (!isWriteoff) {
                 // No outstanding PSD exists so one needs to be created for the difference
                 FIN_PaymentScheduleDetail outstandingPSD = (FIN_PaymentScheduleDetail) DalUtil
                     .copy(paymentScheduleDetail, false);
                 outstandingPSD.setAmount(difference);
+                outstandingPSD.setDebtAmount(paymentScheduleDetail.getDebtAmount().subtract(
+                    doubtFulDebtAmount));
                 outstandingPSD.setPaymentDetails(null);
                 OBDal.getInstance().save(outstandingPSD);
               } else {
+                // If it is write Off then incorporate all doubtful debt
+                doubtFulDebtAmount = paymentScheduleDetail.getDebtAmount();
                 // Set difference as writeoff
                 paymentScheduleDetail.setWriteoffAmount(difference);
+                paymentScheduleDetail.setDebtAmount(doubtFulDebtAmount);
                 OBDal.getInstance().save(paymentScheduleDetail);
                 paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(difference);
                 OBDal.getInstance().save(paymentScheduleDetail.getPaymentDetails());
@@ -212,19 +219,28 @@
               if (!isWriteoff) {
                 // First make sure outstanding amount is not equal zero
                 if (outStandingPSDs.get(0).getAmount().add(difference).signum() == 0) {
+                  doubtFulDebtAmount = paymentScheduleDetail.getDebtAmount().add(
+                      outStandingPSDs.get(0).getDebtAmount());
                   OBDal.getInstance().remove(outStandingPSDs.get(0));
                 } else {
                   // update existing PD with difference
+                  doubtFulDebtAmount = getDoubtFulDebtAmount(
+                      paymentScheduleDetail.getAmount().add(outStandingPSDs.get(0).getAmount()),
+                      paymentDetailAmount,
+                      paymentScheduleDetail.getDebtAmount().add(
+                          outStandingPSDs.get(0).getDebtAmount()));
                   outStandingPSDs.get(0).setAmount(
                       outStandingPSDs.get(0).getAmount().add(difference));
                   outStandingPSDs.get(0).setDebtAmount(
-                      debtAmountDifferenceAbs.signum() >= 0 ? debtAmountDifferenceAbs
-                          : BigDecimal.ZERO);
+                      outStandingPSDs.get(0).getDebtAmount()
+                          .add(paymentScheduleDetail.getDebtAmount().subtract(doubtFulDebtAmount)));
                   OBDal.getInstance().save(outStandingPSDs.get(0));
                 }
               } else {
                 paymentScheduleDetail.setWriteoffAmount(difference.add(outStandingPSDs.get(0)
                     .getAmount()));
+                doubtFulDebtAmount = outStandingPSDs.get(0).getDebtAmount()
+                    .add(paymentScheduleDetail.getDebtAmount());
                 OBDal.getInstance().save(paymentScheduleDetail);
                 paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(
                     difference.add(outStandingPSDs.get(0).getAmount()));
@@ -233,9 +249,7 @@
               }
             }
             paymentScheduleDetail.setAmount(paymentDetailAmount);
-            paymentScheduleDetail
-                .setDebtAmount(debtAmountDifferenceAbs.signum() >= 0 ? paymentDetailAmount
-                    : paymentScheduleDetail.getDebtAmount());
+            paymentScheduleDetail.setDebtAmount(doubtFulDebtAmount);
             OBDal.getInstance().save(paymentScheduleDetail);
             paymentScheduleDetail.getPaymentDetails().setAmount(paymentDetailAmount);
             OBDal.getInstance().save(paymentScheduleDetail.getPaymentDetails());
@@ -243,6 +257,8 @@
             List<FIN_PaymentScheduleDetail> outStandingPSDs = getOutstandingPSDs(paymentScheduleDetail);
             if (outStandingPSDs.size() > 0) {
               paymentScheduleDetail.setWriteoffAmount(outStandingPSDs.get(0).getAmount());
+              paymentScheduleDetail.setDebtAmount(outStandingPSDs.get(0).getDebtAmount()
+                  .add(paymentScheduleDetail.getDebtAmount()));
               OBDal.getInstance().save(paymentScheduleDetail);
               paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(
                   outStandingPSDs.get(0).getAmount());
@@ -260,20 +276,22 @@
           BigDecimal amountDifference = paymentScheduleDetail.getAmount().subtract(
               paymentDetailAmount);
           // Debt Payment
-          BigDecimal debtAmountDifference = paymentScheduleDetail.getDebtAmount().subtract(
-              paymentDetailAmount);
+          BigDecimal doubtfulDebtAmount = getDoubtFulDebtAmount(paymentScheduleDetail.getAmount()
+              .add(paymentScheduleDetail.getWriteoffAmount()), paymentDetailAmount,
+              paymentScheduleDetail.getDebtAmount());
           if (amountDifference.compareTo(BigDecimal.ZERO) != 0) {
             if (!isWriteoff) {
               dao.duplicateScheduleDetail(paymentScheduleDetail, amountDifference,
-                  debtAmountDifference.signum() > 0 ? debtAmountDifference : BigDecimal.ZERO);
+                  paymentScheduleDetail.getDebtAmount().subtract(doubtfulDebtAmount));
               amountDifference = BigDecimal.ZERO;
             } else {
+              if (paymentDetailAmount.signum() == 0) {
+                doubtfulDebtAmount = paymentScheduleDetail.getDebtAmount();
+              }
               paymentScheduleDetail.setWriteoffAmount(amountDifference);
             }
             paymentScheduleDetail.setAmount(paymentDetailAmount);
-            paymentScheduleDetail
-                .setDebtAmount(debtAmountDifference.signum() > 0 ? paymentDetailAmount
-                    : paymentScheduleDetail.getDebtAmount());
+            paymentScheduleDetail.setDebtAmount(doubtfulDebtAmount);
           }
           assignedAmount = assignedAmount.add(paymentDetailAmount);
           dao.getNewPaymentDetail(payment, paymentScheduleDetail, paymentDetailAmount,
@@ -1367,4 +1385,27 @@
       return new ArrayList<FIN_PaymentScheduleDetail>();
     }
   }
+
+  /**
+   * Calculates the resultant doubtful debt amount. Used when editing payment schedule detail amount
+   * to be collected.
+   * 
+   * @param scheduleDetailsTotalAmount
+   *          Payment Schedule Detail amount.
+   * @param paymentAmount
+   *          Amount selected to be collected. Always less or equal than scheduleDetailAmount.
+   * @param doubtfulDebtAmount
+   *          Payment Schedule Detail doubtFulDebt amount.
+   * @return resultant doubtful debt amount. Zero if no doubtful debt amount was present.
+   */
+  private static BigDecimal getDoubtFulDebtAmount(BigDecimal scheduleDetailsTotalAmount,
+      BigDecimal paymentAmount, BigDecimal doubtfulDebtTotalAmount) {
+    BigDecimal calculatedDoubtFulDebtAmount = BigDecimal.ZERO;
+    if (doubtfulDebtTotalAmount.compareTo(BigDecimal.ZERO) == 0) {
+      return calculatedDoubtFulDebtAmount;
+    }
+    calculatedDoubtFulDebtAmount = paymentAmount.subtract(scheduleDetailsTotalAmount
+        .subtract(doubtfulDebtTotalAmount));
+    return calculatedDoubtFulDebtAmount;
+  }
 }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Thu Dec 13 10:47:35 2012 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Mon Dec 17 20:31:37 2012 +0100
@@ -647,6 +647,7 @@
                   OBDal.getInstance().save(outstandingPSD);
                 }
                 paymentScheduleDetail.setWriteoffAmount(BigDecimal.ZERO);
+                paymentScheduleDetail.setDebtAmount(BigDecimal.ZERO);
                 paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(BigDecimal.ZERO);
                 OBDal.getInstance().save(paymentScheduleDetail.getPaymentDetails());
                 OBDal.getInstance().save(paymentScheduleDetail);
--- a/src-db/database/model/tables/C_BP_GROUP_ACCT.xml	Thu Dec 13 10:47:35 2012 +0100
+++ b/src-db/database/model/tables/C_BP_GROUP_ACCT.xml	Mon Dec 17 20:31:37 2012 +0100
@@ -117,12 +117,26 @@
         <default/>
         <onCreateDefault/>
       </column>
+      <column name="BADDEBTEXPENSE_ACCT" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
+      <column name="ALLOWANCEFORDOUBTFUL_ACCT" primaryKey="false" required="false" type="VARCHAR" size="32" autoIncrement="false">
+        <default/>
+        <onCreateDefault/>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="C_BP_GROUP_ACCT_AD_CLIENT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
       <foreign-key foreignTable="AD_ORG" name="C_BP_GROUP_ACCT_AD_ORG">
         <reference local="AD_ORG_ID" foreign="AD_ORG_ID"/>
       </foreign-key>
+      <foreign-key foreignTable="C_VALIDCOMBINATION" name="C_BP_GROUP_ACCT_ALLOWANCE">
+        <reference local="ALLOWANCEFORDOUBTFUL_ACCT" foreign="C_VALIDCOMBINATION_ID"/>
+      </foreign-key>
+      <foreign-key foreignTable="C_VALIDCOMBINATION" name="C_BP_GROUP_ACCT_BADDEBTEXPENSE">
+        <reference local="BADDEBTEXPENSE_ACCT" foreign="C_VALIDCOMBINATION_ID"/>
+      </foreign-key>
       <foreign-key foreignTable="C_ACCTSCHEMA" name="C_BP_GROUP_ACCT_C_ACCTSCHEMA" onDelete="cascade">
         <reference local="C_ACCTSCHEMA_ID" foreign="C_ACCTSCHEMA_ID"/>
       </foreign-key>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Thu Dec 13 10:47:35 2012 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Mon Dec 17 20:31:37 2012 +0100
@@ -220956,6 +220956,40 @@
 <!--05A12278486748828E4DC33428752E72-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--05A12278486748828E4DC33428752E72--></AD_COLUMN>
 
+<!--05C088F54F974D8482C0DFDAE726D0C5--><AD_COLUMN>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_COLUMN_ID><![CDATA[05C088F54F974D8482C0DFDAE726D0C5]]></AD_COLUMN_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <NAME><![CDATA[Bad Debt Expense Account]]></NAME>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <COLUMNNAME><![CDATA[BadDebtExpense_Acct]]></COLUMNNAME>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_TABLE_ID><![CDATA[395]]></AD_TABLE_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_REFERENCE_VALUE_ID><![CDATA[4FA73FBEF8CE4A54926DDD317E385486]]></AD_REFERENCE_VALUE_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <SEQNO><![CDATA[41]]></SEQNO>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_ELEMENT_ID><![CDATA[47582E4FA8A6402F979CE4BBC47F9B71]]></AD_ELEMENT_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <POSITION><![CDATA[30]]></POSITION>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--05C088F54F974D8482C0DFDAE726D0C5-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--05C088F54F974D8482C0DFDAE726D0C5--></AD_COLUMN>
+
 <!--060657E87C824FD29A132A97802331F1--><AD_COLUMN>
 <!--060657E87C824FD29A132A97802331F1-->  <AD_COLUMN_ID><![CDATA[060657E87C824FD29A132A97802331F1]]></AD_COLUMN_ID>
 <!--060657E87C824FD29A132A97802331F1-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -254232,6 +254266,40 @@
 <!--6B7E0E7BB29846E2A1F98C0FA0A6FFEA-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
 <!--6B7E0E7BB29846E2A1F98C0FA0A6FFEA--></AD_COLUMN>
 
+<!--6BBE458716F14497A210D2857A48E904--><AD_COLUMN>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_COLUMN_ID><![CDATA[6BBE458716F14497A210D2857A48E904]]></AD_COLUMN_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6BBE458716F14497A210D2857A48E904-->  <NAME><![CDATA[Allowance For Doubtful Debt Account]]></NAME>
+<!--6BBE458716F14497A210D2857A48E904-->  <COLUMNNAME><![CDATA[AllowanceForDoubtful_Acct]]></COLUMNNAME>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_TABLE_ID><![CDATA[395]]></AD_TABLE_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_REFERENCE_ID><![CDATA[95E2A8B50A254B2AAE6774B8C2F28120]]></AD_REFERENCE_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_REFERENCE_VALUE_ID><![CDATA[4FA73FBEF8CE4A54926DDD317E385486]]></AD_REFERENCE_VALUE_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--6BBE458716F14497A210D2857A48E904-->  <SEQNO><![CDATA[51]]></SEQNO>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_ELEMENT_ID><![CDATA[B31406600223471A8FE5B4C9990CFCFB]]></AD_ELEMENT_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--6BBE458716F14497A210D2857A48E904-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--6BBE458716F14497A210D2857A48E904-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6BBE458716F14497A210D2857A48E904-->  <POSITION><![CDATA[31]]></POSITION>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISAUTOSAVE><![CDATA[Y]]></ISAUTOSAVE>
+<!--6BBE458716F14497A210D2857A48E904-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
+<!--6BBE458716F14497A210D2857A48E904-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
+<!--6BBE458716F14497A210D2857A48E904-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--6BBE458716F14497A210D2857A48E904--></AD_COLUMN>
+
 <!--6BDD5BBDFE613D4BE040007F01013540--><AD_COLUMN>
 <!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_COLUMN_ID><![CDATA[6BDD5BBDFE613D4BE040007F01013540]]></AD_COLUMN_ID>
 <!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Thu Dec 13 10:47:35 2012 +0100
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Dec 17 20:31:37 2012 +0100
@@ -21827,6 +21827,18 @@
 <!--46C995886E534B6BA240599DACD8240B-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--46C995886E534B6BA240599DACD8240B--></AD_ELEMENT>
 
+<!--47582E4FA8A6402F979CE4BBC47F9B71--><AD_ELEMENT>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <AD_ELEMENT_ID><![CDATA[47582E4FA8A6402F979CE4BBC47F9B71]]></AD_ELEMENT_ID>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <COLUMNNAME><![CDATA[BadDebtExpense_Acct]]></COLUMNNAME>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <NAME><![CDATA[Bad Debt Expense Account]]></NAME>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <PRINTNAME><![CDATA[Bad Debt Expense Account]]></PRINTNAME>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--47582E4FA8A6402F979CE4BBC47F9B71-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--47582E4FA8A6402F979CE4BBC47F9B71--></AD_ELEMENT>
+
 <!--4823F0304FFC4CBF84A17244F0431117--><AD_ELEMENT>
 <!--4823F0304FFC4CBF84A17244F0431117-->  <AD_ELEMENT_ID><![CDATA[4823F0304FFC4CBF84A17244F0431117]]></AD_ELEMENT_ID>
 <!--4823F0304FFC4CBF84A17244F0431117-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -28820,6 +28832,18 @@
 <!--B27C7AF72FEFEC33E040007F0100076A-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--B27C7AF72FEFEC33E040007F0100076A--></AD_ELEMENT>
 
+<!--B31406600223471A8FE5B4C9990CFCFB--><AD_ELEMENT>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <AD_ELEMENT_ID><![CDATA[B31406600223471A8FE5B4C9990CFCFB]]></AD_ELEMENT_ID>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <COLUMNNAME><![CDATA[AllowanceForDoubtful_Acct]]></COLUMNNAME>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <NAME><![CDATA[Allowance For Doubtful Debt Account]]></NAME>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <PRINTNAME><![CDATA[Allowance For Doubtful Debt Account]]></PRINTNAME>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--B31406600223471A8FE5B4C9990CFCFB-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
+<!--B31406600223471A8FE5B4C9990CFCFB--></AD_ELEMENT>
+
 <!--B33F04A816A34929B56D918B2636BF2C--><AD_ELEMENT>
 <!--B33F04A816A34929B56D918B2636BF2C-->  <AD_ELEMENT_ID><![CDATA[B33F04A816A34929B56D918B2636BF2C]]></AD_ELEMENT_ID>
 <!--B33F04A816A34929B56D918B2636BF2C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Thu Dec 13 10:47:35 2012 +0100
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Mon Dec 17 20:31:37 2012 +0100
@@ -52216,7 +52216,7 @@
 <!--3926-->  <AD_FIELD_ID><![CDATA[3926]]></AD_FIELD_ID>
 <!--3926-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--3926-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--3926-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
+<!--3926-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--3926-->  <NAME><![CDATA[Realized Loss Acct]]></NAME>
 <!--3926-->  <DESCRIPTION><![CDATA[Realized Loss Account]]></DESCRIPTION>
 <!--3926-->  <HELP><![CDATA[The Realized Loss Account indicates the account to be used when recording losses incurred from currency revaluation that have yet to be realized.]]></HELP>
@@ -184383,6 +184383,33 @@
 <!--2F385E71C756425AAA4DB2EBD741DE01-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--2F385E71C756425AAA4DB2EBD741DE01--></AD_FIELD>
 
+<!--2F4D28954B6B465D9099766757F531C5--><AD_FIELD>
+<!--2F4D28954B6B465D9099766757F531C5-->  <AD_FIELD_ID><![CDATA[2F4D28954B6B465D9099766757F531C5]]></AD_FIELD_ID>
+<!--2F4D28954B6B465D9099766757F531C5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--2F4D28954B6B465D9099766757F531C5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--2F4D28954B6B465D9099766757F531C5-->  <NAME><![CDATA[Allowance For Doubtful Debt Account]]></NAME>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--2F4D28954B6B465D9099766757F531C5-->  <AD_TAB_ID><![CDATA[323]]></AD_TAB_ID>
+<!--2F4D28954B6B465D9099766757F531C5-->  <AD_COLUMN_ID><![CDATA[6BBE458716F14497A210D2857A48E904]]></AD_COLUMN_ID>
+<!--2F4D28954B6B465D9099766757F531C5-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--2F4D28954B6B465D9099766757F531C5-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--2F4D28954B6B465D9099766757F531C5-->  <SEQNO><![CDATA[350]]></SEQNO>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--2F4D28954B6B465D9099766757F531C5-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--2F4D28954B6B465D9099766757F531C5-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--2F4D28954B6B465D9099766757F531C5-->  <GRID_SEQNO><![CDATA[350]]></GRID_SEQNO>
+<!--2F4D28954B6B465D9099766757F531C5-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--2F4D28954B6B465D9099766757F531C5-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--2F4D28954B6B465D9099766757F531C5-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--2F4D28954B6B465D9099766757F531C5-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--2F4D28954B6B465D9099766757F531C5--></AD_FIELD>
+
 <!--2F4D29E92A6940188E48E7144E6698B4--><AD_FIELD>
 <!--2F4D29E92A6940188E48E7144E6698B4-->  <AD_FIELD_ID><![CDATA[2F4D29E92A6940188E48E7144E6698B4]]></AD_FIELD_ID>
 <!--2F4D29E92A6940188E48E7144E6698B4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -185498,6 +185525,33 @@
 <!--345C98C256834D0884968A82B3290FB4-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
 <!--345C98C256834D0884968A82B3290FB4--></AD_FIELD>
 
+<!--347DE80F2FF74C60A0DA3F0571B81A56--><AD_FIELD>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <AD_FIELD_ID><![CDATA[347DE80F2FF74C60A0DA3F0571B81A56]]></AD_FIELD_ID>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <NAME><![CDATA[Bad Debt Expense Account]]></NAME>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <AD_TAB_ID><![CDATA[323]]></AD_TAB_ID>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <AD_COLUMN_ID><![CDATA[05C088F54F974D8482C0DFDAE726D0C5]]></AD_COLUMN_ID>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <IGNOREINWAD><![CDATA[N]]></IGNOREINWAD>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <DISPLAYLENGTH><![CDATA[32]]></DISPLAYLENGTH>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <SEQNO><![CDATA[340]]></SEQNO>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <GRID_SEQNO><![CDATA[340]]></GRID_SEQNO>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <STARTINODDCOLUMN><![CDATA[N]]></STARTINODDCOLUMN>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <STARTNEWLINE><![CDATA[N]]></STARTNEWLINE>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <ISSHOWNINSTATUSBAR><![CDATA[N]]></ISSHOWNINSTATUSBAR>
+<!--347DE80F2FF74C60A0DA3F0571B81A56-->  <EM_OBUIAPP_SHOWSUMMARY><![CDATA[N]]></EM_OBUIAPP_SHOWSUMMARY>
+<!--347DE80F2FF74C60A0DA3F0571B81A56--></AD_FIELD>
+
 <!--348E81878A81453BBD2E73A6D06DB654--><AD_FIELD>
 <!--348E81878A81453BBD2E73A6D06DB654-->  <AD_FIELD_ID><![CDATA[348E81878A81453BBD2E73A6D06DB654]]></AD_FIELD_ID>
 <!--348E81878A81453BBD2E73A6D06DB654-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Thu Dec 13 10:47:35 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Mon Dec 17 20:31:37 2012 +0100
@@ -1782,6 +1782,65 @@
   } // getAccount
 
   /**
+   * It gets Account to be used to provision for the selected Business Partner
+   * 
+   * @param BPartnerId
+   *          : ID of the Business Partner
+   * @param isProvisionExpense
+   *          : Provision Expense Account. If not it applies to Provision Applied account
+   * @param as
+   *          : Accounting Schema
+   * @param conn
+   *          : Connection Provider
+   * @return Account
+   * @throws ServletException
+   */
+  public final Account getAccountBPartnerProvision(String BPartnerId, boolean isProvisionExpense,
+      AcctSchema as, ConnectionProvider conn) throws ServletException {
+
+    String strValidCombination = "";
+    final StringBuilder whereClause = new StringBuilder();
+    BusinessPartner bp = OBDal.getInstance().get(BusinessPartner.class, BPartnerId);
+    whereClause.append(" as cuscata ");
+    whereClause.append(" where cuscata.businessPartnerCategory.id = '"
+        + bp.getBusinessPartnerCategory().getId() + "'");
+    whereClause.append(" and cuscata.accountingSchema.id = '" + as.m_C_AcctSchema_ID + "'");
+
+    final OBQuery<CategoryAccounts> obqParameters = OBDal.getInstance().createQuery(
+        CategoryAccounts.class, whereClause.toString());
+    obqParameters.setFilterOnReadableClients(false);
+    obqParameters.setFilterOnReadableOrganization(false);
+    final List<CategoryAccounts> customerAccounts = obqParameters.list();
+    // TODO: Review Accounts
+    if (customerAccounts != null && customerAccounts.size() > 0
+        && customerAccounts.get(0).getBadDebtExpenseAccount() != null && isProvisionExpense) {
+      strValidCombination = customerAccounts.get(0).getBadDebtExpenseAccount().getId();
+    } else if (customerAccounts != null && customerAccounts.size() > 0
+        && customerAccounts.get(0).getAllowanceForDoubtfulDebtAccount() != null
+        && !isProvisionExpense) {
+      strValidCombination = customerAccounts.get(0).getAllowanceForDoubtfulDebtAccount().getId();
+    }
+    if (strValidCombination.equals("")) {
+      Map<String, String> parameters = new HashMap<String, String>();
+      if (isProvisionExpense) {
+        parameters.put("Account", "@BadDebtExpenseAccount@");
+      } else {
+        parameters.put("Account", "@AllowanceForDoubtfulDebtAccount@");
+      }
+      parameters.put("Entity", bp.getBusinessPartnerCategory().getIdentifier());
+      parameters.put(
+          "AccountingSchema",
+          OBDal
+              .getInstance()
+              .get(org.openbravo.model.financialmgmt.accounting.coa.AcctSchema.class,
+                  as.getC_AcctSchema_ID()).getIdentifier());
+      setMessageResult(conn, STATUS_InvalidAccount, "error", parameters);
+      throw new IllegalStateException();
+    }
+    return new Account(conn, strValidCombination);
+  } // getAccountBPartnerProvision
+
+  /**
    * Get the account for GL Item
    */
   public Account getAccountGLItem(GLItem glItem, AcctSchema as, boolean bIsReceipt,
--- a/src/org/openbravo/erpCommon/ad_forms/DocDoubtfulDebt.java	Thu Dec 13 10:47:35 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocDoubtfulDebt.java	Mon Dec 17 20:31:37 2012 +0100
@@ -106,7 +106,7 @@
     String strClassname = "";
     final StringBuilder whereClause = new StringBuilder();
     final Fact fact = new Fact(this, as, Fact.POST_Actual);
-    final String Fact_Acct_Group_ID = SequenceIdData.getUUID();
+    String Fact_Acct_Group_ID = SequenceIdData.getUUID();
 
     try {
       OBContext.setAdminMode();
@@ -159,13 +159,13 @@
           this.C_Currency_ID, "", bpAmountConverted.toString(), Fact_Acct_Group_ID,
           nextSeqNo(SeqNo), DocumentType, conn);
       // Provision
-      fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, false, true, conn),
+      Fact_Acct_Group_ID = SequenceIdData.getUUID();
+      fact.createLine(null, getAccountBPartnerProvision(C_BPartner_ID, true, as, conn),
           this.C_Currency_ID, bpAmountConverted.toString(), "", Fact_Acct_Group_ID,
           nextSeqNo(SeqNo), DocumentType, conn);
-      fact.createLine(null, getAccountBPartner(C_BPartner_ID, as, true, false, false, conn),
+      fact.createLine(null, getAccountBPartnerProvision(C_BPartner_ID, false, as, conn),
           this.C_Currency_ID, "", bpAmountConverted.toString(), Fact_Acct_Group_ID,
           nextSeqNo(SeqNo), DocumentType, conn);
-
     } finally {
       OBContext.restorePreviousMode();
     }
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Thu Dec 13 10:47:35 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Mon Dec 17 20:31:37 2012 +0100
@@ -116,6 +116,8 @@
             : "");
         FieldProviderFactory.setField(data[i], "Amount", paymentDetails.get(i).getAmount()
             .toString());
+        FieldProviderFactory.setField(data[i], "DoubtFulDebtAmount", paymentDetails.get(i)
+            .getFINPaymentScheduleDetailList().get(0).getDebtAmount().toString());
         FieldProviderFactory.setField(data[i], "WriteOffAmt", paymentDetails.get(i)
             .getWriteoffAmount().toString());
         FieldProviderFactory.setField(data[i], "C_GLItem_ID",
@@ -219,6 +221,7 @@
         docLine.setAmount(data[i].getField("Amount"));
         docLine.setIsPrepayment(data[i].getField("isprepayment"));
         docLine.setWriteOffAmt(data[i].getField("WriteOffAmt"));
+        docLine.setDoubtFulDebtAmount(new BigDecimal(data[i].getField("DoubtFulDebtAmount")));
         docLine.setC_GLItem_ID(data[i].getField("C_GLItem_ID"));
         docLine.setPrepaymentAgainstInvoice("Y".equals(data[i]
             .getField("isPaymentDatePriorToInvoiceDate")) ? true : false);
@@ -315,6 +318,27 @@
             bpAmountConverted = convertAmount(new BigDecimal(bpAmount), !isReceipt, DateAcct,
                 TABLEID_Invoice, invoice.getId(), C_Currency_ID, as.m_C_Currency_ID, line, as,
                 fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn).toString();
+            if (line.getDoubtFulDebtAmount().signum() != 0) {
+              BigDecimal doubtFulDebtAmount = convertAmount(line.getDoubtFulDebtAmount(),
+                  isReceipt, DateAcct, TABLEID_Invoice, invoice.getId(), C_Currency_ID,
+                  as.m_C_Currency_ID, line, as, fact, Fact_Acct_Group_ID, nextSeqNo(SeqNo), conn,
+                  false);
+              fact.createLine(
+                  line,
+                  getAccountBPartner((line.m_C_BPartner_ID == null || line.m_C_BPartner_ID
+                      .equals("")) ? this.C_BPartner_ID : line.m_C_BPartner_ID, as, true, false,
+                      true, conn), strcCurrencyId, "", doubtFulDebtAmount.toString(),
+                  Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, conn);
+              bpAmountConverted = new BigDecimal(bpAmountConverted).subtract(doubtFulDebtAmount)
+                  .toString();
+              String Fact_Acct_Group_ID2 = SequenceIdData.getUUID();
+              fact.createLine(null, getAccountBPartnerProvision(C_BPartner_ID, false, as, conn),
+                  this.C_Currency_ID, doubtFulDebtAmount.toString(), "", Fact_Acct_Group_ID2,
+                  nextSeqNo(SeqNo), DocumentType, conn);
+              fact.createLine(null, getAccountBPartnerProvision(C_BPartner_ID, true, as, conn),
+                  this.C_Currency_ID, "", doubtFulDebtAmount.toString(), Fact_Acct_Group_ID2,
+                  nextSeqNo(SeqNo), DocumentType, conn);
+            }
           }
           fact.createLine(
               line,
--- a/src/org/openbravo/erpCommon/ad_forms/DocLine_FINPayment.java	Thu Dec 13 10:47:35 2012 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocLine_FINPayment.java	Mon Dec 17 20:31:37 2012 +0100
@@ -18,6 +18,8 @@
  */
 package org.openbravo.erpCommon.ad_forms;
 
+import java.math.BigDecimal;
+
 import org.apache.log4j.Logger;
 import org.openbravo.model.common.invoice.Invoice;
 import org.openbravo.model.common.order.Order;
@@ -33,6 +35,7 @@
   String isPrepayment = "";
   boolean isPrepaymentAgainstInvoice = false;
   Invoice invoice = null;
+  BigDecimal doubtFulDebtAmount = BigDecimal.ZERO;
   Order order = null;
 
   public Invoice getInvoice() {
@@ -156,6 +159,14 @@
     Amount = amount;
   }
 
+  public BigDecimal getDoubtFulDebtAmount() {
+    return doubtFulDebtAmount;
+  }
+
+  public void setDoubtFulDebtAmount(BigDecimal doubtFulDebtAmount) {
+    this.doubtFulDebtAmount = doubtFulDebtAmount;
+  }
+
   public DocLine_FINPayment(String DocumentType, String TrxHeader_ID, String TrxLine_ID) {
     super(DocumentType, TrxHeader_ID, TrxLine_ID);
     Line_ID = TrxLine_ID;