[Doubtful Debt] Removes updating invoice plans when picking them in P&E
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Tue, 15 Jan 2013 18:28:43 +0100
changeset 19569 a2580c51ed45
parent 19568 27ae7d0d932e
child 19570 75194f603f33
[Doubtful Debt] Removes updating invoice plans when picking them in P&E
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/DoubtFulDebtPickEditLines.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/DoubtFulDebtPickEditLines.java	Mon Jan 14 12:55:25 2013 +0100
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/DoubtFulDebtPickEditLines.java	Tue Jan 15 18:28:43 2013 +0100
@@ -42,7 +42,6 @@
 import org.openbravo.model.financialmgmt.payment.DoubtfulDebt;
 import org.openbravo.model.financialmgmt.payment.DoubtfulDebtRun;
 import org.openbravo.model.financialmgmt.payment.FIN_PaymentSchedule;
-import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail;
 import org.openbravo.service.db.CallStoredProcedure;
 import org.openbravo.service.db.DbUtility;
 
@@ -152,16 +151,7 @@
           OBDal.getInstance().save(newDoubtfulDebt);
           OBDal.getInstance().save(doubtfulDebtRun);
         }
-        BigDecimal oldAmount = newDoubtfulDebt.getAmount();
         newDoubtfulDebt.setAmount(amount);
-        // TODO: Review processing of documents (to implement as well reactivate...
-        // Set processed = Yes
-        // newDoubtfulDebt.setProcessed(true);
-        // doubtfulDebtRun.setProcessed(true);
-        // OBDal.getInstance().save(newDoubtfulDebt);
-        // OBDal.getInstance().save(doubtfulDebtRun);
-
-        updateDoubtfulDebtScheduleDetails(paymentSchedule, amount, oldAmount);
       }
 
       cont++;
@@ -178,14 +168,6 @@
     if (idList.size() > 0) {
       for (String id : idList) {
         DoubtfulDebt dd = OBDal.getInstance().get(DoubtfulDebt.class, id);
-        FIN_PaymentSchedule salesInvoicePaymentSchedule = dd.getFINPaymentSchedule();
-        for (FIN_PaymentScheduleDetail psd : salesInvoicePaymentSchedule
-            .getFINPaymentScheduleDetailInvoicePaymentScheduleList()) {
-          if (psd.getPaymentDetails() == null && !psd.isCanceled()) {
-            psd.setDoubtfulDebtAmount(psd.getDoubtfulDebtAmount().subtract(dd.getAmount()));
-            OBDal.getInstance().save(psd);
-          }
-        }
         doubtfulDebtRun.getFINDoubtfulDebtList().remove(dd);
         OBDal.getInstance().remove(dd);
       }
@@ -194,21 +176,6 @@
     }
   }
 
-  private void updateDoubtfulDebtScheduleDetails(FIN_PaymentSchedule salesInvoicePaymentSchedule,
-      BigDecimal debtAmount, BigDecimal oldDebtAmount) {
-    for (FIN_PaymentScheduleDetail psd : salesInvoicePaymentSchedule
-        .getFINPaymentScheduleDetailInvoicePaymentScheduleList()) {
-      if (psd.getPaymentDetails() == null && !psd.isCanceled()) {
-        // Pending amount should be greater or equals than the doubtful debt amount
-        if (psd.getAmount().compareTo(debtAmount) >= 0) {
-          psd.setDoubtfulDebtAmount(psd.getDoubtfulDebtAmount().add(debtAmount)
-              .subtract(oldDebtAmount));
-          OBDal.getInstance().save(psd);
-        }
-      }
-    }
-  }
-
   private DocumentType getDoubtfulDebtDocumentType(Client client, Organization organization) {
     final List<Object> parameters = new ArrayList<Object>();
     parameters.add(client.getId());