Fixes Issue 9069: Include Provisional Opening Balance
authorDavid Alsasua <david.alsasua@openbravo.com>
Tue, 09 Jun 2009 19:29:58 +0200
changeset 3989 3470ed6f5af6
parent 3988 eb284f20977d
child 3990 a2d12d0f0fb8
Fixes Issue 9069: Include Provisional Opening Balance
referencedata/sampledata/Accounting_Test.xml
src-db/database/model/tables/C_ACCT_RPT.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_FIELD.xml
src-db/database/sourcedata/AD_REFERENCE.xml
src-db/database/sourcedata/AD_REF_LIST.xml
src-db/database/sourcedata/AD_TEXTINTERFACES.xml
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml
src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql
src/org/openbravo/erpCommon/businessUtility/AccountTree_data.xsql
--- a/referencedata/sampledata/Accounting_Test.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/referencedata/sampledata/Accounting_Test.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -26191,6 +26191,7 @@
     <description xsi:nil="true"/>
     <accountingSchema id="1000001"/>
     <balanced>true</balanced>
+    <reportType>Y</reportType>
   </FinancialMgmtAccountingReport>
   <FinancialMgmtAcctRptNode id="1000000">
     <id>1000000</id>
--- a/src-db/database/model/tables/C_ACCT_RPT.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src-db/database/model/tables/C_ACCT_RPT.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -49,6 +49,10 @@
         <default/>
         <onCreateDefault><![CDATA['N']]></onCreateDefault>
       </column>
+      <column name="REPORTTYPE" primaryKey="false" required="true" type="VARCHAR" size="60" autoIncrement="false">
+        <default><![CDATA[N]]></default>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
+      </column>
       <foreign-key foreignTable="AD_CLIENT" name="ADCLIENT_CACCTRPT">
         <reference local="AD_CLIENT_ID" foreign="AD_CLIENT_ID"/>
       </foreign-key>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -264059,6 +264059,39 @@
 <!--682633A6E6C39D31E040007F010061E4-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
 <!--682633A6E6C39D31E040007F010061E4--></AD_COLUMN>
 
+<!--6BDD5BBDFE613D4BE040007F01013540--><AD_COLUMN>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_COLUMN_ID><![CDATA[6BDD5BBDFE613D4BE040007F01013540]]></AD_COLUMN_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <NAME><![CDATA[Report Type]]></NAME>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <DESCRIPTION><![CDATA[Indicates whether the report is "Point in time" (needs to calculate an opening balance if it does not exist) or a "Periodic" report (in this case that calculation is not needed)]]></DESCRIPTION>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <HELP><![CDATA[Indicates whether the report is "Point in time" (needs to calculate an opening balance if it does not exist) or a "Periodic" report (in this case that calculation is not needed)]]></HELP>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <COLUMNNAME><![CDATA[ReportType]]></COLUMNNAME>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_TABLE_ID><![CDATA[800223]]></AD_TABLE_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_REFERENCE_ID><![CDATA[17]]></AD_REFERENCE_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_REFERENCE_VALUE_ID><![CDATA[F909D710BC084C92BC740A4FD498C99D]]></AD_REFERENCE_VALUE_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <FIELDLENGTH><![CDATA[1]]></FIELDLENGTH>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <DEFAULTVALUE><![CDATA['N']]></DEFAULTVALUE>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISKEY><![CDATA[N]]></ISKEY>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISPARENT><![CDATA[N]]></ISPARENT>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISUPDATEABLE><![CDATA[Y]]></ISUPDATEABLE>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISIDENTIFIER><![CDATA[N]]></ISIDENTIFIER>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <SEQNO><![CDATA[130]]></SEQNO>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISTRANSLATED><![CDATA[N]]></ISTRANSLATED>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_ELEMENT_ID><![CDATA[6BDD5E11747C51DAE040007F01013550]]></AD_ELEMENT_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <POSITION><![CDATA[13]]></POSITION>
+<!--6BDD5BBDFE613D4BE040007F01013540-->  <ISTRANSIENT><![CDATA[N]]></ISTRANSIENT>
+<!--6BDD5BBDFE613D4BE040007F01013540--></AD_COLUMN>
+
 <!--7AD1D1A49C5D11DD9476001B388C05F0--><AD_COLUMN>
 <!--7AD1D1A49C5D11DD9476001B388C05F0-->  <AD_COLUMN_ID><![CDATA[7AD1D1A49C5D11DD9476001B388C05F0]]></AD_COLUMN_ID>
 <!--7AD1D1A49C5D11DD9476001B388C05F0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -24468,6 +24468,19 @@
 <!--6860321CEBD211DD85DF0016D4EE9DB3-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--6860321CEBD211DD85DF0016D4EE9DB3--></AD_ELEMENT>
 
+<!--6BDD5E11747C51DAE040007F01013550--><AD_ELEMENT>
+<!--6BDD5E11747C51DAE040007F01013550-->  <AD_ELEMENT_ID><![CDATA[6BDD5E11747C51DAE040007F01013550]]></AD_ELEMENT_ID>
+<!--6BDD5E11747C51DAE040007F01013550-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6BDD5E11747C51DAE040007F01013550-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6BDD5E11747C51DAE040007F01013550-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6BDD5E11747C51DAE040007F01013550-->  <COLUMNNAME><![CDATA[ReportType]]></COLUMNNAME>
+<!--6BDD5E11747C51DAE040007F01013550-->  <NAME><![CDATA[Report Type]]></NAME>
+<!--6BDD5E11747C51DAE040007F01013550-->  <PRINTNAME><![CDATA[Report Type]]></PRINTNAME>
+<!--6BDD5E11747C51DAE040007F01013550-->  <DESCRIPTION><![CDATA[Indicates whether the report is "Point in time" (needs to calculate an opening balance if it does not exist) or a "Periodic" report (in this case that calculation is not needed)]]></DESCRIPTION>
+<!--6BDD5E11747C51DAE040007F01013550-->  <HELP><![CDATA[Indicates whether the report is "Point in time" (needs to calculate an opening balance if it does not exist) or a "Periodic" report (in this case that calculation is not needed)]]></HELP>
+<!--6BDD5E11747C51DAE040007F01013550-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6BDD5E11747C51DAE040007F01013550--></AD_ELEMENT>
+
 <!--8F16AEFC996311DD812A001D09C4A2FE--><AD_ELEMENT>
 <!--8F16AEFC996311DD812A001D09C4A2FE-->  <AD_ELEMENT_ID><![CDATA[8F16AEFC996311DD812A001D09C4A2FE]]></AD_ELEMENT_ID>
 <!--8F16AEFC996311DD812A001D09C4A2FE-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_FIELD.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src-db/database/sourcedata/AD_FIELD.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -190793,6 +190793,30 @@
 <!--6A93D7E4DEE246488ED145DB1C3D99BC-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--6A93D7E4DEE246488ED145DB1C3D99BC--></AD_FIELD>
 
+<!--6BDD5BBDFE623D4BE040007F01013540--><AD_FIELD>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <AD_FIELD_ID><![CDATA[6BDD5BBDFE623D4BE040007F01013540]]></AD_FIELD_ID>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <NAME><![CDATA[Report Type]]></NAME>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <DESCRIPTION><![CDATA[Indicates whether the report is "Point in time" (needs to calculate an opening balance if it does not exist) or a "Periodic" report (in this case that calculation is not needed)]]></DESCRIPTION>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <HELP><![CDATA[Indicates whether the report is "Point in time" (needs to calculate an opening balance if it does not exist) or a "Periodic" report (in this case that calculation is not needed)]]></HELP>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <AD_TAB_ID><![CDATA[800261]]></AD_TAB_ID>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <AD_COLUMN_ID><![CDATA[6BDD5BBDFE613D4BE040007F01013540]]></AD_COLUMN_ID>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <AD_FIELDGROUP_ID><![CDATA[114]]></AD_FIELDGROUP_ID>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISDISPLAYED><![CDATA[Y]]></ISDISPLAYED>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <DISPLAYLENGTH><![CDATA[1]]></DISPLAYLENGTH>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISREADONLY><![CDATA[N]]></ISREADONLY>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <SEQNO><![CDATA[80]]></SEQNO>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISSAMELINE><![CDATA[N]]></ISSAMELINE>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISFIELDONLY><![CDATA[N]]></ISFIELDONLY>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <SHOWINRELATION><![CDATA[Y]]></SHOWINRELATION>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <ISFIRSTFOCUSEDFIELD><![CDATA[N]]></ISFIRSTFOCUSEDFIELD>
+<!--6BDD5BBDFE623D4BE040007F01013540-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6BDD5BBDFE623D4BE040007F01013540--></AD_FIELD>
+
 <!--739F4C68F44B11DD9B7A0016D4EE9DB3--><AD_FIELD>
 <!--739F4C68F44B11DD9B7A0016D4EE9DB3-->  <AD_FIELD_ID><![CDATA[739F4C68F44B11DD9B7A0016D4EE9DB3]]></AD_FIELD_ID>
 <!--739F4C68F44B11DD9B7A0016D4EE9DB3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_REFERENCE.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src-db/database/sourcedata/AD_REFERENCE.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -3519,4 +3519,16 @@
 <!--DF7938526F074F33A9C8A7ED74EA315A-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--DF7938526F074F33A9C8A7ED74EA315A--></AD_REFERENCE>
 
