Fixes issue 8824: General account report does not display start/end dates correctly when financial year is not calendar year
authorBen Sommerville <ben.sommerville@eintel.com.au>
Thu, 30 Apr 2009 12:34:09 +1000
changeset 3774 39bfc648514c
parent 3773 f031afa35943
child 3775 ec9a9966f353
Fixes issue 8824: General account report does not display start/end dates correctly when financial year is not calendar year
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	Wed Apr 29 18:30:54 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java	Thu Apr 30 12:34:09 2009 +1000
@@ -204,13 +204,13 @@
           .getClient()));
       xmlDocument.setParameter("date", DateTimeData.today(this));
       if (strDateFrom.equals(""))
-        strDateFrom = "01/01/" + strAgno;
+        strDateFrom = GeneralAccountingReportsData.yearStartDate(this,vars.getSqlDateFormat(),strAgno);
       if (strDateTo.equals(""))
-        strDateTo = "31/12/" + strAgno;
+        strDateTo = GeneralAccountingReportsData.yearEndDate(this,vars.getSqlDateFormat(),strAgno);
       if (strDateFromRef.equals(""))
-        strDateFromRef = "01/01/" + strAgnoRef;
+        strDateFromRef = GeneralAccountingReportsData.yearStartDate(this,vars.getSqlDateFormat(),strAgnoRef);
       if (strDateToRef.equals(""))
-        strDateToRef = "31/12/" + strAgnoRef;
+        strDateToRef = GeneralAccountingReportsData.yearEndDate(this,vars.getSqlDateFormat(),strAgnoRef);
       xmlDocument.setParameter("period", strDateFrom + " - " + strDateTo);
       xmlDocument.setParameter("periodRef", strDateFromRef + " - " + strDateToRef);
       xmlDocument.setParameter("agnoInitial", strAgno);
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql	Wed Apr 29 18:30:54 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql	Thu Apr 30 12:34:09 2009 +1000
@@ -152,15 +152,26 @@
     <Parameter name="client"/>
   </SqlMethod>
 
-  <SqlMethod name="date" type="preparedStatement" return="string">
+  <SqlMethod name="yearStartDate" type="preparedStatement" return="string">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
-      SELECT (CASE TO_NUMBER(TO_CHAR(now(), 'YYYY')) WHEN TO_NUMBER(?) THEN TO_CHAR(now(), to_char(?)) ELSE '31/12/'||? END) AS DATETO
-      FROM DUAL
+        select to_char(min(startdate),?) from c_period
+        inner join c_year on c_period.c_year_id = c_year.c_year_id
+        where c_year.year=?
     </Sql>
-    <Parameter name="agno"/>
     <Parameter name="dateFormat"/>
-    <Parameter name="agno"/>
+    <Parameter name="year"/>
+  </SqlMethod>
+
+  <SqlMethod name="yearEndDate" type="preparedStatement" return="string">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+        select to_char(max(enddate),?) from c_period
+        inner join c_year on c_period.c_year_id = c_year.c_year_id
+        where c_year.year=?
+    </Sql>
+    <Parameter name="dateFormat"/>
+    <Parameter name="year"/>
   </SqlMethod>
 
   <SqlMethod name="incomesummary" type="preparedStatement" return="String" default="">