details:   http://code.openbravo.com/erp/devel/pi/rev/728fad6fb913
changeset: 3511:728fad6fb913
user:      David Alsasua <david.alsasua <at> openbravo.com>
date:      Fri Apr 03 18:03:30 2009 +0200
summary:   Fixes Bug 7074: General Ledger in Exel does not work in 2.40. Fixes 
Bug 7728: General Ledger Report shows SALDO instead of Initial and Final

diffstat:

 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.html            |   
 41 +-
 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.java            |   
 85 +-
 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.jrxml           |  
1605 ++++-----
 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.xml             |   
 18 +-
 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger_Previous.jasper |   
    
 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger_Previous.jrxml  |   
606 +-
 src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger_data.xsql       |   
  3 +-
 7 files changed, 1109 insertions(+), 1249 deletions(-)

diffs (truncated from 2890 to 300 lines):

diff -r 2e9ceab69a93 -r 728fad6fb913 
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.html
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.html   Fri Apr 
03 16:50:35 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.html   Fri Apr 
03 18:03:30 2009 +0200
@@ -531,7 +531,15 @@
                       <th width="75%" 
class="DataGrid_Header_Cell">DESCRIPTION</th>
                     </tr>
 
-                    <div id="reportTotals"></div>
+                    <div id="sectionDetailTotals">
+                      <tr class="DataGrid_Body_Row">
+                        <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold">PREVIOUS</span></th>
+                        <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="fieldSubreportPreviousDebit"></span></th>
+                        <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="fieldSubreportPreviousCredit"></span></th>
+                        <th width="15%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="fieldSubreportPreviousTotal"></span></th>
+                        <th width="75%" 
class="DataGrid_Header_Cell_Amount"></th>
+                      </tr>
+                    </div>
                     <div id="sectionDetail"> 
                       <tr class="DataGrid_Body_Row DataGrid_Body_Row_yy" 
id="funcEvenOddRow1xx"> 
                         <td width="10%" class="DataGrid_Body_Cell">
@@ -565,7 +573,15 @@
                         </th>
                         <th width="75%" 
class="DataGrid_Header_Cell">&nbsp;</td>
                       </tr>
-                      <div id="reportAll"></div>
+                      <div id="sectionDetailTotals">
+                        <tr class="DataGrid_Body_Row">
+                          <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold">TOTAL</span></th>
+                          <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="totalDebit"></span></th>
+                          <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="totalCredit"></span></th>
+                          <th width="15%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="totalTotal"></span></th>
+                          <th width="75%" 
class="DataGrid_Header_Cell_Amount"></th>
+                        </tr>
+                      </div>
                     </tr>
                   </table>
                   <div style="height:15px;" />
@@ -591,7 +607,15 @@
                         <th width="75%" 
class="DataGrid_Header_Cell">DESCRIPTION</th>
                       </tr>
 
-                      <div id="reportTotals2"></div>
+                    <div id="sectionDetailTotals">
+                      <tr class="DataGrid_Body_Row">
+                        <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold">SALDO 
ANTERIOR</span></th>
+                        <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="fieldSubreportPreviousDebit2"></span></th>
+                        <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="fieldSubreportPreviousCredit2"></span></th>
+                        <th width="15%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="fieldSubreportPreviousTotal2"></span></th>
+                        <th width="75%" 
class="DataGrid_Header_Cell_Amount"></th>
+                      </tr>
+                    </div>
                       <div id="sectionDetail2"> 
                         <tr class="DataGrid_Body_Row DataGrid_Body_Row_yy" 
id="funcEvenOddRow2xx"> 
                           <td width="10%" class="DataGrid_Body_Cell">
@@ -622,8 +646,15 @@
                                                <TH width="15%" 
class="DataGrid_Header_Cell_Amount"><SPAN 
id="fieldTotalSubAdded2">xx1000.00</SPAN></TH>
                                                <TH width="75%" 