+<!--F909D710BC084C92BC740A4FD498C99D--><AD_REFERENCE>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <AD_REFERENCE_ID><![CDATA[F909D710BC084C92BC740A4FD498C99D]]></AD_REFERENCE_ID>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <NAME><![CDATA[Report Type]]></NAME>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <DESCRIPTION><![CDATA[Type of general accounting report]]></DESCRIPTION>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <HELP><![CDATA[Type of general accounting report]]></HELP>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <VALIDATIONTYPE><![CDATA[L]]></VALIDATIONTYPE>
+<!--F909D710BC084C92BC740A4FD498C99D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--F909D710BC084C92BC740A4FD498C99D--></AD_REFERENCE>
+
 </data>
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -8310,6 +8310,18 @@
 <!--174988A322B34FC9B8C4403BA1617DB7-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--174988A322B34FC9B8C4403BA1617DB7--></AD_REF_LIST>
 
+<!--19CE2DD159684FCF84E1B1963AF59A14--><AD_REF_LIST>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <AD_REF_LIST_ID><![CDATA[19CE2DD159684FCF84E1B1963AF59A14]]></AD_REF_LIST_ID>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <VALUE><![CDATA[Y]]></VALUE>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <NAME><![CDATA[Point in Time]]></NAME>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <DESCRIPTION><![CDATA[This tipe requires an opening entry. If it does not exist system will calculate it.]]></DESCRIPTION>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <AD_REFERENCE_ID><![CDATA[F909D710BC084C92BC740A4FD498C99D]]></AD_REFERENCE_ID>
+<!--19CE2DD159684FCF84E1B1963AF59A14-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--19CE2DD159684FCF84E1B1963AF59A14--></AD_REF_LIST>
+
 <!--238ABDA9172247D98DC8D2080CD26CAD--><AD_REF_LIST>
 <!--238ABDA9172247D98DC8D2080CD26CAD-->  <AD_REF_LIST_ID><![CDATA[238ABDA9172247D98DC8D2080CD26CAD]]></AD_REF_LIST_ID>
 <!--238ABDA9172247D98DC8D2080CD26CAD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -8602,6 +8614,18 @@
 <!--89E14C49889F4D1282E51CFD7F539E59-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--89E14C49889F4D1282E51CFD7F539E59--></AD_REF_LIST>
 
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7--><AD_REF_LIST>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <AD_REF_LIST_ID><![CDATA[8AC0DF3B7CE94524AB7B59DD3A1C88B7]]></AD_REF_LIST_ID>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <VALUE><![CDATA[N]]></VALUE>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <NAME><![CDATA[Periodic]]></NAME>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <DESCRIPTION><![CDATA[This type does not need an opening entry]]></DESCRIPTION>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <AD_REFERENCE_ID><![CDATA[F909D710BC084C92BC740A4FD498C99D]]></AD_REFERENCE_ID>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--8AC0DF3B7CE94524AB7B59DD3A1C88B7--></AD_REF_LIST>
+
 <!--8F44015D71C041D1A96EF85CFDB6E7E9--><AD_REF_LIST>
 <!--8F44015D71C041D1A96EF85CFDB6E7E9-->  <AD_REF_LIST_ID><![CDATA[8F44015D71C041D1A96EF85CFDB6E7E9]]></AD_REF_LIST_ID>
 <!--8F44015D71C041D1A96EF85CFDB6E7E9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src-db/database/sourcedata/AD_TEXTINTERFACES.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -25584,6 +25584,28 @@
 <!--6AAA4872E8DB11DDAE85001D09C4A2FE-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--6AAA4872E8DB11DDAE85001D09C4A2FE--></AD_TEXTINTERFACES>
 
+<!--6BDE5BE4EAE16A0BE040007F01014817--><AD_TEXTINTERFACES>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <AD_TEXTINTERFACES_ID><![CDATA[6BDE5BE4EAE16A0BE040007F01014817]]></AD_TEXTINTERFACES_ID>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <TEXT><![CDATA[As of Date]]></TEXT>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <FILENAME><![CDATA[/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html]]></FILENAME>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <ISUSED><![CDATA[Y]]></ISUSED>
+<!--6BDE5BE4EAE16A0BE040007F01014817-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6BDE5BE4EAE16A0BE040007F01014817--></AD_TEXTINTERFACES>
+
+<!--6BDE5BE4EAE26A0BE040007F01014817--><AD_TEXTINTERFACES>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <AD_TEXTINTERFACES_ID><![CDATA[6BDE5BE4EAE26A0BE040007F01014817]]></AD_TEXTINTERFACES_ID>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <TEXT><![CDATA[As of Reference Date]]></TEXT>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <FILENAME><![CDATA[/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html]]></FILENAME>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <ISUSED><![CDATA[Y]]></ISUSED>
+<!--6BDE5BE4EAE26A0BE040007F01014817-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--6BDE5BE4EAE26A0BE040007F01014817--></AD_TEXTINTERFACES>
+
 <!--788BFEB299DB11DDA986001B388C61A4--><AD_TEXTINTERFACES>
 <!--788BFEB299DB11DDA986001B388C61A4-->  <AD_TEXTINTERFACES_ID><![CDATA[788BFEB299DB11DDA986001B388C61A4]]></AD_TEXTINTERFACES_ID>
 <!--788BFEB299DB11DDA986001B388C61A4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html	Mon Jun 08 21:55:51 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.html	Tue Jun 09 19:29:58 2009 +0200
@@ -50,6 +50,36 @@
         dojo.hostenv.writeIncludes(); //makes debugging in Venkman possible
       </script>
 <script language="JavaScript" type="text/javascript">
