Fixes issue 36556: Organization filter in Orders Awaiting Invoice Report does not
authorArmaignac <collazoandy4@gmail.com>
Tue, 27 Nov 2018 09:17:11 +0100
changeset 35159 1a4041af1fa1
parent 35158 bd0a3cf6b7fd
child 35160 ebcc9e8ba08a
Fixes issue 36556: Organization filter in Orders Awaiting Invoice Report does not
work properly for summary level organizations

Organization filter in Orders Awaiting Invoice Report does not work properly for
summary level organizations, When parent organization is selected as a filter,
records for its child organization are not shown in the report.

The Organization child tree is now set as a filter for the report query.
src/org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoiceJR.java
src/org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoice_data.xsql
--- a/src/org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoiceJR.java	Tue Nov 27 14:01:39 2018 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoiceJR.java	Tue Nov 27 09:17:11 2018 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2017 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2018 Openbravo SLU 
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -29,6 +29,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.businessUtility.WindowTabs;
 import org.openbravo.erpCommon.utility.ComboTableData;
@@ -73,6 +74,13 @@
       String strcBpartnetId = vars.getRequestGlobalVariable("inpcBPartnerId",
           "ReportOrderNotInvoiceJR|bpartner");
       String strCOrgId = vars.getRequestGlobalVariable("inpOrg", "ReportOrderNotInvoiceJR|Org");
+      if (!StringUtils.isEmpty(strCOrgId)) {
+        StringBuilder orgIdBuilder = new StringBuilder("(");
+        orgIdBuilder.append(Utility.getInStrSet(OBContext.getOBContext()
+            .getOrganizationStructureProvider().getChildTree(strCOrgId, true)));
+        orgIdBuilder.append(")");
+        strCOrgId = orgIdBuilder.toString();
+      }
       String strInvoiceRule = vars.getRequestGlobalVariable("inpInvoiceRule",
           "ReportOrderNotInvoiceJR|invoiceRule");
       String strDetail = vars.getStringParameter("inpDetail", "0");
--- a/src/org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoice_data.xsql	Tue Nov 27 14:01:39 2018 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportOrderNotInvoice_data.xsql	Tue Nov 27 09:17:11 2018 +0100
@@ -121,7 +121,7 @@
 	<Parameter name="adUserClient" type="replace" optional="true" after="C.AD_Client_ID IN (" text="'1'"/>
 	<Parameter name="adUserOrg" type="replace" optional="true" after="C.AD_ORG_ID IN (" text="'1'"/>
 	<Parameter name="cBpartnerId" optional="true" after="1=1">AND C.C_BPARTNER_ID = ?</Parameter>
-	<Parameter name="cOrgId" optional="true" after="1=1">AND C.AD_ORG_ID = ?</Parameter>
+	<Parameter name="cOrgId" optional="true" type="argument" after="AND 1=1"><![CDATA[AND C.AD_ORG_ID IN ]]></Parameter>
 	<Parameter name="invoiceRule" optional="true" after="1=1">AND C.INVOICERULE = ?</Parameter>
 	<Parameter name="dateFrom" optional="true" after="1=1"><![CDATA[ AND C.DATEORDERED >= to_date(?) ]]></Parameter>
 	<Parameter name="dateTo" optional="true" after="1=1"><![CDATA[ AND C.DATEORDERED < to_date(?) ]]></Parameter>