Fixes bug 27182: Wrong source payment selected when refunding
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Thu, 24 Jul 2014 18:45:22 +0200
changeset 24117 661190e92d0b
parent 24116 71682af8063c
child 24118 62cb5fa058ed
Fixes bug 27182: Wrong source payment selected when refunding
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java	Thu Jul 24 17:54:20 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java	Thu Jul 24 18:45:22 2014 +0200
@@ -172,7 +172,7 @@
           || strAction.equals("PPW")) {
 
         OBError message = processPayment(payment, strAction, strDifferenceAction, differenceAmount,
-            exchangeRate);
+            exchangeRate, jsonparams);
         JSONObject errorMessage = new JSONObject();
         errorMessage.put("severity", message.getType().toLowerCase());
         errorMessage.put("title", message.getTitle());
@@ -329,6 +329,7 @@
         creditPayment.setDescription(truncateDescription);
         // Set Used Credit = Amount + Previous used credit introduced by the user
         creditPayment.setUsedCredit(usedCreditAmt.add(creditPayment.getUsedCredit()));
+        ;
         FIN_PaymentProcess.linkCreditPayment(payment, usedCreditAmt, creditPayment);
         OBDal.getInstance().save(creditPayment);
       }
@@ -468,7 +469,7 @@
   }
 
   private OBError processPayment(FIN_Payment payment, String strAction, String strDifferenceAction,
-      BigDecimal refundAmount, BigDecimal exchangeRate) throws Exception {
+      BigDecimal refundAmount, BigDecimal exchangeRate, JSONObject jsonparams) throws Exception {
     ConnectionProvider conn = new DalConnectionProvider(true);
     VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
 
@@ -497,6 +498,7 @@
       conn = new DalConnectionProvider(true);
       OBDal.getInstance().getSession().clear();
       payment = OBDal.getInstance().get(FIN_Payment.class, payment.getId());
+      addCredit(payment, jsonparams);
     }
     if (!strDifferenceAction.equals("refund")) {
       return message;