IDEMPIERE-860 Review Payment Processors

- fix the payment amount and invoice ID reference of the new sales payment when invoiced amount is NOT equals to the authorized amount
- throw error when invoiced amount is NOT equals to the authorized amount for non-CIM payment processor
This commit is contained in:
Elaine Tan 2013-04-17 17:59:11 +08:00
parent 4100d6ba55
commit d2c3c23d9d
1 changed files with 10 additions and 2 deletions

View File

@ -1990,6 +1990,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
// automatically void authorization payment and create a new sales payment when invoiced amount is NOT equals to the authorized amount (applied to CIM payment processor) // automatically void authorization payment and create a new sales payment when invoiced amount is NOT equals to the authorized amount (applied to CIM payment processor)
if(getGrandTotal().compareTo(totalPayAmt) != 0 && if(getGrandTotal().compareTo(totalPayAmt) != 0 &&
ptList.size() > 0 && ptList.size() > 0 &&
ptList.get(0).getC_PaymentProcessor_ID() > 0 &&
ptList.get(0).getCustomerPaymentProfileID() != null && ptList.get(0).getCustomerPaymentProfileID() != null &&
ptList.get(0).getCustomerPaymentProfileID().length() > 0) ptList.get(0).getCustomerPaymentProfileID().length() > 0)
{ {
@ -1998,12 +1999,14 @@ public class MInvoice extends X_C_Invoice implements DocAction
newSalesPT.setIsApproved(false); newSalesPT.setIsApproved(false);
newSalesPT.setIsVoided(false); newSalesPT.setIsVoided(false);
newSalesPT.setIsDelayedCapture(false); newSalesPT.setIsDelayedCapture(false);
newSalesPT.setDescription("InvoicedAmt: " + getGrandTotal() + " > TotalAuthorizedAmt: " + totalPayAmt); newSalesPT.setDescription("InvoicedAmt: " + getGrandTotal() + " <> TotalAuthorizedAmt: " + totalPayAmt);
newSalesPT.setC_Invoice_ID(getC_Invoice_ID());
newSalesPT.setPayAmt(getGrandTotal());
// void authorization payment // void authorization payment
for (MPaymentTransaction pt : ptList) for (MPaymentTransaction pt : ptList)
{ {
pt.setDescription("InvoicedAmt: " + getGrandTotal() + " > AuthorizedAmt: " + pt.getPayAmt()); pt.setDescription("InvoicedAmt: " + getGrandTotal() + " <> AuthorizedAmt: " + pt.getPayAmt());
boolean ok = pt.voidOnlineAuthorizationPaymentTransaction(); boolean ok = pt.voidOnlineAuthorizationPaymentTransaction();
pt.saveEx(); pt.saveEx();
if (!ok) if (!ok)
@ -2022,6 +2025,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
} }
else if (getGrandTotal().compareTo(totalPayAmt) != 0 && ptList.size() > 0)
{
m_processMsg = "InvoicedAmt: " + getGrandTotal() + " <> AuthorizedAmt: " + totalPayAmt;
return DocAction.STATUS_Invalid;
}
else else
{ {
// delay capture authorization payment // delay capture authorization payment