From d2c3c23d9d32cbe19de9cd35bf2968573fa3b9c5 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Wed, 17 Apr 2013 17:59:11 +0800 Subject: [PATCH] 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 --- .../src/org/compiere/model/MInvoice.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 4b780f2b0c..d7549d9c26 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -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) if(getGrandTotal().compareTo(totalPayAmt) != 0 && ptList.size() > 0 && + ptList.get(0).getC_PaymentProcessor_ID() > 0 && ptList.get(0).getCustomerPaymentProfileID() != null && ptList.get(0).getCustomerPaymentProfileID().length() > 0) { @@ -1998,12 +1999,14 @@ public class MInvoice extends X_C_Invoice implements DocAction newSalesPT.setIsApproved(false); newSalesPT.setIsVoided(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 for (MPaymentTransaction pt : ptList) { - pt.setDescription("InvoicedAmt: " + getGrandTotal() + " > AuthorizedAmt: " + pt.getPayAmt()); + pt.setDescription("InvoicedAmt: " + getGrandTotal() + " <> AuthorizedAmt: " + pt.getPayAmt()); boolean ok = pt.voidOnlineAuthorizationPaymentTransaction(); pt.saveEx(); if (!ok) @@ -2022,6 +2025,11 @@ public class MInvoice extends X_C_Invoice implements DocAction return DocAction.STATUS_Invalid; } } + else if (getGrandTotal().compareTo(totalPayAmt) != 0 && ptList.size() > 0) + { + m_processMsg = "InvoicedAmt: " + getGrandTotal() + " <> AuthorizedAmt: " + totalPayAmt; + return DocAction.STATUS_Invalid; + } else { // delay capture authorization payment