1003528 GL Bug? Reversed payment showing up on Payment Allocation. Fixed reverse accrual of payment.

This commit is contained in:
Heng Sin Low 2013-12-03 17:57:54 +08:00
parent 548d0d1791
commit c436141c39
1 changed files with 32 additions and 36 deletions

View File

@ -2429,8 +2429,7 @@ public final class MPayment extends X_C_Payment
} }
// //
setC_Invoice_ID(0); setC_Invoice_ID(0);
if (!accrual) setIsAllocated(false);
setIsAllocated(false);
} // deallocate } // deallocate
/** /**
@ -2626,40 +2625,37 @@ public final class MPayment extends X_C_Payment
setReversal_ID(reversal.getC_Payment_ID()); setReversal_ID(reversal.getC_Payment_ID());
StringBuilder info = new StringBuilder(reversal.getDocumentNo()); StringBuilder info = new StringBuilder(reversal.getDocumentNo());
if (!accrual)
{ // Create automatic Allocation
// Create automatic Allocation MAllocationHdr alloc = new MAllocationHdr (getCtx(), false,
MAllocationHdr alloc = new MAllocationHdr (getCtx(), false, ( accrual ? dateAcct : getDateTrx() ),
getDateTrx(), getC_Currency_ID(), getC_Currency_ID(),
Msg.translate(getCtx(), "C_Payment_ID") + ": " + reversal.getDocumentNo(), get_TrxName()); Msg.translate(getCtx(), "C_Payment_ID") + ": " + reversal.getDocumentNo(), get_TrxName());
alloc.setAD_Org_ID(getAD_Org_ID()); alloc.setAD_Org_ID(getAD_Org_ID());
if (!alloc.save()) alloc.saveEx(get_TrxName());
log.warning("Automatic allocation - hdr not saved");
else // Original Allocation
{ MAllocationLine aLine = new MAllocationLine (alloc, getPayAmt(true),
// Original Allocation Env.ZERO, Env.ZERO, Env.ZERO);
MAllocationLine aLine = new MAllocationLine (alloc, getPayAmt(true), aLine.setDocInfo(getC_BPartner_ID(), 0, 0);
Env.ZERO, Env.ZERO, Env.ZERO); aLine.setPaymentInfo(getC_Payment_ID(), 0);
aLine.setDocInfo(getC_BPartner_ID(), 0, 0); if (!aLine.save(get_TrxName()))
aLine.setPaymentInfo(getC_Payment_ID(), 0); log.warning("Automatic allocation - line not saved");
if (!aLine.save(get_TrxName())) // Reversal Allocation
log.warning("Automatic allocation - line not saved"); aLine = new MAllocationLine (alloc, reversal.getPayAmt(true),
// Reversal Allocation Env.ZERO, Env.ZERO, Env.ZERO);
aLine = new MAllocationLine (alloc, reversal.getPayAmt(true), aLine.setDocInfo(reversal.getC_BPartner_ID(), 0, 0);
Env.ZERO, Env.ZERO, Env.ZERO); aLine.setPaymentInfo(reversal.getC_Payment_ID(), 0);
aLine.setDocInfo(reversal.getC_BPartner_ID(), 0, 0); if (!aLine.save(get_TrxName()))
aLine.setPaymentInfo(reversal.getC_Payment_ID(), 0); log.warning("Automatic allocation - reversal line not saved");
if (!aLine.save(get_TrxName()))
log.warning("Automatic allocation - reversal line not saved"); // added AdempiereException by zuhri
} if (!alloc.processIt(DocAction.ACTION_Complete))
// added AdempiereException by zuhri throw new AdempiereException("Failed when processing document - " + alloc.getProcessMsg());
if (!alloc.processIt(DocAction.ACTION_Complete)) // end added
throw new AdempiereException("Failed when processing document - " + alloc.getProcessMsg()); alloc.saveEx(get_TrxName());
// end added //
alloc.saveEx(get_TrxName()); info.append(" - @C_AllocationHdr_ID@: ").append(alloc.getDocumentNo());
//
info.append(" - @C_AllocationHdr_ID@: ").append(alloc.getDocumentNo());
}
// Update BPartner // Update BPartner
if (getC_BPartner_ID() != 0) if (getC_BPartner_ID() != 0)