[Doubtful Debt] DebtAmount > DoubtfulDebtAmount
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Fri, 11 Jan 2013 11:11:53 +0100
changeset 19566 0192e05b4f00
parent 19565 2ffacd79bc39
child 19567 b361d0040ff3
[Doubtful Debt] DebtAmount > DoubtfulDebtAmount
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_DoubtfulDebtProcess.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java
src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/AddOrderOrInvoice.java	Fri Jan 11 11:11:53 2013 +0100
@@ -321,8 +321,8 @@
               // update existing PD with difference
               outStandingPSDs.get(0).setAmount(
                   outStandingPSDs.get(0).getAmount().add(psd.getAmount()));
-              outStandingPSDs.get(0).setDebtAmount(
-                  outStandingPSDs.get(0).getDebtAmount().add(psd.getDebtAmount()));
+              outStandingPSDs.get(0).setDoubtfulDebtAmount(
+                  outStandingPSDs.get(0).getDoubtfulDebtAmount().add(psd.getDoubtfulDebtAmount()));
               OBDal.getInstance().save(outStandingPSDs.get(0));
             }
             toRemovePDs.add(pd.getId());
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java	Fri Jan 11 11:11:53 2013 +0100
@@ -955,7 +955,7 @@
     final FIN_PaymentScheduleDetail newPaymentScheduleDetail = (FIN_PaymentScheduleDetail) DalUtil
         .copy(paymentScheduleDetail);
     newPaymentScheduleDetail.setAmount(writeoffAmount);
-    newPaymentScheduleDetail.setDebtAmount(debtAmount);
+    newPaymentScheduleDetail.setDoubtfulDebtAmount(debtAmount);
     OBDal.getInstance().save(newPaymentScheduleDetail);
     OBDal.getInstance().flush();
   }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java	Fri Jan 11 11:11:53 2013 +0100
@@ -195,22 +195,22 @@
             if (outStandingPSDs.size() == 0) {
               doubtFulDebtAmount = getDoubtFulDebtAmount(
                   paymentScheduleDetail.getAmount().add(paymentScheduleDetail.getWriteoffAmount()),
-                  paymentDetailAmount, paymentScheduleDetail.getDebtAmount());
+                  paymentDetailAmount, paymentScheduleDetail.getDoubtfulDebtAmount());
               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.setDoubtfulDebtAmount(paymentScheduleDetail.getDoubtfulDebtAmount()
+                    .subtract(doubtFulDebtAmount));
                 outstandingPSD.setPaymentDetails(null);
                 OBDal.getInstance().save(outstandingPSD);
               } else {
                 // If it is write Off then incorporate all doubtful debt
-                doubtFulDebtAmount = paymentScheduleDetail.getDebtAmount();
+                doubtFulDebtAmount = paymentScheduleDetail.getDoubtfulDebtAmount();
                 // Set difference as writeoff
                 paymentScheduleDetail.setWriteoffAmount(difference);
-                paymentScheduleDetail.setDebtAmount(doubtFulDebtAmount);
+                paymentScheduleDetail.setDoubtfulDebtAmount(doubtFulDebtAmount);
                 OBDal.getInstance().save(paymentScheduleDetail);
                 paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(difference);
                 OBDal.getInstance().save(paymentScheduleDetail.getPaymentDetails());
@@ -219,28 +219,32 @@
               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());
+                  doubtFulDebtAmount = paymentScheduleDetail.getDoubtfulDebtAmount().add(
+                      outStandingPSDs.get(0).getDoubtfulDebtAmount());
                   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()));
+                      paymentScheduleDetail.getDoubtfulDebtAmount().add(
+                          outStandingPSDs.get(0).getDoubtfulDebtAmount()));
                   outStandingPSDs.get(0).setAmount(
                       outStandingPSDs.get(0).getAmount().add(difference));
