Fixes issue 19737: Payment Report does not take into account the role you are logged with.
authorIoritz Cia <ioritz.cia@openbravo.com>
Tue, 14 Feb 2012 13:44:39 +0100
changeset 15506 9b82d811c2b2
parent 15505 f2585e9deaf5
child 15507 a7e9e2f864a2
Fixes issue 19737: Payment Report does not take into account the role you are logged with.
modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java
--- a/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java	Wed Feb 15 16:58:28 2012 +0100
+++ b/modules/org.openbravo.financial.paymentreport/src/org/openbravo/financial/paymentreport/erpCommon/ad_reports/PaymentReportDao.java	Tue Feb 14 13:44:39 2012 +0100
@@ -128,6 +128,11 @@
       hsqlScript.append(" is not null or invps is not null ");
       hsqlScript.append(") ");
 
+      hsqlScript.append(" and fpsd.");
+      hsqlScript.append(FIN_PaymentScheduleDetail.PROPERTY_ORGANIZATION);
+      hsqlScript.append(".id in ");
+      hsqlScript.append(concatOrganizations(OBContext.getOBContext().getReadableOrganizations()));
+
       // organization + include sub-organization
       if (!strOrg.isEmpty()) {
         if (!strInclSubOrg.equalsIgnoreCase("include")) {
@@ -1160,4 +1165,17 @@
     }
     return bp;
   }
+
+  private String concatOrganizations(String[] orgs) {
+    String concatOrgs = "";
+    for (int i = 0; i < orgs.length; i++) {
+      concatOrgs = concatOrgs.concat("', '" + orgs[i]);
+    }
+    if (!concatOrgs.equalsIgnoreCase("")) {
+      concatOrgs = concatOrgs.substring(3);
+      concatOrgs = "(" + concatOrgs + "')";
+    }
+
+    return concatOrgs;
+  }
 }