IDEMPIERE-1088 Problem with Reverse-Accrual with payment allocation
This commit is contained in:
parent
ac1a8e486c
commit
0e80967351
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue