[APRM] Update Payment Plan: take amounts from payment schedule detail
authorMikel Irurita <mikel.irurita@openbravo.com>
Tue, 10 May 2011 10:01:51 +0200
changeset 12073 d5af22c77778
parent 12072 5d663c7f5bd6
child 12074 af85d0df177c
[APRM] Update Payment Plan: take amounts from payment schedule detail
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java	Tue May 10 05:59:34 2011 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java	Tue May 10 10:01:51 2011 +0200
@@ -182,16 +182,16 @@
               .getBusinessPartner();
           BigDecimal creditUsed = bPartner.getCreditUsed();
           BigDecimal amountWithSign = psd.getInvoicePaymentSchedule().getInvoice()
-              .isSalesTransaction() ? pDetail.getAmount() : pDetail.getAmount().negate();
+              .isSalesTransaction() ? psd.getAmount() : psd.getAmount().negate();
           creditUsed = creditUsed.subtract(amountWithSign);
           bPartner.setCreditUsed(creditUsed);
           OBDal.getInstance().save(bPartner);
-          FIN_AddPayment.updatePaymentScheduleAmounts(psd.getInvoicePaymentSchedule(), pDetail
-              .getAmount(), pDetail.getWriteoffAmount());
+          FIN_AddPayment.updatePaymentScheduleAmounts(psd.getInvoicePaymentSchedule(), psd
+              .getAmount(), psd.getWriteoffAmount());
         }
         if (psd.getOrderPaymentSchedule() != null) {
-          FIN_AddPayment.updatePaymentScheduleAmounts(psd.getOrderPaymentSchedule(), pDetail
-              .getAmount(), pDetail.getWriteoffAmount());
+          FIN_AddPayment.updatePaymentScheduleAmounts(psd.getOrderPaymentSchedule(), psd
+              .getAmount(), psd.getWriteoffAmount());
         }
       }
     }
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Tue May 10 05:59:34 2011 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java	Tue May 10 10:01:51 2011 +0200
@@ -243,8 +243,8 @@
             for (FIN_PaymentDetail paymentDetail : payment.getFINPaymentDetailList()) {
               for (FIN_PaymentScheduleDetail paymentScheduleDetail : paymentDetail
                   .getFINPaymentScheduleDetailList()) {
-                BigDecimal amount = paymentDetail.getAmount()
-                    .add(paymentDetail.getWriteoffAmount());
+                BigDecimal amount = paymentScheduleDetail.getAmount().add(
+                    paymentScheduleDetail.getWriteoffAmount());
                 if (paymentScheduleDetail.getInvoicePaymentSchedule() != null) {
                   // BP SO_CreditUsed
                   businessPartner = paymentScheduleDetail.getInvoicePaymentSchedule().getInvoice()
@@ -256,13 +256,13 @@
                     increaseCustomerCredit(businessPartner, amount);
                   }
                   FIN_AddPayment.updatePaymentScheduleAmounts(paymentScheduleDetail
-                      .getInvoicePaymentSchedule(), paymentDetail.getAmount(), paymentDetail
-                      .getWriteoffAmount());
+                      .getInvoicePaymentSchedule(), paymentScheduleDetail.getAmount(),
+                      paymentScheduleDetail.getWriteoffAmount());
                 }
                 if (paymentScheduleDetail.getOrderPaymentSchedule() != null) {
                   FIN_AddPayment.updatePaymentScheduleAmounts(paymentScheduleDetail
-                      .getOrderPaymentSchedule(), paymentDetail.getAmount(), paymentDetail
-                      .getWriteoffAmount());
+                      .getOrderPaymentSchedule(), paymentScheduleDetail.getAmount(),
+                      paymentScheduleDetail.getWriteoffAmount());
                 }
                 // when generating credit for a BP SO_CreditUsed is also updated
                 if (paymentScheduleDetail.getInvoicePaymentSchedule() == null