+function displayLogic() {
+     var frm = document.frmMain;
+     if (frm.inpcElementvalueId.value.substring(0,1) == 'N') {
+           displayLogicElement('tdFromDateLabel', true);
+           displayLogicElement('tdFromDate', true);
+           displayLogicElement('tdToDateLabel', true);
+           displayLogicElement('tdToDate', true);
+           displayLogicElement('tdFromRefDateLabel', true);
+           displayLogicElement('tdFromRefDate', true);
+           displayLogicElement('tdToRefDateLabel', true);
+           displayLogicElement('tdToRefDate', true);
+           displayLogicElement('tdAsToDateLabel', false);
+           displayLogicElement('tdAsToDate', false);
+           displayLogicElement('tdAsToRefDateLabel', false);
+           displayLogicElement('tdAsToRefDate', false);
+     } else {
+           displayLogicElement('tdFromDateLabel', false);
+           displayLogicElement('tdFromDate', false);
+           displayLogicElement('tdToDateLabel', false);
+           displayLogicElement('tdToDate', false);
+           displayLogicElement('tdFromRefDateLabel', false);
+           displayLogicElement('tdFromRefDate', false);
+           displayLogicElement('tdToRefDateLabel', false);
+           displayLogicElement('tdToRefDate', false);
+           displayLogicElement('tdAsToDateLabel', true);
+           displayLogicElement('tdAsToDate', true);
+           displayLogicElement('tdAsToRefDateLabel', true);
+           displayLogicElement('tdAsToRefDate', true);
+     }
+}
 
 function validate(command) {
 	var frm = document.frmMain;
@@ -83,7 +113,7 @@
 
 function refreshAccountingReports() {
   var cmbAccountSchema = document.frmMain.inpcAcctSchemaId;  
-  var cmbAccountingReports = document.frmMain.inpcElementvalueId;  
+  var cmbAccountingReports = document.frmMain.inpcElementvalueId.value.substring(0,1);
   changeComboData(cmbAccountingReports, arrAccountingReports, cmbAccountSchema.options[cmbAccountSchema.selectedIndex].value, false);
   return true;
 }
@@ -141,6 +171,7 @@
 		updateMenuIcon('buttonMenu');
 
 		setWindowElementFocus('firstElement');
+        displayLogic();
 	}
 
 	function onResizeDo(){
@@ -280,116 +311,6 @@
                     <tr class="FieldGroup_TopMargin"/>
                     <tr>
                       <td class="FieldGroupTitle_Left"><img class="FieldGroupTitle_Left_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
-                      <td class="FieldGroupTitle">Primary Filters</td>
-                      <td class="FieldGroupTitle_Right"><img class="FieldGroupTitle_Right_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
-                      <td class="FieldGroupContent"/>
-                    </tr>
-                    <tr class="FieldGroup_BottomMargin"/>
-                  </tbody>
-                  </table>
-                </td>
-                </tr>
-                <tr>
-                  <td class="TitleCell"><span class="LabelText">Year</span></td>
-                  <td class="TextBox_ContentCell"><input dojoType="openbravo:ValidationTextbox" name="inpAgno" type="text" maxlength="4" value="" id="paramAgno" class="required TextBox_OneCell_width" required="true" onchange="logChanges(this);return true;"></input><script>djConfig.searchIds.push("paramAgno");</script>
-                  <td class="TitleCell"><span class="LabelText">From Date</span></td>
-                  <td class="TextBox_btn_ContentCell">
-                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
-                      <tr>
-                        <td>
-                          <input dojoType="openbravo:DateTextbox" lowerThan="paramDateTo" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateFrom" id="paramDateFrom" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateFrom");</script>
-                        </td>
-                        <td valign="top">
-                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;"  onclick="showCalendar('frmMain.inpDateFrom', document.frmMain.inpDateFrom.value, false);return false;">
-                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
-                            <tr>
-                              <td class="FieldButton_bg">
-                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
-                              </td>
-                            </tr>
-                          </table>
-                          </a>
-                        </td>
-                      </tr>
-                    </table>
-                 </td>
-                  <td class="TitleCell"><span class="LabelText">To Date</span></td>
-                  <td class="TextBox_btn_ContentCell">
-                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
-                      <tr>
-                        <td>
-                          <input dojoType="openbravo:DateTextbox" greaterThan="paramDateFrom" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateTo" id="paramDateTo" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateTo");</script>
-                        </td>
-                        <td valign="top">
-                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;" onclick="showCalendar('frmMain.inpDateTo', document.frmMain.inpDateTo.value, false);return false;" >
-                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
-                            <tr>
-                              <td class="FieldButton_bg">
-                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
-                              </td>
-                            </tr>
-                          </table>
-                          </a>
-                        </td>
-                      </tr>
-                    </table>
-                  </td>
-                </tr>
-
-                <tr>
-                <td class="TitleCell"><span class="LabelText">Reference Year</span></td>
-                  <td class="TextBox_ContentCell"><input dojoType="openbravo:ValidationTextbox" name="inpAgnoRef" type="text" maxlength="4" value="" id="paramAgnoRef" class="required TextBox_OneCell_width" required="true" onchange="logChanges(this);return true;"></input><script>djConfig.searchIds.push("paramAgnoRef");</script>
-                  <td class="TitleCell"><span class="LabelText">From Reference Date</span></td>
-                  <td class="TextBox_btn_ContentCell">
-                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
-                      <tr>
-                        <td>
-                          <input dojoType="openbravo:DateTextbox" lowerThan="paramDateToRef" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateFromRef" id="paramDateFromRef" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateFromRef");</script>
-                        </td>
-                        <td valign="top">
-                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;"  onclick="showCalendar('frmMain.inpDateFromRef', document.frmMain.inpDateFromRef.value, false);return false;">
-                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
-                            <tr>
-                              <td class="FieldButton_bg">
-                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
-                              </td>
-                            </tr>
-                          </table>
-                          </a>
-                        </td>
-                      </tr>
-                    </table>
-                  </td>
-                  <td class="TitleCell"><span class="LabelText">To Reference Date</span></td>
-                  <td class="TextBox_btn_ContentCell">
-                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
-                      <tr>
-                        <td>
-                          <input dojoType="openbravo:DateTextbox" greaterThan="paramDateFromRef" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateToRef" id="paramDateToRef" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateToRef");</script>
-                        </td>
-                        <td valign="top">
-                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;"  onclick="showCalendar('frmMain.inpDateToRef', document.frmMain.inpDateToRef.value, false);return false;">
-                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
-                            <tr>
-                              <td class="FieldButton_bg">
-                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
-                              </td>
-                            </tr>
-                          </table>
-                          </a>
-                        </td>
-                      </tr>
-                    </table>
-                  </td>
-                </tr>
-
-                <tr>
-                <td colspan="6">
-                  <table class="FieldGroup" cellspacing="0" cellpadding="0" border="0">
-                  <tbody>
-                    <tr class="FieldGroup_TopMargin"/>
-                    <tr>
-                      <td class="FieldGroupTitle_Left"><img class="FieldGroupTitle_Left_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
                       <td class="FieldGroupTitle">Report Options</td>
                       <td class="FieldGroupTitle_Right"><img class="FieldGroupTitle_Right_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
                       <td class="FieldGroupContent"/>
@@ -421,7 +342,7 @@
                 </tr>
 
                 <tr>
-				  <td class="TitleCell"><span class="LabelText">Organization</span></td>
+                  <td class="TitleCell"><span class="LabelText">Organization</span></td>
                   <td class="Combo_ContentCell" colspan="2"> <select name="inpOrganizacion" id="inpOrganizacion" class="ComboKey Combo_TwoCells_width">
                       <option value=""></option><div id="reportC_Org_ID"></div>
                     </select></td>
@@ -442,6 +363,162 @@
                     <tr class="FieldGroup_TopMargin"/>
                     <tr>
                       <td class="FieldGroupTitle_Left"><img class="FieldGroupTitle_Left_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
