Fixes issue 0017787: report trial balance, other accounts are displayed when
authorJon Alegría <jon.alegria@openbravo.com>
Thu, 21 Jul 2011 20:27:59 +0200
changeset 13243 01bcb64861bd
parent 13242 4675b0e190f7
child 13244 b5840ad5e283
Fixes issue 0017787: report trial balance, other accounts are displayed when
the level account selected is "subaccount"
src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java
src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance_data.xsql
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java	Thu Jul 21 20:12:26 2011 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java	Thu Jul 21 20:27:59 2011 +0200
@@ -121,8 +121,8 @@
           "ReportTrialBalance|C_ElementValue_IDFROM");
       String strcElementValueTo = vars.getRequestGlobalVariable("inpcElementValueIdTo",
           "ReportTrialBalance|C_ElementValue_IDTO");
-      String strNotInitialBalance = vars.getRequestGlobalVariable("inpNotInitialBalance",
-          "ReportTrialBalance|notInitialBalance");
+      String strNotInitialBalance = vars.getStringParameter("inpNotInitialBalance", "N");
+      vars.setSessionValue("ReportTrialBalance|notInitialBalance", strNotInitialBalance);
       String strcElementValueFromDes = "", strcElementValueToDes = "";
       if (!strcElementValueFrom.equals(""))
         strcElementValueFromDes = ReportTrialBalanceData.selectSubaccountDescription(this,
@@ -167,8 +167,8 @@
           "ReportTrialBalance|cProjectId", "", IsIDFilter.instance);
       String strGroupBy = vars.getRequestGlobalVariable("inpGroupBy", "ReportTrialBalance|GroupBy");
       String strPageNo = vars.getRequestGlobalVariable("inpPageNo", "ReportTrialBalance|PageNo");
-      String strNotInitialBalance = vars.getRequestGlobalVariable("inpNotInitialBalance",
-          "ReportTrialBalance|notInitialBalance");
+      String strNotInitialBalance = vars.getStringParameter("inpNotInitialBalance", "N");
+      vars.setSessionValue("ReportTrialBalance|notInitialBalance", strNotInitialBalance);
       if (vars.commandIn("PDF"))
         printPageDataPDF(request, response, vars, strDateFrom, strDateTo, strOrg, strLevel,
             strcElementValueFrom, strcElementValueFromDes, strcElementValueTo,
@@ -195,8 +195,8 @@
       String strcProjectId = vars.getInGlobalVariable("inpcProjectId_IN",
           "ReportTrialBalance|cProjectId", "", IsIDFilter.instance);
       String strGroupBy = vars.getRequestGlobalVariable("inpGroupBy", "ReportTrialBalance|GroupBy");
-      String strNotInitialBalance = vars.getRequestGlobalVariable("inpNotInitialBalance",
-          "ReportTrialBalance|notInitialBalance");
+      String strNotInitialBalance = vars.getStringParameter("inpNotInitialBalance", "N");
+      vars.setSessionValue("ReportTrialBalance|notInitialBalance", strNotInitialBalance);
 
       printPageOpen(response, vars, strDateFrom, strDateTo, strOrg, strLevel, strcBpartnerId,
           strmProductId, strcProjectId, strcAcctSchemaId, strGroupBy, strAccountId,
@@ -626,7 +626,9 @@
         DateTimeData.nDaysAfter(this, strDateTo, "1"), "", "");
     ReportTrialBalanceData[] dataInitialBalance = ReportTrialBalanceData.selectInitialBalance(this,
         strDateFrom, strcAcctSchemaId, "", "", "", strOrgFamily,
-        Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"));
+        Utility.getContext(this, vars, "#User_Client", "ReportTrialBalance"), 
+	strNotInitialBalance.equals("Y") ? "initial" : "notinitial", 
+	strNotInitialBalance.equals("Y") ? "initial" : "notinitial");
 
     log4j.debug("Calculating tree...");
     dataAux = calculateTree(dataAux, null, new Vector<Object>(), dataInitialBalance,
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance_data.xsql	Thu Jul 21 20:12:26 2011 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance_data.xsql	Thu Jul 21 20:27:59 2011 +0200
@@ -416,7 +416,7 @@
                    AND  F.AD_ORG_ID IN ('1')
                    AND  F.AD_CLIENT_ID IN ('1')
                    AND F.ISACTIVE = 'Y'
-                   AND F.FACTACCTTYPE <> 'O')) A
+		   AND 3=3)) A
       GROUP BY ACCOUNT_ID
       HAVING SUM(AMTACCTDR) - SUM(AMTACCTCR) <> 0
       ORDER BY ACCOUNT_ID
@@ -436,6 +436,8 @@
       <Parameter name="project" optional="true" type="argument" after="2=2"><![CDATA[ AND F.C_PROJECT_ID IN]]></Parameter>
       <Parameter name="orgFamily" type="replace" optional="true" after="AND  F.AD_ORG_ID IN (" text="'1'"/>
       <Parameter name="clientFamily" type="replace" optional="true" after="AND  F.AD_CLIENT_ID IN (" text="'1'"/>
+      <Parameter name="initial" type="none" optional="true" after="AND 3=3"><![CDATA[ AND F.FACTACCTTYPE = 'O']]></Parameter>
+      <Parameter name="notinitial" type="none" optional="true" after="AND 3=3"><![CDATA[ AND F.FACTACCTTYPE <> 'O']]></Parameter>
   </SqlMethod>
   
   <SqlMethod name="treeAccount" type="preparedStatement" return="string">