-                  outStandingPSDs.get(0).setDebtAmount(
-                      outStandingPSDs.get(0).getDebtAmount()
-                          .add(paymentScheduleDetail.getDebtAmount().subtract(doubtFulDebtAmount)));
+                  outStandingPSDs.get(0).setDoubtfulDebtAmount(
+                      outStandingPSDs
+                          .get(0)
+                          .getDoubtfulDebtAmount()
+                          .add(
+                              paymentScheduleDetail.getDoubtfulDebtAmount().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());
+                doubtFulDebtAmount = outStandingPSDs.get(0).getDoubtfulDebtAmount()
+                    .add(paymentScheduleDetail.getDoubtfulDebtAmount());
                 OBDal.getInstance().save(paymentScheduleDetail);
                 paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(
                     difference.add(outStandingPSDs.get(0).getAmount()));
@@ -249,7 +253,7 @@
               }
             }
             paymentScheduleDetail.setAmount(paymentDetailAmount);
-            paymentScheduleDetail.setDebtAmount(doubtFulDebtAmount);
+            paymentScheduleDetail.setDoubtfulDebtAmount(doubtFulDebtAmount);
             OBDal.getInstance().save(paymentScheduleDetail);
             paymentScheduleDetail.getPaymentDetails().setAmount(paymentDetailAmount);
             OBDal.getInstance().save(paymentScheduleDetail.getPaymentDetails());
@@ -257,8 +261,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()));
+              paymentScheduleDetail.setDoubtfulDebtAmount(outStandingPSDs.get(0)
+                  .getDoubtfulDebtAmount().add(paymentScheduleDetail.getDoubtfulDebtAmount()));
               OBDal.getInstance().save(paymentScheduleDetail);
               paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(
                   outStandingPSDs.get(0).getAmount());
@@ -278,20 +282,20 @@
           // Debt Payment
           BigDecimal doubtfulDebtAmount = getDoubtFulDebtAmount(paymentScheduleDetail.getAmount()
               .add(paymentScheduleDetail.getWriteoffAmount()), paymentDetailAmount,
-              paymentScheduleDetail.getDebtAmount());
+              paymentScheduleDetail.getDoubtfulDebtAmount());
           if (amountDifference.compareTo(BigDecimal.ZERO) != 0) {
             if (!isWriteoff) {
               dao.duplicateScheduleDetail(paymentScheduleDetail, amountDifference,
-                  paymentScheduleDetail.getDebtAmount().subtract(doubtfulDebtAmount));
+                  paymentScheduleDetail.getDoubtfulDebtAmount().subtract(doubtfulDebtAmount));
               amountDifference = BigDecimal.ZERO;
             } else {
               if (paymentDetailAmount.signum() == 0) {
-                doubtfulDebtAmount = paymentScheduleDetail.getDebtAmount();
+                doubtfulDebtAmount = paymentScheduleDetail.getDoubtfulDebtAmount();
               }
               paymentScheduleDetail.setWriteoffAmount(amountDifference);
             }
             paymentScheduleDetail.setAmount(paymentDetailAmount);
