From a36e013b4a7f26ae65c992c96eb3a02883e5c2cd Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Tue, 27 Oct 2009 21:08:04 +0000 Subject: [PATCH] Error you can allocate a payment to invoice that was paid https://sourceforge.net/tracker/index.php?func=detail&aid=2880182&group_id=176962&atid=879332 revert the MPayment changes and implement the Carlos's suggestion. kind regards Victor Perez www.e-evolution.com --- .../org/compiere/model/MAllocationHdr.java | 22 +++++++++++++++++-- base/src/org/compiere/model/MPayment.java | 11 ---------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/base/src/org/compiere/model/MAllocationHdr.java b/base/src/org/compiere/model/MAllocationHdr.java index 8d57faf13e..85bb5fe118 100644 --- a/base/src/org/compiere/model/MAllocationHdr.java +++ b/base/src/org/compiere/model/MAllocationHdr.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.exceptions.AdempiereException; import org.compiere.process.DocAction; import org.compiere.process.DocumentEngine; import org.compiere.util.CLogger; @@ -43,9 +44,11 @@ import org.compiere.util.Msg; * @version $Id: MAllocationHdr.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ * @author victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com *
  • FR [ 1866214 ] - * @see http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335 + *
  • http://sourceforge.net/tracker/index.php?func=detail&aid=1866214&group_id=176962&atid=879335 *
  • FR [ 2520591 ] Support multiples calendar for Org - * @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962 + *
  • http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962 + *
  • BF [ 2880182 ] Error you can allocate a payment to invoice that was paid + *
  • https://sourceforge.net/tracker/index.php?func=detail&aid=2880182&group_id=176962&atid=879332 */ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction { @@ -402,6 +405,21 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction m_processMsg = "@NoLines@"; return DocAction.STATUS_Invalid; } + + // Stop the Document Workflow if invoice to allocate is as paid + for (MAllocationLine line :m_lines) + { + if (line.getC_Invoice_ID() != 0) + { + boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, I_C_Invoice.COLUMNNAME_C_Invoice_ID + "=? AND " + I_C_Invoice.COLUMNNAME_IsPaid + "=?", get_TrxName()) + .setClient_ID() + .setParameters(new Object[]{line.getC_Invoice_ID(), "Y"}) + .match(); + if(InvoiceIsPaid) + throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@"); + } + } + // Add up Amounts & validate BigDecimal approval = Env.ZERO; for (int i = 0; i < m_lines.length; i++) diff --git a/base/src/org/compiere/model/MPayment.java b/base/src/org/compiere/model/MPayment.java index 64af86852e..2bbf9e1677 100644 --- a/base/src/org/compiere/model/MPayment.java +++ b/base/src/org/compiere/model/MPayment.java @@ -1640,17 +1640,6 @@ public final class MPayment extends X_C_Payment return DocAction.STATUS_Invalid; } - // Stop workflow if invoice are paid - if (getC_Invoice_ID() != 0) - { - boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, I_C_Invoice.COLUMNNAME_C_Invoice_ID + "=? AND " + I_C_Invoice.COLUMNNAME_IsPaid + "=?", get_TrxName()) - .setClient_ID() - .setParameters(new Object[]{getC_Invoice_ID(), "Y"}) - .match(); - if(InvoiceIsPaid) - throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@"); - } - // Unsuccessful Online Payment if (isOnline() && !isApproved()) {