details:   https://code.openbravo.com/erp/devel/pi/rev/9c31b62de9a2
changeset: 36004:9c31b62de9a2
user:      Nono Carballo <nonofce <at> gmail.com>
date:      Thu May 30 11:36:20 2019 -0400
summary:   Fixes issue 40964: Fixes getting Filter by Payment Method

Avoids duplicates in list of payment method Id's.
Fixes the way the filter is build when there are more than 1000 payment methods
for filtering

details:   https://code.openbravo.com/erp/devel/pi/rev/3365dc61940e
changeset: 36005:3365dc61940e
user:      Sandra Huguet <sandra.huguet <at> openbravo.com>
date:      Wed Jun 05 12:44:16 2019 +0200
summary:   related to issue 40964 reimplement the way to split the 
paymentMethods

diffstat:

 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
 |  24 ++++-----
 1 files changed, 10 insertions(+), 14 deletions(-)

diffs (67 lines):

diff -r 1287606da0c8 -r 3365dc61940e 
modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
--- 
a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
  Wed Jun 05 16:15:03 2019 +0200
+++ 
b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/dao/AdvPaymentMngtDao.java
  Wed Jun 05 12:44:16 2019 +0200
@@ -23,6 +23,7 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -830,7 +831,7 @@
         
OBContext.getOBContext().getOrganizationStructureProvider().getNaturalTree(strOrgId)));
     obc.setFilterOnReadableOrganization(false);
 
-    List<String> payMethods = new ArrayList<>();
+    Set<String> payMethods = new HashSet<>();
     if (strFinancialAccountId != null && !strFinancialAccountId.isEmpty()) {
       for (FinAccPaymentMethod finAccPayMethod : 
getObject(FIN_FinancialAccount.class,
           strFinancialAccountId).getFinancialMgmtFinAccPaymentMethodList()) {
@@ -846,7 +847,7 @@
       if (payMethods.isEmpty()) {
         return (new ArrayList<FIN_PaymentMethod>());
       }
-      addPaymentMethodList(obc, payMethods);
+      addPaymentMethodList(obc, new ArrayList<String>(payMethods));
     } else {
       if (excludePaymentMethodWithoutAccount) {
 
@@ -862,7 +863,7 @@
         if (payMethods.isEmpty()) {
           return (new ArrayList<FIN_PaymentMethod>());
         }
-        addPaymentMethodList(obc, payMethods);
+        addPaymentMethodList(obc, new ArrayList<String>(payMethods));
       }
       if (paymentDirection == PaymentDirection.IN) {
         obc.add(Restrictions.eq(FIN_PaymentMethod.PROPERTY_PAYINALLOW, true));
@@ -905,22 +906,17 @@
       List<String> paymentMethods) {
     Criterion compoundExp = null;
     int paymentMethodsSize = paymentMethods.size();
-    while (paymentMethodsSize > 999) {
-      List<String> paymentMethodsToRemove = paymentMethods.subList(0, 999);
+    int batchIni = 0;
+    int batchSize = 1000;
+    while (paymentMethodsSize > batchIni) {
+      List<String> paymentMethodsToRemove = paymentMethods.subList(batchIni,
+          Math.min(batchIni + batchSize, paymentMethodsSize));
       if (compoundExp == null) {
         compoundExp = Restrictions.in("id", paymentMethodsToRemove);
       } else {
         compoundExp = Restrictions.or(compoundExp, Restrictions.in("id", 
paymentMethodsToRemove));
       }
-      paymentMethods.removeAll(paymentMethodsToRemove);
-      paymentMethodsSize = paymentMethodsSize - 999;
-    }
-    if (paymentMethodsSize > 0) {
-      if (compoundExp == null) {
-        compoundExp = Restrictions.in("id", paymentMethods);
-      } else {
-        compoundExp = Restrictions.or(compoundExp, Restrictions.in("id", 
paymentMethods));
-      }
+      batchIni += batchSize;
     }
     if (compoundExp != null) {
       obc.add(compoundExp);


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to