details:   https://code.openbravo.com/erp/devel/pi/rev/87c9f038283f
changeset: 29833:87c9f038283f
user:      Sanjota <sanjota.nelagi <at> promantia.com>
date:      Mon Jul 11 22:13:15 2016 +0200
summary:   Fixes issue 33460 : New field for comparing ref year in Balance 
sheet & PL rep.

New field "Compare To" created to have reference year as optional
Code reference from org.openbravo.report.improved.balancesheet module.

details:   https://code.openbravo.com/erp/devel/pi/rev/72acd4fea07e
changeset: 29834:72acd4fea07e
user:      Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
date:      Tue Aug 09 09:50:55 2016 +0200
summary:   Fixed issue 33460: code review improvements

Avoid NullPointerException in non-compartive mode
In JasperReport:
 * Band height for details restored to 15, so we have the same number of lines 
as before the change
 * Period N-1 label only shown in comparative mode

diffstat:

 src-db/database/sourcedata/AD_TEXTINTERFACES.xml                         |   
11 +
 src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html     |   
18 +-
 src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java     |   
89 +++++---
 src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml      |    
1 +
 src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReportsPDF.jrxml |  
102 ++++++---
 src/org/openbravo/erpCommon/businessUtility/AccountTree_data.xsql        |    
6 +-
 6 files changed, 155 insertions(+), 72 deletions(-)

diffs (truncated from 524 to 300 lines):

diff -r 6e46a5541bbd -r 72acd4fea07e 
src-db/database/sourcedata/AD_TEXTINTERFACES.xml
--- a/src-db/database/sourcedata/AD_TEXTINTERFACES.xml  Wed Aug 03 09:52:57 
2016 -0400
+++ b/src-db/database/sourcedata/AD_TEXTINTERFACES.xml  Tue Aug 09 09:50:55 
2016 +0200
@@ -14414,6 +14414,17 @@
 <!--4D6F7EFED00711DDBE8C001D09C4A2FE-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--4D6F7EFED00711DDBE8C001D09C4A2FE--></AD_TEXTINTERFACES>
 
+<!--4DE64DE174C34EA2AC63A7522575A600--><AD_TEXTINTERFACES>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  
<AD_TEXTINTERFACES_ID><![CDATA[4DE64DE174C34EA2AC63A7522575A600]]></AD_TEXTINTERFACES_ID>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  <TEXT><![CDATA[Compare To]]></TEXT>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  
<FILENAME><![CDATA[/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html]]></FILENAME>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  <ISUSED><![CDATA[Y]]></ISUSED>
+<!--4DE64DE174C34EA2AC63A7522575A600-->  
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--4DE64DE174C34EA2AC63A7522575A600--></AD_TEXTINTERFACES>
+
 <!--4E80DAAC37BB49D09A8EF2737160FEF5--><AD_TEXTINTERFACES>
 <!--4E80DAAC37BB49D09A8EF2737160FEF5-->  
<AD_TEXTINTERFACES_ID><![CDATA[4E80DAAC37BB49D09A8EF2737160FEF5]]></AD_TEXTINTERFACES_ID>
 <!--4E80DAAC37BB49D09A8EF2737160FEF5-->  
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 6e46a5541bbd -r 72acd4fea07e 
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html      
Wed Aug 03 09:52:57 2016 -0400
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html      
Tue Aug 09 09:50:55 2016 +0200
@@ -85,7 +85,7 @@
                setWindowElementFocus(frm.inpAgno);
                showJSMessage(7);
                return false;
-       } else if (frm.inpAgnoRef.value == null || frm.inpAgnoRef.value == "") {
+       } else if (frm.inpCompareTo.checked && (frm.inpAgnoRef.value == null || 
frm.inpAgnoRef.value == "")) {
                setWindowElementFocus(frm.inpAgnoRef);
                showJSMessage(7);
                return false;
@@ -171,6 +171,13 @@
     }
 }
 
+function onClickCompare() {
+       if(document.frmMain.inpCompareTo.checked)
+               displayLogicElement('trReferenceDetails', true);
+       else
+               displayLogicElement('trReferenceDetails', false);
+}
+
 function onloadFunctions() {
 }
 </script>