+                      <td class="FieldGroupTitle">Primary Filters</td>
+                      <td class="FieldGroupTitle_Right"><img class="FieldGroupTitle_Right_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
+                      <td class="FieldGroupContent"/>
+                    </tr>
+                    <tr class="FieldGroup_BottomMargin"/>
+                  </tbody>
+                  </table>
+                </td>
+                </tr>
+                <tr>
+                  <td class="TitleCell"><span class="LabelText">Year</span></td>
+                  <td class="Combo_ContentCell"> <SELECT name="inpAgno" id="paramAgno" class="ComboKey Combo_OneCell_width" onchange="displayLogic(); return true;">
+                      <OPTION value=""> <DIV id="reportAgno"></DIV></OPTION>
+                    </SELECT></TD>
+                  <td class="TitleCell" id="tdFromDateLabel"><SPAN class="LabelText">From Date</SPAN></td>
+                  <TD class="TextBox_btn_ContentCell" id="tdFromDate">
+                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                      <tr>
+                        <td>
+                          <input dojoType="openbravo:DateTextbox" lowerThan="paramDateTo" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateFrom" id="paramDateFrom" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateFrom");</script>
+                        </td>
+                        <td valign="top">
+                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;"  onclick="showCalendar('frmMain.inpDateFrom', document.frmMain.inpDateFrom.value, false);return false;">
+                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                            <tr>
+                              <td class="FieldButton_bg">
+                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
+                              </td>
+                            </tr>
+                          </table>
+                          </a>
+                        </td>
+                      </tr>
+                    </table>
+                 </td>
+                  <td class="TitleCell"><span class="LabelText" id="tdToDateLabel">To Date</span></td>
+                  <td class="TextBox_btn_ContentCell" id="tdToDate">
+                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                      <tr>
+                        <td>
+                          <input dojoType="openbravo:DateTextbox" greaterThan="paramDateFrom" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateTo" id="paramDateTo" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateTo");</script>
+                        </td>
+                        <td valign="top">
+                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;" onclick="showCalendar('frmMain.inpDateTo', document.frmMain.inpDateTo.value, false);return false;" >
+                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                            <tr>
+                              <td class="FieldButton_bg">
+                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
+                              </td>
+                            </tr>
+                          </table>
+                          </a>
+                        </td>
+                      </tr>
+                    </table>
+                  </td>
+                  <td class="TitleCell" id="tdAsToDateLabel" colspan="2"><SPAN class="LabelText">As of Date</SPAN></td>
+                  <TD class="TextBox_btn_ContentCell" id="tdAsToDate">
+                    <TABLE border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                      <TR>
+                        <TD>
+                          <INPUT dojoType="openbravo:DateTextbox" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpAsDateTo" id="paramAsDateTo" maxlength="10" value="" onkeyup="auto_complete_date(this.textbox, this.displayFormat);return true;"></INPUT><script>djConfig.searchIds.push("paramAsDateTo");</script>
+                        </TD>
+                        <TD valign="top">
+                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;" onclick="showCalendar('frmMain.inpAsDateTo', document.frmMain.inpAsDateTo.value, false);return false;" >
+                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                            <TR>
+                              <TD class="FieldButton_bg">
+                                <IMG alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></IMG>
+                              </TD>
+                            </TR>
+                          </TABLE>
+                          </a>
+                        </TD>
+                      </TR>
+                    </TABLE>
+                  </TD>
+                </tr>
+
+                <tr>
+                <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=""> <DIV id="reportAgnoRef"></DIV></OPTION>
+                    </SELECT></TD>
+                  <td class="TitleCell" id="tdFromRefDateLabel"><SPAN class="LabelText">From Reference Date</SPAN></td>
+                  <TD class="TextBox_btn_ContentCell" id="tdFromRefDate">
+                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                      <tr>
+                        <td>
+                          <input dojoType="openbravo:DateTextbox" lowerThan="paramDateToRef" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateFromRef" id="paramDateFromRef" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateFromRef");</script>
+                        </td>
+                        <td valign="top">
+                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;"  onclick="showCalendar('frmMain.inpDateFromRef', document.frmMain.inpDateFromRef.value, false);return false;">
+                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                            <tr>
+                              <td class="FieldButton_bg">
+                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
+                              </td>
+                            </tr>
+                          </table>
+                          </a>
+                        </td>
+                      </tr>
+                    </table>
+                  </td>
+                  <td class="TitleCell" id="tdToRefDateLabel"><span class="LabelText">To Reference Date</span></td>
+                  <td class="TextBox_btn_ContentCell" id="tdToRefDate">
+                    <table border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                      <tr>
+                        <td>
+                          <input dojoType="openbravo:DateTextbox" greaterThan="paramDateFromRef" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpDateToRef" id="paramDateToRef" maxlength="10" value="" onkeyup="autoCompleteDate(this.textbox, this.displayFormat);return true;"></input><script>djConfig.searchIds.push("paramDateToRef");</script>
+                        </td>
+                        <td valign="top">
+                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;"  onclick="showCalendar('frmMain.inpDateToRef', document.frmMain.inpDateToRef.value, false);return false;">
+                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                            <tr>
+                              <td class="FieldButton_bg">
+                                <img alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></img>
+                              </td>
+                            </tr>
+                          </table>
+                          </a>
+                        </td>
+                      </tr>
+                    </table>
+                  </td>
+                  <td class="TitleCell" id="tdAsToRefDateLabel" colspan="2"><SPAN class="LabelText">As of Reference Date</SPAN></td>
+                  <TD class="TextBox_btn_ContentCell" id="tdAsToRefDate">
+                    <TABLE border="0" cellspacing="0" cellpadding="0" summary=""  style="padding-top: 0px;">
+                      <TR>
+                        <TD>
+                          <INPUT dojoType="openbravo:DateTextbox" displayFormat="xx" saveFormat="yy"  class="TextBox_btn_OneCell_width" type="text" name="inpAsDateToRef" id="paramAsDateToRef" maxlength="10" value="" onkeyup="auto_complete_date(this.textbox, this.displayFormat);return true;"></INPUT><script>djConfig.searchIds.push("paramAsDateToRef");</script>
+                        </TD>
+                        <TD valign="top">
+                          <a class="FieldButtonLink" href="#" onfocus="setWindowElementFocus(this); window.status='Calendar'; return true;" onblur="window.status=''; return true;" onkeypress="this.className='FieldButtonLink_active'; return true;" onkeyup="this.className='FieldButtonLink_focus'; return true;"  onclick="showCalendar('frmMain.inpAsDateToRef', document.frmMain.inpAsDateToRef.value, false);return false;">
+                          <table class="FieldButton" onmouseout="this.className='FieldButton';window.status='';return true;" onmouseover="this.className='FieldButton_hover';window.status='Show calendar';return true;" onmousedown="this.className='FieldButton_active';return true;" onmouseup="this.className='FieldButton';return true;">
+                            <TR>
+                              <TD class="FieldButton_bg">
+                                <IMG alt="Calendar" class="FieldButton_Icon FieldButton_Icon_Calendar" title="Calendar" src="../../../../../web/images/blank.gif" border="0"></IMG>
+                              </TD>
+                            </TR>
+                          </TABLE>
+                          </a>
+                        </TD>
+                      </TR>
+                    </TABLE>
+                  </TD>
+                </tr>
+
+                <tr>
+                <td colspan="6">
+                  <table class="FieldGroup" cellspacing="0" cellpadding="0" border="0">
+                  <tbody>
+                    <tr class="FieldGroup_TopMargin"/>
+                    <tr>
+                      <td class="FieldGroupTitle_Left"><img class="FieldGroupTitle_Left_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
                       <td class="FieldGroupTitle">View Results</td>
                       <td class="FieldGroupTitle_Right"><img class="FieldGroupTitle_Right_bg" border="0" src="../../../../../web/images/blank.gif"/></td>
                       <td class="FieldGroupContent"/>
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java	Mon Jun 08 21:55:51 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.java	Tue Jun 09 19:29:58 2009 +0200
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.math.BigDecimal;
+import java.util.Vector;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -64,6 +65,10 @@
           "GeneralAccountingReports|dateFromRef", "");
       String strDateToRef = vars.getGlobalVariable("inpDateToRef",
           "GeneralAccountingReports|dateToRef", "");
+      String strAsDateTo = vars.getGlobalVariable("inpAsDateTo",
+          "GeneralAccountingReports|asDateTo", "");
+      String strAsDateToRef = vars.getGlobalVariable("inpAsDateToRef",
+          "GeneralAccountingReports|asDateToRef", "");
       String strElementValue = vars.getGlobalVariable("inpcElementvalueId",
           "GeneralAccountingReports|C_ElementValue_ID", "");
       String strConImporte = vars.getGlobalVariable("inpConImporte",
@@ -74,8 +79,8 @@
           "GeneralAccountingReports|organizacion", "");
       String strLevel = vars.getGlobalVariable("inpLevel", "GeneralAccountingReports|level", "");
       printPageDataSheet(response, vars, strAgno, strAgnoRef, strDateFrom, strDateTo,
-          strDateFromRef, strDateToRef, strElementValue, strConImporte, strOrg, strLevel,
-          strConCodigo, strcAcctSchemaId);
+          strDateFromRef, strDateToRef, strAsDateTo, strAsDateToRef, strElementValue,
+          strConImporte, strOrg, strLevel, strConCodigo, strcAcctSchemaId);
     } else if (vars.commandIn("FIND")) {
       String strcAcctSchemaId = vars.getRequestGlobalVariable("inpcAcctSchemaId",
           "ReportGeneralLedger|cAcctSchemaId");
@@ -90,6 +95,10 @@
           "GeneralAccountingReports|dateFromRef");
       String strDateToRef = vars.getRequestGlobalVariable("inpDateToRef",
           "GeneralAccountingReports|dateToRef");