class="DataGrid_Header_Cell_Amount">&nbsp;</TD>
                       </tr>
-                      <div id="reportAll2"></div>
-                    </div>
+                      <div id="sectionDetailTotals">
+                        <tr class="DataGrid_Body_Row">
+                          <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold">SUMA Y SIGUE</span></th>
+                          <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="totalDebit2"></span></th>
+                          <th width="10%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="totalCredit2"></span></th>
+                          <th width="15%" 
class="DataGrid_Header_Cell_Amount"><span class="Bold" 
id="totalTotal2"></span></th>
+                          <th width="75%" 
class="DataGrid_Header_Cell_Amount"></th>
+                        </tr>
+                      </div>                    </div>
                   </table>
                   <div style="height:15px;" />
                 </div>
diff -r 2e9ceab69a93 -r 728fad6fb913 
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.java
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.java   Fri Apr 
03 16:50:35 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.java   Fri Apr 
03 18:03:30 2009 +0200
@@ -22,6 +22,7 @@
 import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 
@@ -180,8 +181,6 @@
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
     XmlDocument xmlDocument = null;
-    ReportGeneralLedgerData[][] subreport = null;
-    ReportGeneralLedgerData[][] subreport2 = null;
     ReportGeneralLedgerData[] data = null;
     String strTreeOrg = ReportTrialBalanceData.treeOrg(this, vars.getClient());
     String strTreeAccount = ReportTrialBalanceData.treeAccount(this, 
vars.getClient());
@@ -290,9 +289,9 @@
                   : "partner");
       }
       // Now dataTotal is covered until the first record to show in this 
screen, so previous amounts
-      // are calculated accurately
+      // are calculated accurately, and saved in previousDebit and 
previousCredit variables.
       String strOld = "";
