IDEMPIERE-3865 Payment term discount on payment doesnt consider the payment amount

This commit is contained in:
Carlos Ruiz 2019-01-19 12:35:05 +01:00
parent 70b5e48440
commit 175166bc12
1 changed files with 7 additions and 3 deletions

View File

@ -433,7 +433,7 @@ public class CalloutPayment extends CalloutEngine
currency.getStdPrecision (), RoundingMode.HALF_UP); currency.getStdPrecision (), RoundingMode.HALF_UP);
mTab.setValue ("OverUnderAmt", OverUnderAmt); 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) else if (C_Invoice_ID == 0)
{ {
if (Env.ZERO.compareTo (DiscountAmt) != 0) if (Env.ZERO.compareTo (DiscountAmt) != 0)
@ -448,8 +448,12 @@ public class CalloutPayment extends CalloutEngine
&& (!processed) && (!processed)
&& "Y".equals (Env.getContext (ctx, WindowNo, "IsOverUnderPayment"))) && "Y".equals (Env.getContext (ctx, WindowNo, "IsOverUnderPayment")))
{ {
OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract ( OverUnderAmt = InvoiceOpenAmt.subtract (PayAmt).subtract(DiscountAmt).subtract (WriteOffAmt);
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); mTab.setValue ("OverUnderAmt", OverUnderAmt);
} }
else if (colName.equals ("PayAmt") else if (colName.equals ("PayAmt")