+      String strAsDateTo = vars.getRequestGlobalVariable("inpAsDateTo",
+          "GeneralAccountingReports|asDateTo");
+      String strAsDateToRef = vars.getRequestGlobalVariable("inpAsDateToRef",
+          "GeneralAccountingReports|asDateToRef");
       String strElementValue = vars.getRequiredGlobalVariable("inpcElementvalueId",
           "GeneralAccountingReports|C_ElementValue_ID");
       String strConImporte = vars.getRequestGlobalVariable("inpConImporte",
@@ -100,22 +109,25 @@
           "GeneralAccountingReports|organizacion");
       String strLevel = vars.getRequestGlobalVariable("inpLevel", "GeneralAccountingReports|level");
       printPagePDF(request, response, vars, strAgno, strAgnoRef, strDateFrom, strDateTo,
-          strDateFromRef, strDateToRef, strElementValue, strConImporte, strOrg, strLevel,
-          strConCodigo, strcAcctSchemaId);
+          strDateFromRef, strDateToRef, strAsDateTo, strAsDateToRef, strElementValue,
+          strConImporte, strOrg, strLevel, strConCodigo, strcAcctSchemaId);
     } else
       pageError(response);
   }
 
   private void printPagePDF(HttpServletRequest request, HttpServletResponse response,
       VariablesSecureApp vars, String strAgno, String strAgnoRef, String strDateFrom,
-      String strDateTo, String strDateFromRef, String strDateToRef, String strElementValue,
-      String strConImporte, String strOrg, String strLevel, String strConCodigo,
-      String strcAcctSchemaId) throws IOException, ServletException {
+      String strDateTo, String strDateFromRef, String strDateToRef, String strAsDateTo,
+      String strAsDateToRef, String strElementValue, String strConImporte, String strOrg,
+      String strLevel, String strConCodigo, String strcAcctSchemaId) throws IOException,
+      ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: pdf");
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
         "org/openbravo/erpCommon/ad_reports/GeneralAccountingReportsPDF").createXmlDocument();
 
+    String strCalculateOpening = strElementValue.substring(0, 1);
+    strElementValue = strElementValue.substring(1, strElementValue.length());
     GeneralAccountingReportsData[] strGroups = GeneralAccountingReportsData.selectGroups(this,
         strElementValue);
 
@@ -148,34 +160,82 @@
       if (dataTree != null && dataTree.length != 0)
         TreeID = dataTree[0].id;
 
+      // For each year, the initial and closing date is obtained
+      GeneralAccountingReportsData[] startEndYear = GeneralAccountingReportsData.startEndYear(this,
+          vars.getClient(), strAgno.substring(1, strAgno.length()));
+      GeneralAccountingReportsData[] startEndYearRef = GeneralAccountingReportsData.startEndYear(
+          this, vars.getClient(), strAgnoRef.substring(1, strAgnoRef.length()));
+      String strYear = "'" + startEndYear[0].name + "'";
+      String strYearRef = "'" + startEndYearRef[0].name + "'";
+      String strYearsToClose = "";
+      String strYearsToCloseRef = "";
+
+      Vector<Object> vec = new Vector<Object>();
+      // Relation of open and closed years is obtained
+      GeneralAccountingReportsData[] closedYears = GeneralAccountingReportsData.checkFiscalYears(
+          this, vars.getClient());
+      GeneralAccountingReportsData[] previousYears = GeneralAccountingReportsData.previousYear(
+          this, vars.getClient());
+      if (strCalculateOpening.equals("Y")) {
+        strCalculateOpening = "N";
+        strDateTo = strAsDateTo;
+        strDateToRef = strAsDateToRef;
+        strDateFrom = "";
+        strDateFromRef = "";
+        fulfillYearsToClose(vec, startEndYear[0].name, closedYears, previousYears);
+        // If there is some year to close, will be appended to the year to show in report when
+        // calculating amounts, through strYearsToClose and strYearsToCloseRef variables
+        if (vec.size() > 0) {
+          for (int i = 0; i < vec.size(); i++) {
+            strCalculateOpening = "Y"; // If we finally calculate the opening variable takes "Y"
+            strYearsToClose = strYearsToClose + ",'" + vec.elementAt(i) + "'";
+          }
+        }
+        vec = new Vector<Object>();
+        fulfillYearsToClose(vec, startEndYearRef[0].name, closedYears, previousYears);
+        // If there is some year to close
+        if (vec.size() > 0) {
+          for (int i = 0; i < vec.size(); i++) {
+            strCalculateOpening = "Y"; // If we finally calculate the opening variable takes "Y"
+            strYearsToCloseRef = strYearsToCloseRef + ",'" + vec.elementAt(i) + "'";
+          }
+        }
+      }
+
       for (int i = 0; i < strGroups.length; i++) {
+        // All account tree is obtained
         if (vars.getLanguage().equals("en_US")) {
           elements[i] = AccountTreeData.select(this, strConCodigo, TreeID);
         } else {
           elements[i] = AccountTreeData.selectTrl(this, strConCodigo, vars.getLanguage(), TreeID);
         }
+        // For each account with movements in the year, debit and credit total amounts are
+        // calculated according to fact_acct movements.
         AccountTreeData[] accounts = AccountTreeData.selectAcct(this, Utility.getContext(this,
             vars, "#AccessibleOrgTree", "GeneralAccountingReports"), Utility.getContext(this, vars,
             "#User_Client", "GeneralAccountingReports"), strDateFrom, DateTimeData.nDaysAfter(this,
-            strDateTo, "1"), strcAcctSchemaId, Tree.getMembers(this, strTreeOrg, strOrg), strAgno,
-            strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"), strAgnoRef);
-
+            strDateTo, "1"), strcAcctSchemaId, Tree.getMembers(this, strTreeOrg, strOrg), strYear
+            + strYearsToClose, strDateFromRef, DateTimeData.nDaysAfter(this, strDateToRef, "1"),
+            strYearRef + strYearsToCloseRef);
         {
+          // Income summary amount is calculated and included in the balance sheet data
           String strIncomeSummary = GeneralAccountingReportsData.incomesummary(this,
               strcAcctSchemaId);
           if (log4j.isDebugEnabled())
             log4j.debug("*********** strIncomeSummary: " + strIncomeSummary);
           String strISyear = processIncomeSummary(strDateFrom, DateTimeData.nDaysAfter(this,
-              strDateTo, "1"), strAgno, strTreeOrg, strOrg, strcAcctSchemaId);
+              strDateTo, "1"), strYear + strYearsToClose, strTreeOrg, strOrg, strcAcctSchemaId);
           if (log4j.isDebugEnabled())
             log4j.debug("*********** strISyear: " + strISyear);
           String strISyearRef = processIncomeSummary(strDateFromRef, DateTimeData.nDaysAfter(this,
-              strDateToRef, "1"), strAgnoRef, strTreeOrg, strOrg, strcAcctSchemaId);
+              strDateToRef, "1"), strYearRef + strYearsToCloseRef, strTreeOrg, strOrg,
+              strcAcctSchemaId);
           if (log4j.isDebugEnabled())
             log4j.debug("*********** strISyearRef: " + strISyearRef);
           accounts = appendRecords(accounts, strIncomeSummary, strISyear, strISyearRef);
 
         }