@@ -490,8 +497,15 @@
                     </TABLE>
                   </TD>
                 </tr>
+                
+                <!-- Improved Balance Sheet -->
+                <tr>
+                  <td class="TitleCell"><span class="LabelText">Compare 
To</span></td>
+                  <td class="Radio_Check_ContentCell"><input 
name="inpCompareTo" type="checkbox" id="fieldCompareTo" value="Y" 
onclick="onClickCompare();"></input></td>
+                </tr>
+                <!-- Improved Balance Sheet -->
 
-                <tr>
+                <tr id="trReferenceDetails">
                 <td class="TitleCell"><span class="LabelText">Reference 
Year</span></td>
                   <td class="Combo_ContentCell"> <SELECT name="inpAgnoRef" 
id="paramAgnoRef" class="ComboKey Combo_OneCell_width" 
onchange="displayLogic(); return true;">
                       <OPTION value=""></OPTION>
diff -r 6e46a5541bbd -r 72acd4fea07e 
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java      
Wed Aug 03 09:52:57 2016 -0400
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java      
Tue Aug 09 09:50:55 2016 +0200
@@ -94,14 +94,19 @@
           "GeneralAccountingReports|conImporte", "N");
       String strConCodigo = vars.getGlobalVariable("inpConCodigo",
           "GeneralAccountingReports|conCodigo", "N");
