From d0036eff0e6d0463ef4a224e178a77f25e0b8846 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 1 May 2008 05:19:22 +0000 Subject: [PATCH] Fix [ 1953184 ] Validate BP marks draft invoice as paid --- base/src/org/compiere/model/MInvoice.java | 33 +++++++++++++---------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/base/src/org/compiere/model/MInvoice.java b/base/src/org/compiere/model/MInvoice.java index 98399dd7e1..e1be96502f 100644 --- a/base/src/org/compiere/model/MInvoice.java +++ b/base/src/org/compiere/model/MInvoice.java @@ -1121,20 +1121,25 @@ public class MInvoice extends X_C_Invoice implements DocAction */ public boolean testAllocation() { - BigDecimal alloc = getAllocatedAmt(); // absolute - if (alloc == null) - alloc = Env.ZERO; - BigDecimal total = getGrandTotal(); - if (!isSOTrx()) - total = total.negate(); - if (isCreditMemo()) - total = total.negate(); - boolean test = total.compareTo(alloc) == 0; - boolean change = test != isPaid(); - if (change) - setIsPaid(test); - log.fine("Paid=" + test - + " (" + alloc + "=" + total + ")"); + boolean change = false; + + if ( isProcessed() ) { + BigDecimal alloc = getAllocatedAmt(); // absolute + if (alloc == null) + alloc = Env.ZERO; + BigDecimal total = getGrandTotal(); + if (!isSOTrx()) + total = total.negate(); + if (isCreditMemo()) + total = total.negate(); + boolean test = total.compareTo(alloc) == 0; + change = test != isPaid(); + if (change) + setIsPaid(test); + log.fine("Paid=" + test + + " (" + alloc + "=" + total + ")"); + } + return change; } // testAllocation