+        // Report tree is built with given the account tree, and the amounts obtained from fact_acct
         acct[i] = new AccountTree(vars, this, elements[i], accounts, strElementValueDes[i]);
         if (acct[i] != null) {
           acct[i].filterSVC();
@@ -186,42 +246,33 @@
 
       xmlDocument.setData("group", strGroups);
 
-      /*
-       * xmlDocument.setParameter("agno", "Ejercicio "+strAgno); xmlDocument.setParameter("agno2",
-       * "Ejercicio "+strAgno); xmlDocument.setParameter("column", "Ejercicio "+strAgno);
-       * xmlDocument.setParameter("columnRef", "Ejercicio "+strAgnoRef);
-       * xmlDocument.setParameter("column1", "Ejercicio "+strAgno);
-       * xmlDocument.setParameter("columnRef1", "Ejercicio "+strAgnoRef);
-       */
-      xmlDocument.setParameter("agno", strAgno);
-      xmlDocument.setParameter("agno2", strAgno);
-      xmlDocument.setParameter("column", strAgno);
-      xmlDocument.setParameter("columnRef", strAgnoRef);
+      xmlDocument.setParameter("agno", startEndYear[0].name);
+      xmlDocument.setParameter("agno2", startEndYearRef[0].name);
+      xmlDocument.setParameter("column", startEndYear[0].name);
+      xmlDocument.setParameter("columnRef", startEndYearRef[0].name);
       xmlDocument.setParameter("org", OrganizationData.selectOrgName(this, strOrg));
-      xmlDocument.setParameter("column1", strAgno);
-      xmlDocument.setParameter("columnRef1", strAgnoRef);
+      xmlDocument.setParameter("column1", startEndYear[0].name);
+      xmlDocument.setParameter("columnRef1", startEndYearRef[0].name);
       xmlDocument.setParameter("companyName", GeneralAccountingReportsData.companyName(this, vars
           .getClient()));
       xmlDocument.setParameter("date", DateTimeData.today(this));
       if (strDateFrom.equals(""))
-        strDateFrom = GeneralAccountingReportsData.yearStartDate(this, vars.getSqlDateFormat(),
-            strAgno);
+        strDateFrom = startEndYear[0].begining;
       if (strDateTo.equals(""))
-        strDateTo = GeneralAccountingReportsData
-            .yearEndDate(this, vars.getSqlDateFormat(), strAgno);
+        strDateTo = startEndYear[0].end;
       if (strDateFromRef.equals(""))
-        strDateFromRef = GeneralAccountingReportsData.yearStartDate(this, vars.getSqlDateFormat(),
-            strAgnoRef);
+        strDateFromRef = startEndYearRef[0].begining;
       if (strDateToRef.equals(""))
-        strDateToRef = GeneralAccountingReportsData.yearEndDate(this, vars.getSqlDateFormat(),
-            strAgnoRef);
+        strDateToRef = startEndYearRef[0].end;
       xmlDocument.setParameter("period", strDateFrom + " - " + strDateTo);
       xmlDocument.setParameter("periodRef", strDateFromRef + " - " + strDateToRef);
-      xmlDocument.setParameter("agnoInitial", strAgno);
-      xmlDocument.setParameter("agnoRef", strAgnoRef);
+      xmlDocument.setParameter("agnoInitial", startEndYear[0].name);
+      xmlDocument.setParameter("agnoRef", startEndYearRef[0].name);
 
-      xmlDocument.setParameter("principalTitle", GeneralAccountingReportsData.rptTitle(this,
-          strElementValue));
+      xmlDocument.setParameter("principalTitle",
+          strCalculateOpening.equals("Y") ? GeneralAccountingReportsData.rptTitle(this,
+              strElementValue)
+              + " (Provisional)" : GeneralAccountingReportsData.rptTitle(this, strElementValue));
 
       AccountTreeData[][] trees = new AccountTreeData[strGroups.length][];
 
@@ -240,6 +291,32 @@
     }
   }
 