+      /* Improved Balance Sheet */
+      String strCompareTo = vars.getGlobalVariable("inpCompareTo",
+          "GeneralAccountingReports|compareTo", "Y");
+
       String strLevel = vars.getGlobalVariable("inpLevel", 
"GeneralAccountingReports|level", "");
       printPageDataSheet(response, vars, "", "", strDateFrom, strDateTo, 
strPageNo, strDateFromRef,
           strDateToRef, strAsDateTo, strAsDateToRef, strElementValue, 
strConImporte, "", strLevel,
-          strConCodigo, "");
+          strConCodigo, "", strCompareTo);
     } else if (vars.commandIn("FIND")) {
       String strcAcctSchemaId = vars.getStringParameter("inpcAcctSchemaId", 
"");
       String strAgno = vars.getRequiredGlobalVariable("inpAgno", 
"GeneralAccountingReports|agno");
-      String strAgnoRef = vars.getRequiredGlobalVariable("inpAgnoRef",
+      /* Improved Balance Sheet */
+      String strAgnoRef = vars.getRequestGlobalVariable("inpAgnoRef",
           "GeneralAccountingReports|agnoRef");
       String strDateFrom = vars.getRequestGlobalVariable("inpDateFrom",
           "GeneralAccountingReports|dateFrom");
@@ -123,12 +128,15 @@
           "GeneralAccountingReports|conImporte");
       String strConCodigo = vars.getRequestGlobalVariable("inpConCodigo",
           "GeneralAccountingReports|conCodigo");
+      /* Improved Balance Sheet */
+      String strCompareTo = vars.getRequestGlobalVariable("inpCompareTo",
+          "GeneralAccountingReports|compareTo");
       String strOrg = vars.getRequestGlobalVariable("inpOrganizacion",
           "GeneralAccountingReports|organizacion");
       String strLevel = vars.getRequestGlobalVariable("inpLevel", 
"GeneralAccountingReports|level");
       printPagePDF(request, response, vars, strAgno, strAgnoRef, strDateFrom, 
strDateTo,
           strDateFromRef, strDateToRef, strAsDateTo, strAsDateToRef, 
strElementValue,
-          strConImporte, strOrg, strLevel, strConCodigo, strcAcctSchemaId, 
strPageNo);
+          strConImporte, strOrg, strLevel, strConCodigo, strcAcctSchemaId, 
strPageNo, strCompareTo);
     } else if (vars.commandIn("LEDGER")) {
       String strOrg = vars.getStringParameter("inpOrganizacion");
       if (StringUtils.isEmpty(strOrg)) {
@@ -150,8 +158,8 @@
       VariablesSecureApp vars, String strYearId, String strYearRefId, String 
strDateFrom,
       String strDateTo, String strDateFromRef, String strDateToRef, String 
strAsDateTo,
       String strAsDateToRef, String strElementValue, String strConImporte, 
String strOrg,
-      String strLevel, String strConCodigo, String strcAcctSchemaId, String 
strPageNo)
-      throws IOException, ServletException {
+      String strLevel, String strConCodigo, String strcAcctSchemaId, String 
strPageNo,
+      String strCompareTo) throws IOException, ServletException {
     String localStrElementValue = strElementValue;
     String localStrDateToRef = strDateToRef;
     String localStrDateFrom = strDateFrom;
@@ -201,7 +209,13 @@
         Year year = OBDal.getInstance().get(Year.class, strYearId);
         Year yearRef = OBDal.getInstance().get(Year.class, strYearRefId);
         HashMap<String, Date> startingEndingDate = getStartingEndingDate(year);
-        HashMap<String, Date> startingEndingDateRef = 
getStartingEndingDate(yearRef);
+        /* Improved Balance Sheet */
+        String yrRef = "";
+        HashMap<String, Date> startingEndingDateRef = null;
+        if (strCompareTo.equals("Y")) {
+          yrRef = yearRef.getFiscalYear();
+          startingEndingDateRef = getStartingEndingDate(yearRef);
+        }
         // Years to be included as no closing is present
         String strYearsToClose = "";
         String strYearsToCloseRef = "";
@@ -219,13 +233,16 @@
             strCalculateOpening = "Y";
             strYearsToClose = "," + strYearsToClose;
           }
-          yearsInfo = 
getYearsToClose(startingEndingDateRef.get("startingDate"), strOrg,
-              yearRef.getCalendar(), strcAcctSchemaId, true);
-          strYearsToCloseRef = yearsInfo[0];
-          openingEntryOwnerRef = yearsInfo[1];
-          if (strYearsToCloseRef.length() > 0) {
-            strCalculateOpening = "Y";
-            strYearsToCloseRef = "," + strYearsToCloseRef;
+          /* Improved Balance Sheet */
+          if (strCompareTo.equals("Y")) {
+            yearsInfo = 
getYearsToClose(startingEndingDateRef.get("startingDate"), strOrg,
+                yearRef.getCalendar(), strcAcctSchemaId, true);
+            strYearsToCloseRef = yearsInfo[0];
+            openingEntryOwnerRef = yearsInfo[1];
+            if (strYearsToCloseRef.length() > 0) {
+              strCalculateOpening = "Y";
+              strYearsToCloseRef = "," + strYearsToCloseRef;
+            }
           }
         }
         // Income summary amount is calculated and included in the balance 
sheet data
@@ -246,9 +263,9 @@
               Utility.getContext(this, vars, "#User_Client", 
"GeneralAccountingReports"),
               localStrDateFrom, DateTimeData.nDaysAfter(this, localStrDateTo, 
"1"),
               strcAcctSchemaId, Tree.getMembers(this, strTreeOrg, strOrg),
-              "'" + year.getFiscalYear() + "'" + strYearsToClose, 
openingEntryOwner,
+              "'" + year.getFiscalYear() + "'" + strYearsToClose, 
openingEntryOwner, strCompareTo,
               localStrDateFromRef, DateTimeData.nDaysAfter(this, 
localStrDateToRef, "1"), "'"
-                  + yearRef.getFiscalYear() + "'" + strYearsToCloseRef, 
openingEntryOwnerRef);
+                  + yrRef + "'" + strYearsToCloseRef, openingEntryOwnerRef);
           {
             if (log4j.isDebugEnabled())
               log4j.debug("*********** strIncomeSummaryAccount: " + 
strIncomeSummaryAccount);
@@ -257,12 +274,16 @@
                     + "'" + strYearsToClose, strTreeOrg, strOrg, 
strcAcctSchemaId);
             if (log4j.isDebugEnabled())
               log4j.debug("*********** strISyear: " + strISyear);