-      for (int i = 0; data != null && i < dataTotal.length; i++) {
+      for (int i = 0; i < data.length && i < dataTotal.length; i++) {
         if (dataTotal[i].factAcctId.equals(data[0].factAcctId)) {
           if (!strOld.equals(((strcBpartnerId.equals("") && strAll.equals("")) 
? ""
               : dataTotal[i].cBpartnerId)
@@ -312,48 +311,67 @@
         previousCredit = previousCredit.add(new 
BigDecimal(dataTotal[i].amtacctcr));
         strOld = (((strcBpartnerId.equals("") && strAll.equals("")) ? "" : 
dataTotal[i].cBpartnerId) + dataTotal[i].id);
       }
-      // And previous amounts (until DateFrom) is calculated through
+
+      // And previous amounts (until DateFrom) are calculated through
       // ReportGeneralLedgerData.selectPrevious and, if necessary, amounts of 
previous screen are
       // added
-      subreport = new ReportGeneralLedgerData[data.length][];
+      ArrayList<Object> list = new ArrayList<Object>();
       strOld = "";
       int j = 0;
+      ReportGeneralLedgerData[] subreportElement = new 
ReportGeneralLedgerData[1];
       for (int i = 0; data != null && i < data.length; i++) {
         if (!strOld.equals(((strcBpartnerId.equals("") && strAll.equals("")) ? 
""
             : data[i].cBpartnerId)
             + data[i].id)) {
+          subreportElement = new ReportGeneralLedgerData[1];
           if (i == 0) {
-            subreport[j] = new ReportGeneralLedgerData[1];
-            subreport[j][0] = new ReportGeneralLedgerData();
-            subreport[j][0].totaldr = previousDebit.toPlainString();
-            subreport[j][0].totalcr = previousCredit.toPlainString();
-            subreport[j][0].total = 
previousDebit.subtract(previousCredit).toPlainString();
+            subreportElement = new ReportGeneralLedgerData[1];
+            subreportElement[0] = new ReportGeneralLedgerData();
+            subreportElement[0].totaldr = previousDebit.toPlainString();
+            subreportElement[0].totalcr = previousCredit.toPlainString();
+            subreportElement[0].total = 
previousDebit.subtract(previousCredit).toPlainString();
           } else
-            subreport[j] = ReportGeneralLedgerData.selectPrevious(this,
-                (strcBpartnerId.equals("") && strAll.equals("")) ? "" : 
data[i].cBpartnerId,
-                strcAcctSchemaId, data[i].id, strYearInitialDate, strDateFrom, 
strOrgFamily);
-          data[i].totalacctdr = subreport[j][0].totaldr;
-          data[i].totalacctcr = subreport[j][0].totalcr;
-          data[i].totalacctsub = subreport[j][0].total;
+            subreportElement = ReportGeneralLedgerData.selectPrevious(this, 
(strcBpartnerId
+                .equals("") && strAll.equals("")) ? "" : data[i].cBpartnerId, 
strcAcctSchemaId,
+                data[i].id, strYearInitialDate, strDateFrom, strOrgFamily);
+          data[i].totalacctdr = subreportElement[0].totaldr;
+          data[i].totalacctcr = subreportElement[0].totalcr;
+          data[i].totalacctsub = subreportElement[0].total;
+          list.add(subreportElement);
           j++;
         }
+        data[i].previousdebit = subreportElement[0].totaldr;
+        data[i].previouscredit = subreportElement[0].totalcr;
+        data[i].previoustotal = subreportElement[0].total;
         strOld = (((strcBpartnerId.equals("") && strAll.equals("")) ? "" : 
data[i].cBpartnerId) + data[i].id);
       }
-      subreport2 = new ReportGeneralLedgerData[data.length][];
+      /*
+       * subreport = new ReportGeneralLedgerData[j][]; list.toArray(subreport);
+       */
+      list = new ArrayList<Object>();
       String strTotal = "";
       int g = 0;
-      for (int i = 0; data != null && i < data.length; i++) {
+      subreportElement = new ReportGeneralLedgerData[1];
+      for (int i = 0; i < dataTotal.length && i < data.length; i++) {
         if (!strTotal.equals(((strcBpartnerId.equals("") && strAll.equals("")) 
? ""
             : data[i].cBpartnerId)
             + data[i].id)) {
-          subreport2[g] = ReportGeneralLedgerData.selectTotal(this,
+          subreportElement = new ReportGeneralLedgerData[1];
+          subreportElement = ReportGeneralLedgerData.selectTotal(this,
               (strcBpartnerId.equals("") && strAll.equals("")) ? "" : 
data[i].cBpartnerId,
               strcAcctSchemaId, data[i].id, strYearInitialDate, 
DateTimeData.nDaysAfter(this,
                   strDateTo, "1"), strOrgFamily);
           g++;
         }
+        data[i].finaldebit = subreportElement[0].totaldr;
+        data[i].finalcredit = subreportElement[0].totalcr;
+        data[i].finaltotal = subreportElement[0].total;
         strTotal = (((strcBpartnerId.equals("") && strAll.equals("")) ? "" : 
data[i].cBpartnerId) + data[i].id);
       }
+      /*
+       * subreport2 = new ReportGeneralLedgerData[g][]; 
list.toArray(subreport2);
+       */
+
       boolean hasPrevious = !(data == null || data.length == 0 || 
initRecordNumber <= 1);
       boolean hasNext = !(data == null || data.length == 0 || data.length < 
intRecordRange);
       toolbar
@@ -442,14 +460,14 @@
       xmlDocument.setData("structure1", data);
     else
       xmlDocument.setData("structure2", data);
-    if (strcBpartnerId.equals("") && strAll.equals(""))
-      xmlDocument.setDataArray("reportTotals", "structure", subreport);
-    else
-      xmlDocument.setDataArray("reportTotals2", "structure", subreport);
-    if (strcBpartnerId.equals("") && strAll.equals(""))
-      xmlDocument.setDataArray("reportAll", "structure", subreport2);
-    else
-      xmlDocument.setDataArray("reportAll2", "structure", subreport2);
+
+    /*
+     * if (strcBpartnerId.equals("") && strAll.equals("")) 
xmlDocument.setDataArray("reportTotals",
+     * "structure", subreport); else xmlDocument.setDataArray("reportTotals2", 
"structure",
+     * subreport); if (strcBpartnerId.equals("") && strAll.equals(""))
+     * xmlDocument.setDataArray("reportAll", "structure", subreport2); else
+     * xmlDocument.setDataArray("reportAll2", "structure", subreport2);
+     */
 
     out.println(xmlDocument.print());
     out.close();
@@ -461,6 +479,7 @@
       String strHide, String strcAcctSchemaId) throws IOException, 
ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: PDF");
+    response.setContentType("text/html; charset=UTF-8");
     ReportGeneralLedgerData[] data = null;
     ReportGeneralLedgerData[] subreport = null;
     String strTreeOrg = ReportTrialBalanceData.treeOrg(this, vars.getClient());
@@ -539,6 +558,8 @@
 
     String strOutput = vars.commandIn("PDF") ? "pdf" : "xls";
     String strReportName = 
"@basedesign@/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.jrxml";
+    if (strOutput.equals("pdf"))
+      response.setHeader("Content-disposition", "inline; 
filename=ReportGeneralLedgerPDF.pdf");
 
     HashMap<String, Object> parameters = new HashMap<String, Object>();
 
@@ -572,16 +593,16 @@
     parameters.put("InitialYearDate", date);
     Date dateTo = null;
     try {
-        dateTo = dateFormat.parse(strDateTo);
+      dateTo = dateFormat.parse(strDateTo);
     } catch (Exception e) {
-        throw new ServletException(e.getMessage());
+      throw new ServletException(e.getMessage());
     }
     parameters.put("DateTo", dateTo);
     Date dateFrom = null;
     try {
-        dateFrom = dateFormat.parse(strDateFrom);
+      dateFrom = dateFormat.parse(strDateFrom);
     } catch (Exception e) {
-        throw new ServletException(e.getMessage());
+      throw new ServletException(e.getMessage());
     }
     parameters.put("DateFrom", dateFrom);
 
diff -r 2e9ceab69a93 -r 728fad6fb913 
src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.jrxml
--- a/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.jrxml  Fri Apr 
03 16:50:35 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportGeneralLedger.jrxml  Fri Apr 
03 18:03:30 2009 +0200
@@ -1,232 +1,223 @@
-<?xml version="1.0" encoding="UTF-8"  ?>
-<!-- Created with iReport - A designer for JasperReports -->
-<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" 
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd";>
-<jasperReport
-                name="ReportGeneralLedger"
-                columnCount="1"
-                printOrder="Vertical"
-                orientation="Portrait"
-                pageWidth="595"
-                pageHeight="842"
-                columnWidth="535"
-                columnSpacing="0"
-                leftMargin="30"
-                rightMargin="30"
-                topMargin="20"
-                bottomMargin="20"
-                whenNoDataType="NoPages"
-                isTitleNewPage="false"
-                isSummaryNewPage="false">
-       <property name="ireport.scriptlethandling" value="0" />
-       <property name="ireport.encoding" value="UTF-8" />
-       <import value="java.util.*" />
-       <import value="net.sf.jasperreports.engine.*" />
-       <import value="net.sf.jasperreports.engine.data.*" />
-
-       <style 
-               name="default"
-               isDefault="false"
-               vAlign="Middle"
-               fontName="Bitstream Vera Sans"
-               fontSize="11"
-       >
-       </style>
-       <style 
-               name="Report_Title"
-               isDefault="false"
-               fontName="Bitstream Vera Sans"
-               fontSize="18"
-       >
-                                       <box leftPadding="5"></box>
-       </style>
-       <style 
-               name="Report_Subtitle"
-               isDefault="false"
-               forecolor="#555555"
-               fontName="Bitstream Vera Sans"
-               fontSize="14"

------------------------------------------------------------------------------
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to