+  private Vector<Object> fulfillYearsToClose(Vector<Object> vec, String yearID,
+      GeneralAccountingReportsData[] closedYears, GeneralAccountingReportsData[] previousYears) {
+    Vector<Object> vecAux = vec;
+    String previous = "";
+    // Let's see if this year has a previous one
+    for (int i = 0; i < previousYears.length; i++) {
+      if (previousYears[i].name.equals(yearID))
+        previous = previousYears[i].previousYear;
+    }
+    // If not, return with what we have got until now
+    if ("".equals(previous))
+      return vecAux;
+
+    // Let's see if the previous year was closed or not
+    for (int i = 0; i < closedYears.length; i++) {
+      if (closedYears[i].name.substring(0, 4).equals(yearID))
+        if ("N".equals(closedYears[i].id.substring(0, 1))) {
+          if (!vecAux.contains(previous))
+            vecAux.add(previous);
+          // If not, let's check if previous of the previous was closed
+          vecAux = fulfillYearsToClose(vecAux, previous, closedYears, previousYears);
+        }
+    }
+    return vecAux;
+  }
+
   private AccountTreeData[] appendRecords(AccountTreeData[] data, String strIncomeSummary,
       String strISyear, String strISyearRef) throws ServletException {
     if (data == null || strIncomeSummary == null || strIncomeSummary.equals("")
@@ -288,11 +365,11 @@
     return total.toString();
   }
 
-  private void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strAgno,
-      String strAgnoRef, String strDateFrom, String strDateTo, String strDateFromRef,
-      String strDateToRef, String strElementValue, String strConImporte, String strOrg,
-      String strLevel, String strConCodigo, String strcAcctSchemaId) throws IOException,
-      ServletException {
+  private void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars,
+      String strAgno, String strAgnoRef, String strDateFrom, String strDateTo,
+      String strDateFromRef, String strDateToRef, String strAsDateTo, String strAsDateToRef,
+      String strElementValue, String strConImporte, String strOrg, String strLevel,
+      String strConCodigo, String strcAcctSchemaId) throws IOException, ServletException {
     if (log4j.isDebugEnabled())
       log4j.debug("Output: dataSheet");
     XmlDocument xmlDocument = xmlEngine.readXmlTemplate(
@@ -346,6 +423,12 @@
     xmlDocument.setParameter("dateToRef", strDateToRef);
     xmlDocument.setParameter("dateToRefdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
     xmlDocument.setParameter("dateToRefsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+    xmlDocument.setParameter("asDateTo", strAsDateTo);
+    xmlDocument.setParameter("asDateTodisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+    xmlDocument.setParameter("asDateTosaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+    xmlDocument.setParameter("asDateToRef", strAsDateToRef);
+    xmlDocument.setParameter("asDateToRefdisplayFormat", vars.getSessionValue("#AD_SqlDateFormat"));
+    xmlDocument.setParameter("asDateToRefsaveFormat", vars.getSessionValue("#AD_SqlDateFormat"));
     xmlDocument.setParameter("conImporte", strConImporte);
     xmlDocument.setParameter("conCodigo", strConCodigo);
     xmlDocument.setParameter("C_Org_ID", strOrg);
@@ -435,15 +518,13 @@
 
     xmlDocument.setParameter("accountingReports", Utility.arrayDobleEntrada("arrAccountingReports",
         GeneralAccountingReportsData.selectRptDouble(this)));
-    /*
-     * try { ComboTableData comboTableData = new ComboTableData(vars, this, "TABLEDIR",
-     * "C_Acct_Rpt_ID", "", "", Utility.getContext(this, vars, "#AccessibleOrgTree",
-     * "GeneralAccountingReports"), Utility.getContext(this, vars, "#User_Client",
-     * "GeneralAccountingReports"), 0); Utility.fillSQLParameters(this, vars, null, comboTableData,
-     * "GeneralAccountingReports", "");
-     * xmlDocument.setData("reportC_ElementValue_ID","liststructure", comboTableData.select(false));
-     * comboTableData = null; } catch (Exception ex) { throw new ServletException(ex); }
-     */
+
+    xmlDocument.setParameter("paramAgno", strAgno);
+    xmlDocument.setData("reportAgno", "liststructure", GeneralAccountingReportsData
+        .checkFiscalYears(this, vars.getClient()));
+    xmlDocument.setParameter("paramAgno", strAgnoRef);
+    xmlDocument.setData("reportAgnoRef", "liststructure", GeneralAccountingReportsData
+        .checkFiscalYears(this, vars.getClient()));
 
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml	Mon Jun 08 21:55:51 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports.xml	Tue Jun 09 19:29:58 2009 +0200
@@ -25,18 +25,24 @@
   <PARAMETER id="paramLanguage" name="language"/>
   <PARAMETER id="paramAgno" name="agno" attribute="value"/>
   <PARAMETER id="paramAgnoRef" name="agnoRef" attribute="value"/>
-	<PARAMETER id="paramDateFrom" name="dateFrom" attribute="value"/>
-	<PARAMETER id="paramDateFrom" name="dateFromdisplayFormat" attribute="displayformat" replace="xx"/>
-	<PARAMETER id="paramDateFrom" name="dateFromsaveFormat" attribute="saveformat" replace="yy"/>
-	<PARAMETER id="paramDateTo" name="dateTo" attribute="value"/>
-	<PARAMETER id="paramDateTo" name="dateTodisplayFormat" attribute="displayformat" replace="xx"/>
-	<PARAMETER id="paramDateTo" name="dateTosaveFormat" attribute="saveformat" replace="yy"/>
-	<PARAMETER id="paramDateFromRef" name="dateFromRef" attribute="value"/>
-	<PARAMETER id="paramDateFromRef" name="dateFromRefdisplayFormat" attribute="displayformat" replace="xx"/>
-	<PARAMETER id="paramDateFromRef" name="dateFromRefsaveFormat" attribute="saveformat" replace="yy"/>
-	<PARAMETER id="paramDateToRef" name="dateToRef" attribute="value"/>
-	<PARAMETER id="paramDateToRef" name="dateToRefdisplayFormat" attribute="displayformat" replace="xx"/>
-	<PARAMETER id="paramDateToRef" name="dateToRefsaveFormat" attribute="saveformat" replace="yy"/>
+  <PARAMETER id="paramDateFrom" name="dateFrom" attribute="value"/>
+  <PARAMETER id="paramDateFrom" name="dateFromdisplayFormat" attribute="displayformat" replace="xx"/>
+  <PARAMETER id="paramDateFrom" name="dateFromsaveFormat" attribute="saveformat" replace="yy"/>
+  <PARAMETER id="paramDateTo" name="dateTo" attribute="value"/>
+  <PARAMETER id="paramDateTo" name="dateTodisplayFormat" attribute="displayformat" replace="xx"/>
+  <PARAMETER id="paramDateTo" name="dateTosaveFormat" attribute="saveformat" replace="yy"/>
+  <PARAMETER id="paramAsDateTo" name="asDateTo" attribute="value"/>
+  <PARAMETER id="paramAsDateTo" name="asDateTodisplayFormat" attribute="displayformat" replace="xx"/>
+  <PARAMETER id="paramAsDateTo" name="dateTodisplayFormat" attribute="saveformat" replace="yy"/>
+  <PARAMETER id="paramAsDateToRef" name="asDateToRef" attribute="value"/>
+  <PARAMETER id="paramAsDateToRef" name="asDateToRefdisplayFormat" attribute="displayformat" replace="xx"/>
+  <PARAMETER id="paramAsDateToRef" name="asDateToRefsaveFormat" attribute="saveformat" replace="yy"/>
+  <PARAMETER id="paramDateFromRef" name="dateFromRef" attribute="value"/>
+  <PARAMETER id="paramDateFromRef" name="dateFromRefdisplayFormat" attribute="displayformat" replace="xx"/>
+  <PARAMETER id="paramDateFromRef" name="dateFromRefsaveFormat" attribute="saveformat" replace="yy"/>
+  <PARAMETER id="paramDateToRef" name="dateToRef" attribute="value"/>
+  <PARAMETER id="paramDateToRef" name="dateToRefdisplayFormat" attribute="displayformat" replace="xx"/>
+  <PARAMETER id="paramDateToRef" name="dateToRefsaveFormat" attribute="saveformat" replace="yy"/>
   <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"/>
@@ -70,7 +76,16 @@
     <ARGUMENT name="parameterListSelected" withId="paramLevel"/>
   </SUBREPORT>
 
-	 <SUBREPORT id="reportC_ACCTSCHEMA_ID" name="reportC_ACCTSCHEMA_ID" report="org/openbravo/erpCommon/reference/List">
-	   <ARGUMENT name="parameterListSelected" withId="paramC_ACCTSCHEMA_ID"/>
-	</SUBREPORT>       
+  <SUBREPORT id="reportC_ACCTSCHEMA_ID" name="reportC_ACCTSCHEMA_ID" report="org/openbravo/erpCommon/reference/List">
+    <ARGUMENT name="parameterListSelected" withId="paramC_ACCTSCHEMA_ID"/>
+  </SUBREPORT>
+
+  <SUBREPORT id="reportAgno" name="reportAgno" report="org/openbravo/erpCommon/reference/List">
+    <ARGUMENT name="parameterListSelected" withId="paramAgno"/>
+  </SUBREPORT>
+
+  <SUBREPORT id="reportAgnoRef" name="reportAgnoRef" report="org/openbravo/erpCommon/reference/List">
+    <ARGUMENT name="parameterListSelected" withId="paramAgnoRef"/>
+  </SUBREPORT>
+       
 </REPORT>
--- a/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql	Mon Jun 08 21:55:51 2009 +0200
+++ b/src/org/openbravo/erpCommon/ad_reports/GeneralAccountingReports_data.xsql	Tue Jun 09 19:29:58 2009 +0200
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SL 
- * All portions are Copyright (C) 2001-2006 Openbravo SL 
+ * All portions are Copyright (C) 2001-2009 Openbravo SL 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -26,7 +26,7 @@
   <SqlMethod name="selectCombo" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
-        SELECT A_O.AD_ORG_ID AS ID, A_O.NAME, '' as pagebreak, '' AS PADRE, '' AS ISBALANCED
+        SELECT A_O.AD_ORG_ID AS ID, A_O.NAME, '' as pagebreak, '' AS PADRE, '' AS ISBALANCED, '' AS BEGINING, '' AS END, '' AS PREVIOUS_YEAR, '' AS PREVIOUS_YEAR_ID
         FROM AD_ORG A_O, AD_ROLE_ORGACCESS A_R_O, AD_ROLE R
         WHERE A_R_O.AD_ORG_ID = A_O.AD_ORG_ID 
         AND A_R_O.ISACTIVE = 'Y' 
@@ -41,7 +41,7 @@
    <SqlMethod name="selectRpt" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql><![CDATA[
-		SELECT C_ACCT_RPT_ID AS ID, NAME, ISORGBALANCED AS ISBALANCED
+		SELECT REPORTTYPE || C_ACCT_RPT_ID AS ID, NAME, ISORGBALANCED AS ISBALANCED
 		FROM C_ACCT_RPT
 		WHERE AD_ORG_ID IN ('1')
 		AND AD_CLIENT_ID IN ('1')
@@ -55,7 +55,7 @@
    <SqlMethod name="selectRptDouble" type="preparedStatement" return="multiple">
       <SqlMethodComment></SqlMethodComment>
       <Sql>
-		SELECT C_ACCT_RPT.C_ACCTSCHEMA_ID AS PADRE, C_ACCT_RPT.C_ACCT_RPT_ID AS ID, C_ACCT_RPT.NAME AS NAME 
+		SELECT C_ACCT_RPT.C_ACCTSCHEMA_ID AS PADRE, REPORTTYPE || C_ACCT_RPT.C_ACCT_RPT_ID AS ID, C_ACCT_RPT.NAME AS NAME 
 		FROM C_ACCT_RPT
 		ORDER BY NAME
       </Sql>
@@ -152,28 +152,6 @@
     <Parameter name="client"/>
   </SqlMethod>
 
-  <SqlMethod name="yearStartDate" type="preparedStatement" return="string">
-    <SqlMethodComment></SqlMethodComment>
-    <Sql>
-        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="dateFormat"/>
-    <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="">
     <SqlMethodComment></SqlMethodComment>
     <Sql>
@@ -199,14 +177,93 @@
      AND FACT_ACCT.ACCOUNT_ID = AA.C_ELEMENTVALUE_ID
      AND FACT_ACCT.FACTACCTTYPE <> 'R'
      AND 1=1
-     AND C_YEAR.YEAR = ?
+     AND C_YEAR.YEAR IN ('1')
      AND FACT_ACCT.AD_ORG_ID IN ('1')
       ]]></Sql>
         <Parameter name="accountType"/>
         <Parameter name="dateFrom" optional="true" after="AND 1=1"><![CDATA[ AND FACT_ACCT.DATEACCT >= TO_DATE(?)]]></Parameter>
         <Parameter name="dateTo" optional="true" after="AND 1=1"><![CDATA[ AND FACT_ACCT.DATEACCT < TO_DATE(?)]]></Parameter>
         <Parameter name="acctschema" optional="true" after="AND 1=1"><![CDATA[ AND FACT_ACCT.C_ACCTSCHEMA_ID = ?]]></Parameter>
-        <Parameter name="year"/>
+        <Parameter name="year" optional="true" type="replace" after="AND C_YEAR.YEAR IN (" text="'1'"/>
         <Parameter name="adOrgId" optional="true" type="replace" after="AND FACT_ACCT.AD_ORG_ID IN (" text="'1'"/>
    </SqlMethod>
+   <SqlMethod name="checkFiscalYears" type="preparedStatement" return="multiple" default="">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql><![CDATA[
+        SELECT CASE WHEN PREVIOUS.CLOSE_FACT_ACCT_GROUP_ID IS NULL THEN 'N' ELSE 'Y' END || SELECTED.C_YEAR_ID AS ID,
+          C_YEAR.YEAR AS NAME
+        FROM C_PERIOD PREVIOUS, C_PERIOD SELECTED, C_YEAR
+        WHERE PREVIOUS.AD_CLIENT_ID = ?
+          AND SELECTED.AD_CLIENT_ID = ?
+          AND SELECTED.ISACTIVE = 'Y'
+          AND C_YEAR.ISACTIVE = 'Y'
+          AND PREVIOUS.ENDDATE = SELECTED.STARTDATE-1
+          AND PREVIOUS.ENDDATE IN (
+            SELECT MAX(P.ENDDATE) AS END
+            FROM C_PERIOD P, C_YEAR Y
+            WHERE P.AD_CLIENT_ID = ?
+              AND Y.C_YEAR_ID = P.C_YEAR_ID
+            GROUP BY Y.YEAR, P.C_YEAR_ID
+          )
+          AND C_YEAR.C_YEAR_ID = SELECTED.C_YEAR_ID
+        UNION
+        SELECT 'M'||Y.C_YEAR_ID AS ID, Y.YEAR AS NAME
+        FROM C_PERIOD P, C_YEAR Y
+        WHERE P.AD_CLIENT_ID=?
+          AND P.C_YEAR_ID = Y.C_YEAR_ID
+          AND P.ISACTIVE = 'Y'
+          AND Y.ISACTIVE = 'Y'
+          AND P.STARTDATE-1 NOT IN (
+                SELECT ENDDATE
+                FROM C_PERIOD
+                WHERE C_PERIOD.AD_CLIENT_ID = ?
+          )
+        ORDER BY NAME DESC
+      ]]></Sql>
+        <Parameter name="adClientId"/>
+        <Parameter name="adClientId"/>
+        <Parameter name="adClientId"/>
+        <Parameter name="adClientId"/>
+        <Parameter name="adClientId"/>
+   </SqlMethod>
+   <SqlMethod name="previousYear" type="preparedStatement" return="multiple" default="">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql><![CDATA[
+        SELECT A.ID, A.NAME, Y.YEAR AS PREVIOUS_YEAR, Y.C_YEAR_ID AS PREVIOUS_YEAR_ID
+        FROM (
+                SELECT MIN(P.STARTDATE) AS BEGINING, MAX(P.ENDDATE) AS END, Y.YEAR AS NAME, Y.C_YEAR_ID AS ID
+                FROM C_PERIOD P, C_YEAR Y
+                WHERE P.AD_CLIENT_ID = ?
+                  AND Y.C_YEAR_ID = P.C_YEAR_ID
+                GROUP BY Y.C_YEAR_ID, Y.YEAR
+             ) A, C_YEAR Y, C_PERIOD P
+        WHERE P.ENDDATE = A.BEGINING-1
+          AND Y.AD_CLIENT_ID = ?
+          AND P.AD_CLIENT_ID = ?
+          AND P.C_YEAR_ID = Y.C_YEAR_ID
+        ]]></Sql>
+        <Parameter name="adClientId"/>
+        <Parameter name="adClientId"/>
+        <Parameter name="adClientId"/>
+   </SqlMethod>
+   <SqlMethod name="startEndYear" type="preparedStatement" return="multiple" default="">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql><![CDATA[
+          SELECT MIN(P.STARTDATE) AS BEGINING, MAX(P.ENDDATE) AS END, Y.YEAR AS NAME, Y.C_YEAR_ID AS ID
+          FROM C_PERIOD P, C_YEAR Y
+          WHERE P.AD_CLIENT_ID=?
+            AND Y.C_YEAR_ID = P.C_YEAR_ID
+            AND Y.C_YEAR_ID IN ('1')
+          GROUP BY Y.C_YEAR_ID, Y.YEAR
+        ]]></Sql>
+        <Parameter name="adClientId"/>
+        <Parameter name="cYearId" optional="true" type="replace" after="AND Y.C_YEAR_ID IN (" text="'1'"/>
+   </SqlMethod>
+   <SqlMethod name="selectCalculateOpening" type="preparedStatement" return="String" default="">
+      <SqlMethodComment></SqlMethodComment>
+      <Sql><![CDATA[
+          SELECT REPORTTYPE FROM C_ACCT_RPT WHERE C_ACCT_RPT_ID=?
+        ]]></Sql>
+        <Parameter name="cAcctRptId"/>
+   </SqlMethod>
 </SqlClass>
--- a/src/org/openbravo/erpCommon/businessUtility/AccountTree_data.xsql	Mon Jun 08 21:55:51 2009 +0200
+++ b/src/org/openbravo/erpCommon/businessUtility/AccountTree_data.xsql	Tue Jun 09 19:29:58 2009 +0200
@@ -75,7 +75,7 @@
             AND 0=0 AND f.AD_ORG_ID IN ('1')
             AND f.C_PERIOD_ID = p.C_PERIOD_ID 
             AND p.C_YEAR_ID = y.C_YEAR_ID
-            AND y.YEAR = ? 
+            AND Y.YEAR IN ('1') 
         UNION ALL
         SELECT m.C_ElementValue_ID as id, 0 AS QTY, 0 as qtyCredit, (COALESCE(f.AMTACCTDR,0) - COALESCE(f.AMTACCTCR, 0)) AS qty_ref, 
                 (COALESCE(f.AMTACCTCR,0) - COALESCE(f.AMTACCTDR, 0)) AS qtyCredit_ref 
@@ -90,7 +90,7 @@
             AND 1=1 AND f.AD_ORG_ID IN ('1')
             AND f.C_PERIOD_ID = p.C_PERIOD_ID 
             AND p.C_YEAR_ID = y.C_YEAR_ID
-            AND y.YEAR = ? 
+            AND y.YEAR IN ('1') 
         ) AA
         GROUP BY ID
       ]]></Sql>
@@ -100,14 +100,14 @@
         <Parameter name="dateTo" optional="true" after="AND 1=1 "><![CDATA[ AND f.DATEACCT < to_date(?)]]></Parameter>
         <Parameter name="acctschema" optional="true" after="AND 1=1 "><![CDATA[ AND f.C_ACCTSCHEMA_ID = ?]]></Parameter>
         <Parameter name="org" optional="true" type="replace" after="AND 0=0 AND f.AD_ORG_ID IN (" text="'1'"/>
-        <Parameter name="agno"/>
+        <Parameter name="agno" optional="true" type="replace" after="AND Y.YEAR IN (" text="'1'"/>
         <Parameter name="adOrgClient" type="replace" optional="true" after="m.AD_Org_ID IN(" text="'2'"/>
         <Parameter name="adUserClient" type="replace" optional="true" after="m.AD_Client_ID IN(" text="'2'"/>
         <Parameter name="dateFromRef" optional="true" after="AND 2=2 "><![CDATA[ AND f.DATEACCT >= to_date(?)]]></Parameter>
         <Parameter name="dateToRef" optional="true" after="AND 2=2 "><![CDATA[ AND f.DATEACCT < to_date(?)]]></Parameter>
         <Parameter name="acctschema" optional="true" after="AND 2=2 "><![CDATA[ AND f.C_ACCTSCHEMA_ID = ?]]></Parameter>
         <Parameter name="org" optional="true" type="replace" after="AND 1=1 AND f.AD_ORG_ID IN (" text="'1'"/>
-        <Parameter name="agnoRef"/>
+        <Parameter name="agnoRef" optional="true" type="replace" after="AND y.YEAR IN (" text="'1'"/>
   </SqlMethod>
   <SqlMethod name="selectForms" type="preparedStatement" return="multiple">
     <SqlMethodComment></SqlMethodComment>