-            String strISyearRef = processIncomeSummary(localStrDateFromRef,
-                DateTimeData.nDaysAfter(this, localStrDateToRef, "1"),
-                "'" + yearRef.getFiscalYear() + "'" + strYearsToCloseRef, 
strTreeOrg, strOrg,
-                strcAcctSchemaId);
-            if (log4j.isDebugEnabled())
-              log4j.debug("*********** strISyearRef: " + strISyearRef);
+            /* Improved Balance Sheet */
+            String strISyearRef = "0";
+            if (strCompareTo.equals("Y")) {
+              strISyearRef = processIncomeSummary(localStrDateFromRef,
+                  DateTimeData.nDaysAfter(this, localStrDateToRef, "1"),
+                  "'" + yearRef.getFiscalYear() + "'" + strYearsToCloseRef, 
strTreeOrg, strOrg,
+                  strcAcctSchemaId);
+              if (log4j.isDebugEnabled())
+                log4j.debug("*********** strISyearRef: " + strISyearRef);
+            }
             accounts = appendRecords(accounts, strIncomeSummaryAccount, 
strISyear, strISyearRef);
 
           }
@@ -282,12 +303,12 @@
         parameters.put("group", strGroups);
         parameters.put("agno", year.getFiscalYear());
 
-        parameters.put("agno2", yearRef.getFiscalYear());
+        parameters.put("agno2", yrRef);
         parameters.put("column", year.getFiscalYear());
-        parameters.put("columnRef", yearRef.getFiscalYear());
+        parameters.put("columnRef", yrRef);
         parameters.put("org", OrganizationData.selectOrgName(this, strOrg));
         parameters.put("column1", year.getFiscalYear());
-        parameters.put("columnRef1", yearRef.getFiscalYear());
+        parameters.put("columnRef1", yrRef);
         parameters.put("companyName",
             GeneralAccountingReportsData.companyName(this, vars.getClient()));
         parameters.put("date", DateTimeData.today(this));
@@ -295,15 +316,18 @@
           localStrDateFrom = 
OBDateUtils.formatDate(startingEndingDate.get("startingDate"));
         if (localStrDateTo.equals(""))
           localStrDateTo = 
OBDateUtils.formatDate(startingEndingDate.get("endingDate"));
-        if (localStrDateFromRef.equals(""))
-          localStrDateFromRef = 
OBDateUtils.formatDate(startingEndingDateRef.get("startingDate"));
-        if (localStrDateToRef.equals(""))
-          localStrDateToRef = 
OBDateUtils.formatDate(startingEndingDateRef.get("endingDate"));
+        /* Improved Balance Sheet */
+        if (strCompareTo.equals("Y")) {
+          if (localStrDateFromRef.equals(""))
+            localStrDateFromRef = 
OBDateUtils.formatDate(startingEndingDateRef.get("startingDate"));
+          if (localStrDateToRef.equals(""))
+            localStrDateToRef = 
OBDateUtils.formatDate(startingEndingDateRef.get("endingDate"));
+        }
         parameters.put("period", localStrDateFrom + " - " + localStrDateTo);
         parameters.put("periodRef", localStrDateFromRef + " - " + 
localStrDateToRef);
         parameters.put("agnoInitial", year.getFiscalYear());
