diff --git a/org.adempiere.base.process/src/org/compiere/process/PaySelectionCreateFrom.java b/org.adempiere.base.process/src/org/compiere/process/PaySelectionCreateFrom.java index ac57be1f5d..4e2870c8cc 100644 --- a/org.adempiere.base.process/src/org/compiere/process/PaySelectionCreateFrom.java +++ b/org.adempiere.base.process/src/org/compiere/process/PaySelectionCreateFrom.java @@ -148,7 +148,7 @@ public class PaySelectionCreateFrom extends SvrProcess .append(" WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.IsActive='Y'") .append(" AND (pmt.DocStatus IS NULL OR pmt.DocStatus NOT IN ('VO','RE')) )") // Don't generate again invoices already on this payment selection - .append(" AND i.C_Invoice_ID NOT IN (SELECT i.C_Invoice_ID FROM C_PaySelectionLine psl WHERE psl.C_PaySelection_ID=?)"); // ##p9 + .append(" AND i.C_Invoice_ID NOT IN (SELECT psl.C_Invoice_ID FROM C_PaySelectionLine psl WHERE psl.C_PaySelection_ID=?)"); // ##p9 // Disputed if (!p_IncludeInDispute) sqlWhere.append(" AND i.IsInDispute='N'"); 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);