diff --git a/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java b/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java index a93b20a2b6..e6c1ff9ec1 100644 --- a/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java +++ b/org.adempiere.base.process/src/org/compiere/process/AllocationReset.java @@ -21,6 +21,7 @@ import java.sql.ResultSet; import java.sql.Timestamp; import java.util.logging.Level; +import org.adempiere.exceptions.AdempiereException; import org.compiere.model.MAllocationHdr; import org.compiere.util.AdempiereUserError; import org.compiere.util.DB; @@ -110,6 +111,8 @@ public class AllocationReset extends SvrProcess MAllocationHdr hdr = new MAllocationHdr(getCtx(), p_C_AllocationHdr_ID, m_trx.getTrxName()); if (delete(hdr)) count++; + else + throw new AdempiereException("Cannot delete"); m_trx.close(); StringBuilder msgreturn = new StringBuilder("@Deleted@ #").append(count); return msgreturn.toString(); diff --git a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java index 13267c6652..6e1faafe8e 100644 --- a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java @@ -407,21 +407,23 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction } // Stop the Document Workflow if invoice to allocate is as paid - for (MAllocationLine line :m_lines) - { - if (line.getC_Invoice_ID() != 0) - { - StringBuilder whereClause = new StringBuilder(I_C_Invoice.COLUMNNAME_C_Invoice_ID).append("=? AND ") - .append(I_C_Invoice.COLUMNNAME_IsPaid).append("=? AND ") - .append(I_C_Invoice.COLUMNNAME_DocStatus).append(" NOT IN (?,?)"); - boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause.toString(), get_TrxName()) - .setClient_ID() - .setParameters(line.getC_Invoice_ID(), "Y", X_C_Invoice.DOCSTATUS_Voided, X_C_Invoice.DOCSTATUS_Reversed) - .match(); - if(InvoiceIsPaid && line.getAmount().signum() > 0) - throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@"); - } - } + if (!isReversal()) { + for (MAllocationLine line :m_lines) + { + if (line.getC_Invoice_ID() != 0) + { + StringBuilder whereClause = new StringBuilder(I_C_Invoice.COLUMNNAME_C_Invoice_ID).append("=? AND ") + .append(I_C_Invoice.COLUMNNAME_IsPaid).append("=? AND ") + .append(I_C_Invoice.COLUMNNAME_DocStatus).append(" NOT IN (?,?)"); + boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause.toString(), get_TrxName()) + .setClient_ID() + .setParameters(line.getC_Invoice_ID(), "Y", X_C_Invoice.DOCSTATUS_Voided, X_C_Invoice.DOCSTATUS_Reversed) + .match(); + if (InvoiceIsPaid && line.getAmount().signum() > 0) + throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@"); + } + } + } // Add up Amounts & validate BigDecimal approval = Env.ZERO;