-        parameters.put("agnoRef", yearRef.getFiscalYear());
-
+        parameters.put("agnoRef", yrRef);
+        parameters.put("compareTo", (strCompareTo.equals("Y") ? "Y" : "N"));
         parameters.put(
             "principalTitle",
             strCalculateOpening.equals("Y") ? 
GeneralAccountingReportsData.rptTitle(this,
@@ -486,7 +510,8 @@
       String strAgno, String strAgnoRef, String strDateFrom, String strDateTo, 
String strPageNo,
       String strDateFromRef, String strDateToRef, String strAsDateTo, String 
strAsDateToRef,
       String strElementValue, String strConImporte, String strOrg, String 
strLevel,
-      String strConCodigo, String strcAcctSchemaId) throws IOException, 
ServletException {
+      String strConCodigo, String strcAcctSchemaId, String strCompareTo) 
throws IOException,
+      ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: dataSheet");
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
@@ -549,6 +574,8 @@
     xmlDocument.setParameter("asDateToRefsaveFormat", 
vars.getSessionValue("#AD_SqlDateFormat"));
     xmlDocument.setParameter("conImporte", strConImporte);
     xmlDocument.setParameter("conCodigo", strConCodigo);
+    /* Improved Balance Sheet */
+    xmlDocument.setParameter("compareTo", strCompareTo);
     xmlDocument.setParameter("C_Org_ID", strOrg);
     xmlDocument.setParameter("C_ElementValue_ID", strElementValue);
     xmlDocument.setParameter("level", strLevel);
diff -r 6e46a5541bbd -r 72acd4fea07e 
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml       
Wed Aug 03 09:52:57 2016 -0400
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml       
Tue Aug 09 09:50:55 2016 +0200
@@ -46,6 +46,7 @@
   <PARAMETER id="fieldCheck" name="check" default="Y"/>
   <PARAMETER id="fieldConImporte" name="conImporte" boolean="checked" 
withId="fieldCheck"/>
   <PARAMETER id="fieldConCodigo" name="conCodigo" boolean="checked" 
withId="fieldCheck"/>
+  <PARAMETER id="fieldCompareTo" name="compareTo" boolean="checked" 
withId="fieldCheck"/>
   <PARAMETER id="fieldC_ElementValue_ID" name="C_ElementValue_ID"/>
   <PARAMETER id="fieldC_Org_ID" name="C_Org_ID"/>
   <PARAMETER id="paramLevel" name="level"/>
diff -r 6e46a5541bbd -r 72acd4fea07e 
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReportsPDF.jrxml
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReportsPDF.jrxml  
Wed Aug 03 09:52:57 2016 -0400
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReportsPDF.jrxml  
Tue Aug 09 09:50:55 2016 +0200
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports 
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"; 
name="GeneralAccountingReportsPDF" pageWidth="595" pageHeight="842" 
columnWidth="535" leftMargin="30" rightMargin="30" topMargin="20" 
bottomMargin="20" uuid="1de34766-77d8-4a3a-9223-88d6ac76dcb9">
+<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports 
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"; 
name="GeneralAccountingReportsPDF" pageWidth="595" pageHeight="842" 
columnWidth="535" leftMargin="30" rightMargin="30" topMargin="20" 
bottomMargin="20">
        <property name="ireport.scriptlethandling" value="0"/>
        <property name="ireport.encoding" value="UTF-8"/>
-       <property name="ireport.zoom" value="1.5"/>
-       <property name="ireport.x" value="0"/>
+       <property name="ireport.zoom" value="1.6500000000000001"/>
+       <property name="ireport.x" value="277"/>
        <property name="ireport.y" value="0"/>
        <import value="net.sf.jasperreports.engine.*"/>
        <import value="java.util.*"/>
@@ -46,6 +46,9 @@
        <parameter name="agnoRef" class="java.lang.String"/>
        <parameter name="principalTitle" class="java.lang.String"/>
        <parameter name="pageNo" class="java.lang.String"/>
+       <parameter name="compareTo" class="java.lang.String">
+               <defaultValueExpression><![CDATA[]]></defaultValueExpression>
+       </parameter>
        <queryString>
                <![CDATA[]]>
        </queryString>
@@ -73,17 +76,17 @@
        <pageHeader>
                <band height="121" splitType="Stretch">
                        <textField>
-                               <reportElement key="staticText-15" x="0" y="0" 
width="535" height="18" uuid="793d4469-26a6-483e-ab31-d93d39e76902"/>
+                               <reportElement key="staticText-15" x="0" y="0" 
width="535" height="18"/>
                                <textElement textAlignment="Center" 
markup="none">
                                        <font fontName="DejaVu Sans" size="12" 
isBold="true" pdfFontName="Helvetica-Bold"/>
                                </textElement>
-                               
<textFieldExpression><![CDATA[$P{principalTitle}]]></textFieldExpression>
+                               <textFieldExpression 
class="java.lang.String"><![CDATA[$P{principalTitle}]]></textFieldExpression>
                        </textField>

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to