-            paymentScheduleDetail.setDebtAmount(doubtfulDebtAmount);
+            paymentScheduleDetail.setDoubtfulDebtAmount(doubtfulDebtAmount);
           }
           assignedAmount = assignedAmount.add(paymentDetailAmount);
           dao.getNewPaymentDetail(payment, paymentScheduleDetail, paymentDetailAmount,
@@ -1026,7 +1030,8 @@
       final List<String> removedPDSIds = new ArrayList<String>();
       for (FIN_PaymentScheduleDetail psdToRemove : psdFilter.list()) {
         psd.setAmount(psd.getAmount().add(psdToRemove.getAmount()));
-        psd.setDebtAmount(psd.getDebtAmount().add(psdToRemove.getDebtAmount()));
+        psd.setDoubtfulDebtAmount(psd.getDoubtfulDebtAmount().add(
+            psdToRemove.getDoubtfulDebtAmount()));
         // TODO: Set 0 as default value for writeoffamt column in FIN_Payment_ScheduleDetail table
         BigDecimal sum1 = (psd.getWriteoffAmount() == null) ? BigDecimal.ZERO : psd
             .getWriteoffAmount();
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_DoubtfulDebtProcess.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_DoubtfulDebtProcess.java	Fri Jan 11 11:11:53 2013 +0100
@@ -128,7 +128,7 @@
       if (psd.getPaymentDetails() == null) {
         // Pending amount should be greater or equals than the doubtful debt amount
         if (psd.getAmount().compareTo(debtAmount) >= 0) {
-          psd.setDebtAmount(psd.getDebtAmount().add(debtAmount));
+          psd.setDoubtfulDebtAmount(psd.getDoubtfulDebtAmount().add(debtAmount));
           OBDal.getInstance().save(psd);
         }
       }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Fri Jan 11 11:11:53 2013 +0100
@@ -641,16 +641,16 @@
                   FIN_PaymentScheduleDetail outstandingPSD = (FIN_PaymentScheduleDetail) DalUtil
                       .copy(paymentScheduleDetail, false);
                   outstandingPSD.setAmount(psdWriteoffAmount);
-                  outstandingDebtAmount = paymentScheduleDetail.getDebtAmount().subtract(
+                  outstandingDebtAmount = paymentScheduleDetail.getDoubtfulDebtAmount().subtract(
                       paymentScheduleDetail.getAmount());
-                  outstandingPSD.setDebtAmount(outstandingDebtAmount);
+                  outstandingPSD.setDoubtfulDebtAmount(outstandingDebtAmount);
                   outstandingPSD.setWriteoffAmount(BigDecimal.ZERO);
                   outstandingPSD.setPaymentDetails(null);
                   OBDal.getInstance().save(outstandingPSD);
                 }
                 paymentScheduleDetail.setWriteoffAmount(BigDecimal.ZERO);
-                paymentScheduleDetail.setDebtAmount(paymentScheduleDetail.getDebtAmount().subtract(
-                    outstandingDebtAmount));
+                paymentScheduleDetail.setDoubtfulDebtAmount(paymentScheduleDetail
+                    .getDoubtfulDebtAmount().subtract(outstandingDebtAmount));
                 paymentScheduleDetail.getPaymentDetails().setWriteoffAmount(BigDecimal.ZERO);
                 OBDal.getInstance().save(paymentScheduleDetail.getPaymentDetails());
                 OBDal.getInstance().save(paymentScheduleDetail);
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java	Fri Jan 11 11:11:53 2013 +0100
@@ -140,7 +140,7 @@
         FieldProviderFactory.setField(data[i], "Amount", paymentDetails.get(i).getAmount()
             .toString());
         FieldProviderFactory.setField(data[i], "DoubtFulDebtAmount", paymentDetails.get(i)
-            .getFINPaymentScheduleDetailList().get(0).getDebtAmount().toString());
+            .getFINPaymentScheduleDetailList().get(0).getDoubtfulDebtAmount().toString());
         FieldProviderFactory.setField(data[i], "isprepayment",
             paymentDetails.get(i).isPrepayment() ? "Y" : "N");
         // Check if payment against invoice is in a previous date than invoice accounting date
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java	Fri Jan 11 11:11:53 2013 +0100
@@ -117,7 +117,7 @@
         FieldProviderFactory.setField(data[i], "Amount", paymentDetails.get(i).getAmount()
             .toString());
         FieldProviderFactory.setField(data[i], "DoubtFulDebtAmount", paymentDetails.get(i)
-            .getFINPaymentScheduleDetailList().get(0).getDebtAmount().toString());
+            .getFINPaymentScheduleDetailList().get(0).getDoubtfulDebtAmount().toString());
         FieldProviderFactory.setField(data[i], "WriteOffAmt", paymentDetails.get(i)
             .getWriteoffAmount().toString());
         FieldProviderFactory.setField(data[i], "C_GLItem_ID",
--- a/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java	Fri Jan 11 10:07:44 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java	Fri Jan 11 11:11:53 2013 +0100
@@ -199,7 +199,7 @@
         FieldProviderFactory.setField(data[i], "Amount", paymentDetails.get(i).getAmount()
             .toString());
         FieldProviderFactory.setField(data[i], "DoubtFulDebtAmount", paymentDetails.get(i)
-            .getFINPaymentScheduleDetailList().get(0).getDebtAmount().toString());
+            .getFINPaymentScheduleDetailList().get(0).getDoubtfulDebtAmount().toString());
         FieldProviderFactory.setField(data[i], "isprepayment",
             paymentDetails.get(i).isPrepayment() ? "Y" : "N");
         // Check if payment against invoice is in a previous date than invoice accounting date