From 175166bc121fdc00b38fa65549c4e7d5165b4b84 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 19 Jan 2019 12:35:05 +0100 Subject: [PATCH] IDEMPIERE-3865 Payment term discount on payment doesnt consider the payment amount --- .../src/org/compiere/model/CalloutPayment.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java index 1ca3a98309..1e46f97b1c 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutPayment.java @@ -433,7 +433,7 @@ public class CalloutPayment extends CalloutEngine currency.getStdPrecision (), RoundingMode.HALF_UP); mTab.setValue ("OverUnderAmt", OverUnderAmt); } - // No Invoice - Set Discount, Witeoff, Under/Over to 0 + // No Invoice - Set Discount, Writeoff, Under/Over to 0 else if (C_Invoice_ID == 0) { if (Env.ZERO.compareTo (DiscountAmt) != 0) @@ -448,8 +448,12 @@ public class CalloutPayment extends CalloutEngine && (!processed) && "Y".equals (Env.getContext (ctx, WindowNo, "IsOverUnderPayment"))) { - OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract ( - DiscountAmt).subtract (WriteOffAmt); + OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract(DiscountAmt).subtract (WriteOffAmt); + if (OverUnderAmt.signum() > 0) { // no discount because is not paid in full + DiscountAmt = Env.ZERO; + mTab.setValue ("DiscountAmt", DiscountAmt); + OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract(DiscountAmt).subtract (WriteOffAmt); + } mTab.setValue ("OverUnderAmt", OverUnderAmt); } else if (colName.equals ("PayAmt")