IDEMPIERE-1088 Problem with Reverse-Accrual with payment allocation

This commit is contained in:
Carlos Ruiz 2013-06-21 19:26:14 -05:00
parent ac1a8e486c
commit 0e80967351
2 changed files with 20 additions and 15 deletions

View File

@ -21,6 +21,7 @@ import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MAllocationHdr; import org.compiere.model.MAllocationHdr;
import org.compiere.util.AdempiereUserError; import org.compiere.util.AdempiereUserError;
import org.compiere.util.DB; 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()); MAllocationHdr hdr = new MAllocationHdr(getCtx(), p_C_AllocationHdr_ID, m_trx.getTrxName());
if (delete(hdr)) if (delete(hdr))
count++; count++;
else
throw new AdempiereException("Cannot delete");
m_trx.close(); m_trx.close();
StringBuilder msgreturn = new StringBuilder("@Deleted@ #").append(count); StringBuilder msgreturn = new StringBuilder("@Deleted@ #").append(count);
return msgreturn.toString(); return msgreturn.toString();

View File

@ -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 // Stop the Document Workflow if invoice to allocate is as paid
for (MAllocationLine line :m_lines) if (!isReversal()) {
{ for (MAllocationLine line :m_lines)
if (line.getC_Invoice_ID() != 0) {
{ 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 ") StringBuilder whereClause = new StringBuilder(I_C_Invoice.COLUMNNAME_C_Invoice_ID).append("=? AND ")
.append(I_C_Invoice.COLUMNNAME_DocStatus).append(" NOT IN (?,?)"); .append(I_C_Invoice.COLUMNNAME_IsPaid).append("=? AND ")
boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause.toString(), get_TrxName()) .append(I_C_Invoice.COLUMNNAME_DocStatus).append(" NOT IN (?,?)");
.setClient_ID() boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause.toString(), get_TrxName())
.setParameters(line.getC_Invoice_ID(), "Y", X_C_Invoice.DOCSTATUS_Voided, X_C_Invoice.DOCSTATUS_Reversed) .setClient_ID()
.match(); .setParameters(line.getC_Invoice_ID(), "Y", X_C_Invoice.DOCSTATUS_Voided, X_C_Invoice.DOCSTATUS_Reversed)
if(InvoiceIsPaid && line.getAmount().signum() > 0) .match();
throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@"); if (InvoiceIsPaid && line.getAmount().signum() > 0)
} throw new AdempiereException("@ValidationError@ @C_Invoice_ID@ @IsPaid@");
} }
}
}
// Add up Amounts & validate // Add up Amounts & validate
BigDecimal approval = Env.ZERO; BigDecimal approval = Env.ZERO;