Reverse Invoice with Payment Cash

54 views
Skip to first unread message

Victor Suárez

unread,
May 11, 2020, 6:42:00 PM5/11/20
to iDempiere
Hello community.

I have  a doubt. When I reverse an Invoice with Payment Rule is CASH ('B'), it's create a payment, with "PayAmt" in negative, and it's complete it, but I think this other payment shouldn't be created. If not, reverse the existing payment, and associated with this invoice.

WDYT?

Martin Schönbeck

unread,
May 12, 2020, 2:59:16 AM5/12/20
to iDempiere
Hi Victor,
I my opinion it depends on when the original. payment was created. If it was created implicitly by completing the invoice it of should be reversed when reversing this completion. Reversing a completion should reverse anything which was initiated by this completion.

Regards,
Martin

Victor Suárez

unread,
May 15, 2020, 12:28:51 AM5/15/20
to iDempiere
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  ...
                }


Victor Suárez

unread,
May 15, 2020, 12:35:16 AM5/15/20
to iDempiere
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());
     }
}
}


Reply all
Reply to author
Forward
0 new messages