From 39a601874dff6644270849addce814939273bbec Mon Sep 17 00:00:00 2001 From: Murilo Habermann Torquato Date: Wed, 4 Sep 2019 09:44:56 -0300 Subject: [PATCH] COF #10054 / IDEMPIERE-4043 - allocation amount problem when using allocate tab --- org.adempiere.base/src/org/compiere/model/MPayment.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 9ab8374dc3..f688f3d5b4 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -2282,12 +2282,17 @@ public class MPayment extends X_C_Payment for (int i = 0; i < pAllocs.length; i++) { MPaymentAllocate pa = pAllocs[i]; + + BigDecimal allocationAmt = pa.getAmount(); // underpayment + if (pa.getOverUnderAmt().signum() < 0 && pa.getAmount().signum() > 0) + allocationAmt = allocationAmt.add(pa.getOverUnderAmt()); // overpayment (negative) + MAllocationLine aLine = null; if (isReceipt()) - aLine = new MAllocationLine (alloc, pa.getAmount(), + aLine = new MAllocationLine (alloc, allocationAmt, pa.getDiscountAmt(), pa.getWriteOffAmt(), pa.getOverUnderAmt()); else - aLine = new MAllocationLine (alloc, pa.getAmount().negate(), + aLine = new MAllocationLine (alloc, allocationAmt.negate(), pa.getDiscountAmt().negate(), pa.getWriteOffAmt().negate(), pa.getOverUnderAmt().negate()); aLine.setDocInfo(pa.getC_BPartner_ID(), 0, pa.getC_Invoice_ID()); aLine.setPaymentInfo(getC_Payment_ID(), 0);