Fixes bug 26117: Payment created in Payment Proposal is executed more than once
authorEduardo Argal Guibert <eduardo.argal@openbravo.com>
Tue, 15 Apr 2014 19:11:46 +0200
changeset 22923 c25c56618b6d
parent 22922 9f4a800d3f0a
child 22924 d1aef7712d87
Fixes bug 26117: Payment created in Payment Proposal is executed more than once
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ExecutePayments.java
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ExecutePayments.java	Tue Apr 15 18:59:23 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ExecutePayments.java	Tue Apr 15 19:11:46 2014 +0200
@@ -22,8 +22,10 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -168,6 +170,7 @@
       }
 
       List<FIN_Payment> payments = FIN_Utility.getOBObjectList(FIN_Payment.class, strPayments);
+      Set<FIN_Payment> paymentSet = new HashSet<FIN_Payment>(payments);
       FIN_ExecutePayment executePayment = new FIN_ExecutePayment();
       executePayment.init(getSource(strWindowId), executionProcess, payments, parameters,
           organization);
@@ -175,7 +178,7 @@
       String paymentsDocNo = "";
       if ("Success".equals(result.getType())) {
         int i = 0;
-        Iterator<FIN_Payment> iterator = payments.iterator();
+        Iterator<FIN_Payment> iterator = paymentSet.iterator();
         while (iterator.hasNext()) {
           FIN_Payment payment = iterator.next();
           if (i == 0) {
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java	Tue Apr 15 18:59:23 2014 +0200
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java	Tue Apr 15 19:11:46 2014 +0200
@@ -20,7 +20,9 @@
 
 import java.math.BigDecimal;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
 import org.openbravo.advpaymentmngt.dao.TransactionsDao;
@@ -70,7 +72,8 @@
     else
       this.parameters = _parameters;
     this.paymentRun = dao.getNewPaymentRun(sourceType, executionProcess, organization);
-    for (FIN_Payment payment : payments)
+    Set<FIN_Payment> paymentSet = new HashSet<FIN_Payment>(payments);
+    for (FIN_Payment payment : paymentSet)
       dao.getNewPaymentRunPayment(paymentRun, payment);
     final List<PaymentExecutionProcessParameter> allParameters = executionProcess
         .getFinancialMgmtPaymentExecutionProcessParameterList();
@@ -181,6 +184,7 @@
             }
             paymentRunPayment.getPayment().setPosted("N");
             try {
+              OBContext.setAdminMode(true);
               for (FIN_PaymentDetail pd : payment.getFINPaymentDetailList()) {
                 for (FIN_PaymentScheduleDetail psd : pd.getFINPaymentScheduleDetailList()) {
                   if (psd.isInvoicePaid()