Currently, iDempiere always creates the Payment, when it is effective, and does not come from a POS Order, even if the Invoice is reversed.
// POS supports multiple payments boolean fromPOS = false; if ( getC_Order_ID() > 0 ) { fromPOS = getC_Order().getC_POS_ID() > 0; }
// Create Cash Payment if (PAYMENTRULE_Cash.equals(getPaymentRule()) && !fromPOS
/// Should be Validated if Reversed
!isReversal()) {
// ... Payment is Created ...
}
I think that payment should be reversed like this:
public void reversePayment(boolean accrual) { if(PAYMENTRULE_Cash.equals(getPaymentRule()) && getC_Payment_ID() > 0) {
boolean fromPOS = false; if (getC_Order_ID() > 0)
fromPOS = getC_Order().getC_POS_ID() > 0; // Reverse Cash Payment if (!fromPOS ) { MPayment payment = new MPayment(getCtx(), getC_Payment_ID(), get_TrxName()); if(accrual) { payment.setDocAction(DocAction.ACTION_Reverse_Accrual); payment.reverseAccrualIt(); } else { payment.setDocAction(DocAction.ACTION_Reverse_Correct); payment.reverseCorrectIt(); } payment.saveEx(get_TrxName()); } }}