Fixes issue 41737: Modify payment plan recalculation when deleting line
authorArmaignac <collazoandy4@gmail.com>
Wed, 04 Sep 2019 18:31:06 -0400
changeset 36561 db9908961a58
parent 36560 b3393dd2ea1e
child 36562 b75877805a1a
Fixes issue 41737: Modify payment plan recalculation when deleting line

A wrong outstanding amount was used to check if all payment plan lines are valid

Now if the total outstanding amount plus the total received are distinct from the
invoice grand total an error is shown indicating a wrong payment plan quantity
modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-utilities.js
--- a/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-utilities.js	Thu Sep 05 08:47:04 2019 +0200
+++ b/modules/org.openbravo.advpaymentmngt/web/org.openbravo.advpaymentmngt/js/ob-aprm-utilities.js	Wed Sep 04 18:31:06 2019 -0400
@@ -82,6 +82,16 @@
           false
         ).inpoutstandingamt
       )
+    ),
+    invoiceGrandTotal = new BigDecimal(
+      String(
+        item.grid.view.parentWindow.activeView.getContextInfo(
+          false,
+          true,
+          true,
+          false
+        ).inpgrandtotal
+      )
     );
 
   if (
@@ -115,8 +125,9 @@
   }
   if (
     totalOutstanding
+      .add(totalReceived)
       .abs()
-      .compareTo(totalExpected.subtract(totalReceived).abs()) !== 0
+      .compareTo(invoiceGrandTotal.abs()) !== 0
   ) {
     return false;
   }