Fixes issue 11470: Error with * organization
authorDavid Alsasua <david.alsasua@openbravo.com>
Mon, 14 Dec 2009 03:02:56 +0100
changeset 5703 e7ad8a48210d
parent 5702 ffba35c94a86
child 5704 fac7faeaae8c
child 5706 b9b9f4e7a61b
Fixes issue 11470: Error with * organization
in Balance sheet and P&L structure
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java	Mon Dec 14 02:42:20 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java	Mon Dec 14 03:02:56 2009 +0100
@@ -446,7 +446,7 @@
     xmlDocument.setParameter("accountingReports", Utility.arrayDobleEntrada("arrAccountingReports",
         GeneralAccountingReportsData.selectRptDouble(this)));
     xmlDocument.setParameter("years", Utility.arrayDobleEntrada("arrYears",
-        GeneralAccountingReportsData.selectYearsDouble(this)));
+        GeneralAccountingReportsData.selectYearsDouble(this, vars.getUserClient())));
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
     out.println(xmlDocument.print());
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql	Mon Dec 14 02:42:20 2009 +0100
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql	Mon Dec 14 03:02:56 2009 +0100
@@ -298,11 +298,21 @@
    <SqlMethod name="selectYearsDouble" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
-        SELECT O.AD_ORG_ID AS PADRE, Y.C_YEAR_ID AS ID, Y.YEAR AS NAME
+        SELECT O.AD_ORG_ID AS PADRE, Y.C_YEAR_ID AS ID, Y.YEAR || ' (' || C.NAME || ')' AS NAME
         FROM C_YEAR Y, C_CALENDAR C, AD_ORG O
         WHERE C.C_CALENDAR_ID = Y.C_CALENDAR_ID
-          AND C.C_CALENDAR_ID=(SELECT AD_ORG.C_CALENDAR_ID FROM AD_ORG WHERE AD_ORG_GETCALENDAROWNER(O.AD_ORG_ID) = AD_ORG.AD_ORG_ID)
-        ORDER BY O.AD_ORG_ID, Y.YEAR
+          AND C.C_CALENDAR_ID IN (
+                                    SELECT ORG.C_CALENDAR_ID FROM AD_ORG ORG
+                                    WHERE AD_ISORGINCLUDED(O.AD_ORG_ID, ORG.AD_ORG_ID, '1') <> -1
+                                      AND ORG.C_CALENDAR_ID IS NOT NULL
+                                  UNION
+                                    SELECT ORG.C_CALENDAR_ID FROM AD_ORG ORG
+                                    WHERE AD_ISORGINCLUDED(ORG.AD_ORG_ID,O.AD_ORG_ID, '1') <> -1
+                                      AND ORG.C_CALENDAR_ID IS NOT NULL
+                                 )
+        ORDER BY O.NAME, Y.YEAR
         ]]></Sql>
+    <Parameter name="Client"  type="replace" optional="true"  after="WHERE AD_ISORGINCLUDED(O.AD_ORG_ID, ORG.AD_ORG_ID, " text="'1'"></Parameter>
+    <Parameter name="Client"  type="replace" optional="true"  after="WHERE AD_ISORGINCLUDED(ORG.AD_ORG_ID,O.AD_ORG_ID, " text="'1'"></Parameter>
    </SqlMethod>
 </SqlClass>