Related to issue 32535: Code review improvements
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Thu, 26 May 2016 20:02:26 +0200
changeset 29590 65a012587054
parent 29589 6b69927ae231
child 29591 020004e453ca
Related to issue 32535: Code review improvements

- Set login organization general ledger if report organization is empty in Balance Sheet and P&L structure report.
- Avoid change general ledger after click on search button in General Ledger Report, Journal Entries Report and Trial Balance reports.
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.html
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.java
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java
src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html
src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java	Thu May 26 15:55:44 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java	Thu May 26 20:02:26 2016 +0200
@@ -32,6 +32,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.lang.StringUtils;
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hibernate.criterion.Restrictions;
@@ -129,8 +130,10 @@
           strDateFromRef, strDateToRef, strAsDateTo, strAsDateToRef, strElementValue,
           strConImporte, strOrg, strLevel, strConCodigo, strcAcctSchemaId, strPageNo);
     } else if (vars.commandIn("LEDGER")) {
-      String strOrg = vars
-          .getGlobalVariable("inpOrganizacion", "GeneralAccountingReports|Org", "0");
+      String strOrg = vars.getStringParameter("inpOrganizacion");
+      if (StringUtils.isEmpty(strOrg)) {
+        strOrg = vars.getOrg();
+      }
       String strcAcctSchemaId = OBLedgerUtils.getOrgLedger(strOrg);
       response.setContentType("text/html; charset=UTF-8");
       PrintWriter out = response.getWriter();
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.html	Thu May 26 15:55:44 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.html	Thu May 26 20:02:26 2016 +0200
@@ -149,8 +149,6 @@
     updateMenuIcon('buttonMenu');
 
     setWindowElementFocus('firstElement');
-    setDefaultLedger();
-
   }
 
   function onResizeDo(){
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.java	Thu May 26 15:55:44 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.java	Thu May 26 20:02:26 2016 +0200
@@ -60,8 +60,8 @@
     VariablesSecureApp vars = new VariablesSecureApp(request);
 
     if (vars.commandIn("DEFAULT")) {
-      String strcAcctSchemaId = vars.getGlobalVariable("inpcAcctSchemaId",
-          "ReportGeneralLedger|cAcctSchemaId", "");
+      String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedger|Org", "0");
+      String strcAcctSchemaId = OBLedgerUtils.getOrgLedger(strOrg);
       String strDateFrom = vars
           .getGlobalVariable("inpDateFrom", "ReportGeneralLedger|DateFrom", "");
       String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportGeneralLedger|DateTo", "");
@@ -85,7 +85,6 @@
       strcelementvaluetodes = (strcelementvaluetodes.equals("null")) ? "" : strcelementvaluetodes;
       vars.setSessionValue("inpElementValueIdFrom_DES", strcelementvaluefromdes);
       vars.setSessionValue("inpElementValueIdTo_DES", strcelementvaluetodes);
-      String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedger|Org", "0");
       String strcBpartnerId = vars.getInGlobalVariable("inpcBPartnerId_IN",
           "ReportGeneralLedger|cBpartnerId", "", IsIDFilter.instance);
       String strmProductId = vars.getInGlobalVariable("inpmProductId_IN",
@@ -203,7 +202,7 @@
             strcProjectId, strGroupBy, strcAcctSchemaId, strShowOpenBalances);
       }
     } else if (vars.commandIn("LEDGER")) {
-      String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedger|Org", "0");
+      String strOrg = vars.getStringParameter("inpOrg");
       String strcAcctSchemaId = OBLedgerUtils.getOrgLedger(strOrg);
       response.setContentType("text/html; charset=UTF-8");
       PrintWriter out = response.getWriter();
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html	Thu May 26 15:55:44 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.html	Thu May 26 20:02:26 2016 +0200
@@ -316,7 +316,6 @@
         updateMenuIcon('buttonMenu');
 
         setWindowElementFocus('firstElement');
-        setDefaultLedger();
         displayDocumentNo();
         displayAdvancedFilters();
         selectDocument();
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java	Thu May 26 15:55:44 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedgerJournal.java	Thu May 26 20:02:26 2016 +0200
@@ -90,8 +90,8 @@
       log4j.debug("Command: " + vars.getStringParameter("Command"));
 
     if (vars.commandIn("DEFAULT")) {
-      String strcAcctSchemaId = vars.getGlobalVariable("inpcAcctSchemaId",
-          "ReportGeneralLedger|cAcctSchemaId", "");
+      String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
+      String strcAcctSchemaId = OBLedgerUtils.getOrgLedger(strOrg);
       String strDateFrom = vars.getGlobalVariable("inpDateFrom",
           "ReportGeneralLedgerJournal|DateFrom", "");
       String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportGeneralLedgerJournal|DateTo",
@@ -100,7 +100,6 @@
           "ReportGeneralLedgerJournal|Document", "");
       String strDocumentNo = vars.getGlobalVariable("inpDocumentNo",
           "ReportGeneralLedgerJournal|DocumentNo", "");
-      String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
       String strShowClosing = vars.getGlobalVariable("inpShowClosing",
           "ReportGeneralLedgerJournal|ShowClosing", "Y");
       String strShowReg = vars.getGlobalVariable("inpShowReg",
@@ -412,7 +411,7 @@
       out.println("objson = " + combobox);
       out.close();
     } else if (vars.commandIn("LEDGER")) {
-      String strOrg = vars.getGlobalVariable("inpOrg", "ReportGeneralLedgerJournal|Org", "0");
+      String strOrg = vars.getStringParameter("inpOrg");
       String strcAcctSchemaId = OBLedgerUtils.getOrgLedger(strOrg);
       response.setContentType("text/html; charset=UTF-8");
       PrintWriter out = response.getWriter();
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html	Thu May 26 15:55:44 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.html	Thu May 26 20:02:26 2016 +0200
@@ -299,7 +299,6 @@
   updateMenuIcon('buttonMenu');
 
   setWindowElementFocus('firstElement');
-  setDefaultLedger();
   displayAdvancedFilters();
 }
 
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java	Thu May 26 15:55:44 2016 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTrialBalance.java	Thu May 26 20:02:26 2016 +0200
@@ -64,12 +64,11 @@
     VariablesSecureApp vars = new VariablesSecureApp(request);
 
     if (vars.commandIn("DEFAULT")) {
-      String strcAcctSchemaId = vars.getGlobalVariable("inpcAcctSchemaId",
-          "ReportTrialBalance|cAcctSchemaId", "");
+      String strOrg = vars.getGlobalVariable("inpOrg", "ReportTrialBalance|Org", "");
+      String strcAcctSchemaId = OBLedgerUtils.getOrgLedger(strOrg);
       String strDateFrom = vars.getGlobalVariable("inpDateFrom", "ReportTrialBalance|DateFrom", "");
       String strDateTo = vars.getGlobalVariable("inpDateTo", "ReportTrialBalance|DateTo", "");
       String strPageNo = vars.getGlobalVariable("inpPageNo", "ReportTrialBalance|PageNo", "1");
-      String strOrg = vars.getGlobalVariable("inpOrg", "ReportTrialBalance|Org", "");
       String strLevel = vars.getGlobalVariable("inpLevel", "ReportTrialBalance|Level", "");
       String strcBpartnerId = vars.getInGlobalVariable("inpcBPartnerId_IN",
           "ReportTrialBalance|cBpartnerId", "", IsIDFilter.instance);
@@ -213,7 +212,7 @@
           strmProductId, strcProjectId, strcAcctSchemaId, strGroupBy, strAccountId,
           strNotInitialBalance);
     } else if (vars.commandIn("LEDGER")) {
-      String strOrg = vars.getGlobalVariable("inpOrg", "AgingInquiry|Org", "0");
+      String strOrg = vars.getStringParameter("inpOrg");
       String strcAcctSchemaId = OBLedgerUtils.getOrgLedger(strOrg);
       response.setContentType("text/html; charset=UTF-8");
       PrintWriter out = response.getWriter();