Fixed 22300 Reset accouting process refactor
authorSandra Huguet <sandra.huguet@openbravo.com>
Thu, 14 Mar 2013 15:08:23 +0100
changeset 19920 768fee4f6be2
parent 19919 6798cd18b7cb
child 19921 6e8aa43cb4a4
Fixed 22300 Reset accouting process refactor
src-db/database/sourcedata/AD_MENU.xml
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_PROCESS.xml
src-db/database/sourcedata/AD_PROCESS_PARA.xml
src-db/database/sourcedata/AD_TABLE.xml
src-db/database/sourcedata/AD_TREENODE.xml
src/org/openbravo/erpCommon/ad_actionButton/Posted.java
src/org/openbravo/erpCommon/ad_process/ResetAccountingProcess.java
src/org/openbravo/financial/ResetAccounting.java
--- a/src-db/database/sourcedata/AD_MENU.xml	Fri Mar 15 10:37:14 2013 +0100
+++ b/src-db/database/sourcedata/AD_MENU.xml	Thu Mar 14 15:08:23 2013 +0100
@@ -1373,8 +1373,8 @@
 <!--307-->  <AD_MENU_ID><![CDATA[307]]></AD_MENU_ID>
 <!--307-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--307-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--307-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--307-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--307-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
+<!--307-->  <NAME><![CDATA[Reset Accounting Old]]></NAME>
 <!--307-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
 <!--307-->  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
 <!--307-->  <ACTION><![CDATA[P]]></ACTION>
@@ -4668,6 +4668,19 @@
 <!--C62EBC52C8DF463B9B720D52F250A8CF-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--C62EBC52C8DF463B9B720D52F250A8CF--></AD_MENU>
 
+<!--CC8E287A0B0743D69C53D8F678F9AD41--><AD_MENU>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_MENU_ID><![CDATA[CC8E287A0B0743D69C53D8F678F9AD41]]></AD_MENU_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <ISSUMMARY><![CDATA[N]]></ISSUMMARY>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <ACTION><![CDATA[P]]></ACTION>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--CC8E287A0B0743D69C53D8F678F9AD41--></AD_MENU>
+
 <!--D13B4DBDCBF747BB9A91B17CBC6D1AA5--><AD_MENU>
 <!--D13B4DBDCBF747BB9A91B17CBC6D1AA5-->  <AD_MENU_ID><![CDATA[D13B4DBDCBF747BB9A91B17CBC6D1AA5]]></AD_MENU_ID>
 <!--D13B4DBDCBF747BB9A91B17CBC6D1AA5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Fri Mar 15 10:37:14 2013 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Thu Mar 14 15:08:23 2013 +0100
@@ -4172,6 +4172,18 @@
 <!--BAA507E4C79F498DE040007F010077E2-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--BAA507E4C79F498DE040007F010077E2--></AD_MODEL_OBJECT>
 
+<!--BB0F6F0167694601A4D521F13B5D4F1E--><AD_MODEL_OBJECT>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_MODEL_OBJECT_ID><![CDATA[BB0F6F0167694601A4D521F13B5D4F1E]]></AD_MODEL_OBJECT_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <ACTION><![CDATA[P]]></ACTION>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <CLASSNAME><![CDATA[org.openbravo.erpCommon.ad_process.ResetAccountingProcess]]></CLASSNAME>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--BB0F6F0167694601A4D521F13B5D4F1E-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
+<!--BB0F6F0167694601A4D521F13B5D4F1E--></AD_MODEL_OBJECT>
+
 <!--BB540F2CEA514936B5E60216ACE844B3--><AD_MODEL_OBJECT>
 <!--BB540F2CEA514936B5E60216ACE844B3-->  <AD_MODEL_OBJECT_ID><![CDATA[BB540F2CEA514936B5E60216ACE844B3]]></AD_MODEL_OBJECT_ID>
 <!--BB540F2CEA514936B5E60216ACE844B3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS.xml	Fri Mar 15 10:37:14 2013 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS.xml	Thu Mar 14 15:08:23 2013 +0100
@@ -1243,9 +1243,9 @@
 <!--176-->  <AD_PROCESS_ID><![CDATA[176]]></AD_PROCESS_ID>
 <!--176-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
 <!--176-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--176-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--176-->  <ISACTIVE><![CDATA[N]]></ISACTIVE>
 <!--176-->  <VALUE><![CDATA[Fact_Acct_Reset DELETE]]></VALUE>
-<!--176-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--176-->  <NAME><![CDATA[Reset Accounting Old]]></NAME>
 <!--176-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
 <!--176-->  <HELP><![CDATA[The reset accounting process allows to totally or partially remove the ledger entries of an organization. The ledger entries can be massively re-created again by using the "Accounting Server Process" or the "G/L Posting by DB Tables" process. ]]></HELP>
 <!--176-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
@@ -6446,6 +6446,28 @@
 <!--DFC78024B1F54CBB95DC73425BA6687F-->  <PREVENTCONCURRENT><![CDATA[N]]></PREVENTCONCURRENT>
 <!--DFC78024B1F54CBB95DC73425BA6687F--></AD_PROCESS>
 
+<!--E264309FF8244A94936502BF51829109--><AD_PROCESS>
+<!--E264309FF8244A94936502BF51829109-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--E264309FF8244A94936502BF51829109-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E264309FF8244A94936502BF51829109-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E264309FF8244A94936502BF51829109-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E264309FF8244A94936502BF51829109-->  <VALUE><![CDATA[Reset Accounting]]></VALUE>
+<!--E264309FF8244A94936502BF51829109-->  <NAME><![CDATA[Reset Accounting]]></NAME>
+<!--E264309FF8244A94936502BF51829109-->  <DESCRIPTION><![CDATA[Reset Accounting Entries]]></DESCRIPTION>
+<!--E264309FF8244A94936502BF51829109-->  <HELP><![CDATA[The reset accounting process allows to totally or partially remove the ledger entries of an organization. The ledger entries can be massively re-created again by using the "Accounting Server Process" or the "G/L Posting by DB Tables" process.]]></HELP>
+<!--E264309FF8244A94936502BF51829109-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
+<!--E264309FF8244A94936502BF51829109-->  <ISUSERSTARTABLE><![CDATA[N]]></ISUSERSTARTABLE>
+<!--E264309FF8244A94936502BF51829109-->  <ISREPORT><![CDATA[N]]></ISREPORT>
+<!--E264309FF8244A94936502BF51829109-->  <ISDIRECTPRINT><![CDATA[N]]></ISDIRECTPRINT>
+<!--E264309FF8244A94936502BF51829109-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--E264309FF8244A94936502BF51829109-->  <ISJASPER><![CDATA[N]]></ISJASPER>
+<!--E264309FF8244A94936502BF51829109-->  <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
+<!--E264309FF8244A94936502BF51829109-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--E264309FF8244A94936502BF51829109-->  <UIPATTERN><![CDATA[S]]></UIPATTERN>
+<!--E264309FF8244A94936502BF51829109-->  <ISADVANCEDFEATURE><![CDATA[N]]></ISADVANCEDFEATURE>
+<!--E264309FF8244A94936502BF51829109-->  <PREVENTCONCURRENT><![CDATA[N]]></PREVENTCONCURRENT>
+<!--E264309FF8244A94936502BF51829109--></AD_PROCESS>
+
 <!--E5BE98DCF4514A18B571F21183B397DD--><AD_PROCESS>
 <!--E5BE98DCF4514A18B571F21183B397DD-->  <AD_PROCESS_ID><![CDATA[E5BE98DCF4514A18B571F21183B397DD]]></AD_PROCESS_ID>
 <!--E5BE98DCF4514A18B571F21183B397DD-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Fri Mar 15 10:37:14 2013 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS_PARA.xml	Thu Mar 14 15:08:23 2013 +0100
@@ -4043,6 +4043,26 @@
 <!--208021A9537641BAB0AFC4294453D59F-->  <AD_ELEMENT_ID><![CDATA[275]]></AD_ELEMENT_ID>
 <!--208021A9537641BAB0AFC4294453D59F--></AD_PROCESS_PARA>
 
+<!--33829BDE12A849CE8CF9CBF773DE556A--><AD_PROCESS_PARA>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_PROCESS_PARA_ID><![CDATA[33829BDE12A849CE8CF9CBF773DE556A]]></AD_PROCESS_PARA_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <NAME><![CDATA[Table]]></NAME>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <DESCRIPTION><![CDATA[A dictionary table used for this tab that points to the database table.]]></DESCRIPTION>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <HELP><![CDATA[The Table indicates the table in which a field or fields reside.]]></HELP>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <SEQNO><![CDATA[30]]></SEQNO>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_REFERENCE_ID><![CDATA[18]]></AD_REFERENCE_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_REFERENCE_VALUE_ID><![CDATA[800022]]></AD_REFERENCE_VALUE_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <COLUMNNAME><![CDATA[AD_Table_ID]]></COLUMNNAME>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--33829BDE12A849CE8CF9CBF773DE556A-->  <AD_ELEMENT_ID><![CDATA[126]]></AD_ELEMENT_ID>
+<!--33829BDE12A849CE8CF9CBF773DE556A--></AD_PROCESS_PARA>
+
 <!--3401DE925FBB4A3AAC72E914595E1C71--><AD_PROCESS_PARA>
 <!--3401DE925FBB4A3AAC72E914595E1C71-->  <AD_PROCESS_PARA_ID><![CDATA[3401DE925FBB4A3AAC72E914595E1C71]]></AD_PROCESS_PARA_ID>
 <!--3401DE925FBB4A3AAC72E914595E1C71-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4298,6 +4318,27 @@
 <!--83BBC36B706642A39448DD2342B291F3-->  <AD_ELEMENT_ID><![CDATA[800632]]></AD_ELEMENT_ID>
 <!--83BBC36B706642A39448DD2342B291F3--></AD_PROCESS_PARA>
 
+<!--959B501B597940E8AC00F9587D83CB2D--><AD_PROCESS_PARA>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_PROCESS_PARA_ID><![CDATA[959B501B597940E8AC00F9587D83CB2D]]></AD_PROCESS_PARA_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <NAME><![CDATA[Client]]></NAME>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <DESCRIPTION><![CDATA[Client for this installation.]]></DESCRIPTION>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <HELP><![CDATA[A Client is a company or a legal entity. You cannot share data between Clients.]]></HELP>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <SEQNO><![CDATA[10]]></SEQNO>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_VAL_RULE_ID><![CDATA[103]]></AD_VAL_RULE_ID>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <COLUMNNAME><![CDATA[AD_Client_ID]]></COLUMNNAME>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <DEFAULTVALUE><![CDATA[@AD_Client_ID@]]></DEFAULTVALUE>
+<!--959B501B597940E8AC00F9587D83CB2D-->  <AD_ELEMENT_ID><![CDATA[102]]></AD_ELEMENT_ID>
+<!--959B501B597940E8AC00F9587D83CB2D--></AD_PROCESS_PARA>
+
 <!--97266E0DF6A24EC0BC6845B9E305F307--><AD_PROCESS_PARA>
 <!--97266E0DF6A24EC0BC6845B9E305F307-->  <AD_PROCESS_PARA_ID><![CDATA[97266E0DF6A24EC0BC6845B9E305F307]]></AD_PROCESS_PARA_ID>
 <!--97266E0DF6A24EC0BC6845B9E305F307-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -4589,6 +4630,83 @@
 <!--E15C3460969D4583BD954308E715C5D4-->  <AD_ELEMENT_ID><![CDATA[800653]]></AD_ELEMENT_ID>
 <!--E15C3460969D4583BD954308E715C5D4--></AD_PROCESS_PARA>
 
+<!--EAE447CD0ACE4C3B9D037847B5B5571C--><AD_PROCESS_PARA>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_PROCESS_PARA_ID><![CDATA[EAE447CD0ACE4C3B9D037847B5B5571C]]></AD_PROCESS_PARA_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <NAME><![CDATA[Delete existing Accounting Entries]]></NAME>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <DESCRIPTION><![CDATA[The selected accounting entries will be deleted!  DANGEROUS !!!]]></DESCRIPTION>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <HELP><![CDATA[The selected accounting entries will be deleted!  DANGEROUS !!!]]></HELP>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <SEQNO><![CDATA[40]]></SEQNO>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_REFERENCE_ID><![CDATA[20]]></AD_REFERENCE_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <COLUMNNAME><![CDATA[DeletePosting]]></COLUMNNAME>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <FIELDLENGTH><![CDATA[0]]></FIELDLENGTH>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C-->  <AD_ELEMENT_ID><![CDATA[1692]]></AD_ELEMENT_ID>
+<!--EAE447CD0ACE4C3B9D037847B5B5571C--></AD_PROCESS_PARA>
+
+<!--EC9EAD40499A41E6956E7A0DC9269E0A--><AD_PROCESS_PARA>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_PROCESS_PARA_ID><![CDATA[EC9EAD40499A41E6956E7A0DC9269E0A]]></AD_PROCESS_PARA_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <NAME><![CDATA[Starting Date]]></NAME>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <DESCRIPTION><![CDATA[A parameter stating the starting time range related to a specified request.]]></DESCRIPTION>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <HELP><![CDATA[The Date From indicates the starting date of a range.]]></HELP>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <SEQNO><![CDATA[50]]></SEQNO>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <COLUMNNAME><![CDATA[datefrom]]></COLUMNNAME>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A-->  <AD_ELEMENT_ID><![CDATA[1581]]></AD_ELEMENT_ID>
+<!--EC9EAD40499A41E6956E7A0DC9269E0A--></AD_PROCESS_PARA>
+
+<!--F072C56439FA47418C156337644F3CB5--><AD_PROCESS_PARA>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_PROCESS_PARA_ID><![CDATA[F072C56439FA47418C156337644F3CB5]]></AD_PROCESS_PARA_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F072C56439FA47418C156337644F3CB5-->  <NAME><![CDATA[Organization]]></NAME>
+<!--F072C56439FA47418C156337644F3CB5-->  <DESCRIPTION><![CDATA[Organizational entity within client]]></DESCRIPTION>
+<!--F072C56439FA47418C156337644F3CB5-->  <HELP><![CDATA[An organization is a unit of your client or legal entity - examples are store, department. You can share data between organizations.]]></HELP>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <SEQNO><![CDATA[20]]></SEQNO>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_REFERENCE_ID><![CDATA[19]]></AD_REFERENCE_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_VAL_RULE_ID><![CDATA[4A2C613871134B76899BA0464F3CBF76]]></AD_VAL_RULE_ID>
+<!--F072C56439FA47418C156337644F3CB5-->  <COLUMNNAME><![CDATA[AD_Org_ID]]></COLUMNNAME>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F072C56439FA47418C156337644F3CB5-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISMANDATORY><![CDATA[Y]]></ISMANDATORY>
+<!--F072C56439FA47418C156337644F3CB5-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--F072C56439FA47418C156337644F3CB5-->  <AD_ELEMENT_ID><![CDATA[113]]></AD_ELEMENT_ID>
+<!--F072C56439FA47418C156337644F3CB5--></AD_PROCESS_PARA>
+
+<!--F6B5EF335B25411CA5499D224BA4C3F3--><AD_PROCESS_PARA>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_PROCESS_PARA_ID><![CDATA[F6B5EF335B25411CA5499D224BA4C3F3]]></AD_PROCESS_PARA_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <NAME><![CDATA[Ending Date]]></NAME>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <DESCRIPTION><![CDATA[A parameter stating the ending time range related for a specified request, query, etc.]]></DESCRIPTION>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <HELP><![CDATA[The Date To indicates the end date of a range (inclusive)]]></HELP>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_PROCESS_ID><![CDATA[E264309FF8244A94936502BF51829109]]></AD_PROCESS_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <SEQNO><![CDATA[60]]></SEQNO>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_REFERENCE_ID><![CDATA[15]]></AD_REFERENCE_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <COLUMNNAME><![CDATA[dateto]]></COLUMNNAME>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISCENTRALLYMAINTAINED><![CDATA[Y]]></ISCENTRALLYMAINTAINED>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <FIELDLENGTH><![CDATA[32]]></FIELDLENGTH>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISMANDATORY><![CDATA[N]]></ISMANDATORY>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <ISRANGE><![CDATA[N]]></ISRANGE>
+<!--F6B5EF335B25411CA5499D224BA4C3F3-->  <AD_ELEMENT_ID><![CDATA[1582]]></AD_ELEMENT_ID>
+<!--F6B5EF335B25411CA5499D224BA4C3F3--></AD_PROCESS_PARA>
+
 <!--F6C130E3B2DD4414A162FC6BA4F2808E--><AD_PROCESS_PARA>
 <!--F6C130E3B2DD4414A162FC6BA4F2808E-->  <AD_PROCESS_PARA_ID><![CDATA[F6C130E3B2DD4414A162FC6BA4F2808E]]></AD_PROCESS_PARA_ID>
 <!--F6C130E3B2DD4414A162FC6BA4F2808E-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_TABLE.xml	Fri Mar 15 10:37:14 2013 +0100
+++ b/src-db/database/sourcedata/AD_TABLE.xml	Thu Mar 14 15:08:23 2013 +0100
@@ -1321,6 +1321,7 @@
 <!--224-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--224-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--224-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E54B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--224-->  <ACCTDATE_COLUMN_ID><![CDATA[1635]]></ACCTDATE_COLUMN_ID>
 <!--224--></AD_TABLE>
 
 <!--225--><AD_TABLE>
@@ -1591,6 +1592,7 @@
 <!--259-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--259-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--259-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1D94B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--259-->  <ACCTDATE_COLUMN_ID><![CDATA[2183]]></ACCTDATE_COLUMN_ID>
 <!--259--></AD_TABLE>
 
 <!--260--><AD_TABLE>
@@ -2391,6 +2393,7 @@
 <!--318-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--318-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--318-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1D84B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--318-->  <ACCTDATE_COLUMN_ID><![CDATA[3508]]></ACCTDATE_COLUMN_ID>
 <!--318--></AD_TABLE>
 
 <!--319--><AD_TABLE>
@@ -2414,6 +2417,7 @@
 <!--319-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--319-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--319-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--319-->  <ACCTDATE_COLUMN_ID><![CDATA[3794]]></ACCTDATE_COLUMN_ID>
 <!--319--></AD_TABLE>
 
 <!--320--><AD_TABLE>
@@ -2459,6 +2463,7 @@
 <!--321-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--321-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--321-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--321-->  <ACCTDATE_COLUMN_ID><![CDATA[3552]]></ACCTDATE_COLUMN_ID>
 <!--321--></AD_TABLE>
 
 <!--322--><AD_TABLE>
@@ -2503,6 +2508,7 @@
 <!--323-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--323-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--323-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--323-->  <ACCTDATE_COLUMN_ID><![CDATA[3579]]></ACCTDATE_COLUMN_ID>
 <!--323--></AD_TABLE>
 
 <!--324--><AD_TABLE>
@@ -2548,6 +2554,7 @@
 <!--325-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--325-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--325-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--325-->  <ACCTDATE_COLUMN_ID><![CDATA[3608]]></ACCTDATE_COLUMN_ID>
 <!--325--></AD_TABLE>
 
 <!--326--><AD_TABLE>
@@ -2894,6 +2901,7 @@
 <!--392-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--392-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--392-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E44B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--392-->  <ACCTDATE_COLUMN_ID><![CDATA[4918]]></ACCTDATE_COLUMN_ID>
 <!--392--></AD_TABLE>
 
 <!--393--><AD_TABLE>
@@ -3068,6 +3076,7 @@
 <!--407-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--407-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--407-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E44B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--407-->  <ACCTDATE_COLUMN_ID><![CDATA[5253]]></ACCTDATE_COLUMN_ID>
 <!--407--></AD_TABLE>
 
 <!--408--><AD_TABLE>
@@ -3433,6 +3442,7 @@
 <!--472-->  <ISDEFAULTACCT><![CDATA[Y]]></ISDEFAULTACCT>
 <!--472-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--472-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F84B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--472-->  <ACCTDATE_COLUMN_ID><![CDATA[6508]]></ACCTDATE_COLUMN_ID>
 <!--472--></AD_TABLE>
 
 <!--473--><AD_TABLE>
@@ -3456,6 +3466,7 @@
 <!--473-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--473-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--473-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F84B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--473-->  <ACCTDATE_COLUMN_ID><![CDATA[6524]]></ACCTDATE_COLUMN_ID>
 <!--473--></AD_TABLE>
 
 <!--475--><AD_TABLE>
@@ -3609,6 +3620,7 @@
 <!--486-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--486-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--486-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1FC4B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--486-->  <ACCTDATE_COLUMN_ID><![CDATA[6838]]></ACCTDATE_COLUMN_ID>
 <!--486--></AD_TABLE>
 
 <!--487--><AD_TABLE>
@@ -4305,6 +4317,7 @@
 <!--623-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--623-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--623-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F94B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--623-->  <ACCTDATE_COLUMN_ID><![CDATA[9859]]></ACCTDATE_COLUMN_ID>
 <!--623--></AD_TABLE>
 
 <!--800000--><AD_TABLE>
@@ -4673,6 +4686,7 @@
 <!--800019-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800019-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800019-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E64B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800019-->  <ACCTDATE_COLUMN_ID><![CDATA[800470]]></ACCTDATE_COLUMN_ID>
 <!--800019--></AD_TABLE>
 
 <!--800020--><AD_TABLE>
@@ -5227,6 +5241,7 @@
 <!--800060-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800060-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800060-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E24B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800060-->  <ACCTDATE_COLUMN_ID><![CDATA[801079]]></ACCTDATE_COLUMN_ID>
 <!--800060--></AD_TABLE>
 
 <!--800061--><AD_TABLE>
@@ -6532,6 +6547,7 @@
 <!--800168-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800168-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800168-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1F14B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800168-->  <ACCTDATE_COLUMN_ID><![CDATA[802758]]></ACCTDATE_COLUMN_ID>
 <!--800168--></AD_TABLE>
 
 <!--800169--><AD_TABLE>
@@ -6669,6 +6685,7 @@
 <!--800176-->  <ISDEFAULTACCT><![CDATA[N]]></ISDEFAULTACCT>
 <!--800176-->  <DEVELOPMENTSTATUS><![CDATA[RE]]></DEVELOPMENTSTATUS>
 <!--800176-->  <AD_PACKAGE_ID><![CDATA[5A3ED54AB1E64B84E040007F01006125]]></AD_PACKAGE_ID>
+<!--800176-->  <ACCTDATE_COLUMN_ID><![CDATA[802948]]></ACCTDATE_COLUMN_ID>
 <!--800176--></AD_TABLE>
 
 <!--800177--><AD_TABLE>
--- a/src-db/database/sourcedata/AD_TREENODE.xml	Fri Mar 15 10:37:14 2013 +0100
+++ b/src-db/database/sourcedata/AD_TREENODE.xml	Thu Mar 14 15:08:23 2013 +0100
@@ -2779,7 +2779,7 @@
 <!--52118BF1A3284D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A3284D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A3284D84E040007F01005FEC-->  <PARENT_ID><![CDATA[800254]]></PARENT_ID>
-<!--52118BF1A3284D84E040007F01005FEC-->  <SEQNO><![CDATA[60]]></SEQNO>
+<!--52118BF1A3284D84E040007F01005FEC-->  <SEQNO><![CDATA[70]]></SEQNO>
 <!--52118BF1A3284D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A32A4D84E040007F01005FEC--><AD_TREENODE>
@@ -3054,7 +3054,7 @@
 <!--52118BF1A3464D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A3464D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A3464D84E040007F01005FEC-->  <PARENT_ID><![CDATA[800254]]></PARENT_ID>
-<!--52118BF1A3464D84E040007F01005FEC-->  <SEQNO><![CDATA[70]]></SEQNO>
+<!--52118BF1A3464D84E040007F01005FEC-->  <SEQNO><![CDATA[80]]></SEQNO>
 <!--52118BF1A3464D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A3474D84E040007F01005FEC--><AD_TREENODE>
@@ -3351,7 +3351,7 @@
 <!--52118BF1A3614D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A3614D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A3614D84E040007F01005FEC-->  <PARENT_ID><![CDATA[0]]></PARENT_ID>
-<!--52118BF1A3614D84E040007F01005FEC-->  <SEQNO><![CDATA[170]]></SEQNO>
+<!--52118BF1A3614D84E040007F01005FEC-->  <SEQNO><![CDATA[180]]></SEQNO>
 <!--52118BF1A3614D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A3624D84E040007F01005FEC--><AD_TREENODE>
@@ -3593,7 +3593,7 @@
 <!--52118BF1A3784D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A3784D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A3784D84E040007F01005FEC-->  <PARENT_ID><![CDATA[0]]></PARENT_ID>
-<!--52118BF1A3784D84E040007F01005FEC-->  <SEQNO><![CDATA[180]]></SEQNO>
+<!--52118BF1A3784D84E040007F01005FEC-->  <SEQNO><![CDATA[190]]></SEQNO>
 <!--52118BF1A3784D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A3794D84E040007F01005FEC--><AD_TREENODE>
@@ -3746,7 +3746,7 @@
 <!--52118BF1A5C94D84E040007F01005FEC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--52118BF1A5C94D84E040007F01005FEC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--52118BF1A5C94D84E040007F01005FEC-->  <PARENT_ID><![CDATA[0]]></PARENT_ID>
-<!--52118BF1A5C94D84E040007F01005FEC-->  <SEQNO><![CDATA[160]]></SEQNO>
+<!--52118BF1A5C94D84E040007F01005FEC-->  <SEQNO><![CDATA[170]]></SEQNO>
 <!--52118BF1A5C94D84E040007F01005FEC--></AD_TREENODE>
 
 <!--52118BF1A5CA4D84E040007F01005FEC--><AD_TREENODE>
@@ -4035,6 +4035,17 @@
 <!--8CB53124C58211DDB9A9001D09C4A2FE-->  <SEQNO><![CDATA[50]]></SEQNO>
 <!--8CB53124C58211DDB9A9001D09C4A2FE--></AD_TREENODE>
 
+<!--8E286E545FC6433F8BADCF02254A8C14--><AD_TREENODE>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_TREENODE_ID><![CDATA[8E286E545FC6433F8BADCF02254A8C14]]></AD_TREENODE_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_TREE_ID><![CDATA[10]]></AD_TREE_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <NODE_ID><![CDATA[CC8E287A0B0743D69C53D8F678F9AD41]]></NODE_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <PARENT_ID><![CDATA[800254]]></PARENT_ID>
+<!--8E286E545FC6433F8BADCF02254A8C14-->  <SEQNO><![CDATA[90]]></SEQNO>
+<!--8E286E545FC6433F8BADCF02254A8C14--></AD_TREENODE>
+
 <!--A14B428C6EF34B70B51C278E26BFDD43--><AD_TREENODE>
 <!--A14B428C6EF34B70B51C278E26BFDD43-->  <AD_TREENODE_ID><![CDATA[A14B428C6EF34B70B51C278E26BFDD43]]></AD_TREENODE_ID>
 <!--A14B428C6EF34B70B51C278E26BFDD43-->  <AD_TREE_ID><![CDATA[10]]></AD_TREE_ID>
--- a/src/org/openbravo/erpCommon/ad_actionButton/Posted.java	Fri Mar 15 10:37:14 2013 +0100
+++ b/src/org/openbravo/erpCommon/ad_actionButton/Posted.java	Thu Mar 14 15:08:23 2013 +0100
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2001-2012 Openbravo SLU
+ * All portions are Copyright (C) 2001-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -21,22 +21,22 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.sql.Connection;
+import java.util.HashMap;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.ad_forms.AcctServer;
-import org.openbravo.erpCommon.reference.ActionButtonData;
-import org.openbravo.erpCommon.reference.PInstanceProcessData;
 import org.openbravo.erpCommon.utility.OBError;
-import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.financial.ResetAccounting;
 import org.openbravo.model.ad.ui.Process;
 import org.openbravo.xmlEngine.XmlDocument;
 
@@ -206,7 +206,25 @@
         } else {
           if (log4j.isDebugEnabled())
             log4j.debug("SAVE, delete");
-          OBError myMessage = processButtonDelete(vars, strKey, strTableId);
+          Long inicio = System.currentTimeMillis();
+          OBError myMessage = new OBError();
+          myMessage.setType("Success");
+          PostedData[] data = PostedData.select(this, strKey, strTableId);
+          try {
+            HashMap<String, Integer> hm = ResetAccounting.delete(data[0].client, data[0].org,
+                strTableId, strKey, "", "");
+            myMessage.setMessage(Utility.parseTranslation(
+                this,
+                vars,
+                vars.getLanguage(),
+                "@UnpostedDocuments@ = " + hm.get("updated") + ", @DeletedEntries@ = "
+                    + hm.get("deleted")));
+          } catch (OBException e) {
+            myMessage.setType("Error");
+            myMessage.setMessage(Utility.parseTranslation(this, vars, vars.getLanguage(),
+                e.getMessage()));
+          }
+          System.out.println("Total deleting /milis: " + (System.currentTimeMillis() - inicio));
           vars.setMessage(strTabId, myMessage);
           printPageClosePopUp(response, vars);
         }
@@ -259,41 +277,6 @@
     return myMessage;
   }
 
-  private OBError processButtonDelete(VariablesSecureApp vars, String strKey, String strTableId)
-      throws ServletException {
-    OBError myMessage = null;
-
-    try {
-
-      String strClient = PostedData.selectClient(this,
-          PostedData.selectTableName(this, strTableId), strKey);
-      String pinstance = SequenceIdData.getUUID();
-      PInstanceProcessData.insertPInstance(this, pinstance, "176", strKey, "N", vars.getUser(),
-          vars.getClient(), vars.getOrg());
-      PInstanceProcessData.insertPInstanceParam(this, pinstance, "10", "AD_Client_ID", strClient,
-          vars.getClient(), vars.getOrg(), vars.getUser());
-      PInstanceProcessData.insertPInstanceParam(this, pinstance, "20", "AD_Table_ID", strTableId,
-          vars.getClient(), vars.getOrg(), vars.getUser());
-      PInstanceProcessData.insertPInstanceParam(this, pinstance, "30", "DeletePosting", "Y",
-          vars.getClient(), vars.getOrg(), vars.getUser());
-      if (log4j.isDebugEnabled())
-        log4j.debug("delete, pinstance " + pinstance);
-      ActionButtonData.process176(this, pinstance);
-
-      PInstanceProcessData[] pinstanceData = PInstanceProcessData.select(this, pinstance);
-      myMessage = Utility.getProcessInstanceMessage(this, vars, pinstanceData);
-    } catch (ServletException ex) {
-      myMessage = Utility.translateError(this, vars, vars.getLanguage(), ex.getMessage());
-    }
-    if (myMessage == null) {
-      myMessage = new OBError();
-      myMessage.setType("Success");
-      myMessage.setTitle("");
-      myMessage.setMessage(Utility.messageBD(this, "Success", vars.getLanguage()));
-    }
-    return myMessage;
-  }
-
   private void printPage(HttpServletResponse response, VariablesSecureApp vars, String strKey,
       String windowId, String strTab, String strProcessId, String strTableId,
       String strForcedTableId, String strPath, String strTabName, String strPosted)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/erpCommon/ad_process/ResetAccountingProcess.java	Thu Mar 14 15:08:23 2013 +0100
@@ -0,0 +1,85 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.erpCommon.ad_process;
+
+import java.util.HashMap;
+
+import org.openbravo.base.exception.OBException;
+import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.financial.ResetAccounting;
+import org.openbravo.scheduling.ProcessBundle;
+import org.openbravo.scheduling.ProcessLogger;
+import org.openbravo.service.db.DalBaseProcess;
+import org.quartz.JobExecutionException;
+
+public class ResetAccountingProcess extends DalBaseProcess {
+
+  private ProcessLogger logger;
+
+  public void doExecute(ProcessBundle bundle) throws Exception {
+    logger = bundle.getLogger();
+    try {
+      String adClientId = (String) bundle.getParams().get("adClientId");
+      String adOrgId = (String) bundle.getParams().get("adOrgId");
+      String deletePosting = (String) bundle.getParams().get("deleteposting");
+      String adTableId = (String) bundle.getParams().get("adTableId");
+      String recordId = (String) bundle.getParams().get("recordId");
+      String datefrom = (String) bundle.getParams().get("datefrom");
+      String dateto = (String) bundle.getParams().get("dateto");
+      HashMap<String, Integer> results = new HashMap<String, Integer>();
+      Long totalupdate = 0l;
+      Long inicioupdate = 0l;
+      Long finupdate = 0l;
+      inicioupdate = System.currentTimeMillis();
+      if ("Y".equals(deletePosting)) {
+        results = ResetAccounting
+            .delete(adClientId, adOrgId, adTableId, recordId, datefrom, dateto);
+      } else {
+        if (!"".equals(adTableId)) {
+          results = ResetAccounting.restore(adClientId, adOrgId, adTableId, datefrom, dateto);
+        } else {
+          results = ResetAccounting.restore(adClientId, adOrgId, datefrom, dateto);
+        }
+      }
+      finupdate = System.currentTimeMillis();
+      totalupdate = totalupdate + finupdate - inicioupdate;
+      int counter = results.get("updated");
+      int counterDeleted = results.get("deleted");
+      System.out.println("Records updated: " + counter + "\n");
+      System.out.println("Records deleted: " + counterDeleted + "\n");
+      System.out.println("totalupdate /milis:" + totalupdate);
+      OBError myError = new OBError();
+      myError.setType("Success");
+      myError.setTitle("@Success@");
+      myError.setMessage(Utility.parseTranslation(bundle.getConnection(), bundle.getContext()
+          .toVars(), bundle.getContext().toVars().getLanguage(), "@UnpostedDocuments@ = " + counter
+          + ", @DeletedEntries@ = " + counterDeleted));
+
+      bundle.setResult(myError);
+    } catch (OBException e) {
+      throw e;
+    } catch (Exception e) {
+      // catch any possible exception and throw it as a Quartz
+      // JobExecutionException
+      throw new JobExecutionException(e.getMessage(), e);
+    }
+
+  }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/financial/ResetAccounting.java	Thu Mar 14 15:08:23 2013 +0100
@@ -0,0 +1,512 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2013 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.financial;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.hibernate.Query;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.OrganizationStructureProvider;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBDateUtils;
+import org.openbravo.model.ad.datamodel.Table;
+import org.openbravo.model.ad.system.Client;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.financialmgmt.accounting.AccountingFact;
+import org.openbravo.model.financialmgmt.calendar.Period;
+
+public class ResetAccounting {
+  final static int FETCH_SIZE = 1000;
+  static Logger log4j = Logger.getLogger(ResetAccounting.class);
+
+  @SuppressWarnings("unchecked")
+  public static HashMap<String, Integer> delete(String adClientId, String adOrgId,
+      String adTableId, String recordId, String strdatefrom, String strdateto) throws OBException {
+    if (recordId == null) {
+      recordId = "";
+    }
+    Long totalProcess = System.currentTimeMillis();
+    Long inicio = 0l;
+    Long fin = 0l;
+    Long totalselect = 0l;
+    int deleted = 0;
+    int updated = 0;
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", new Integer(0));
+    results.put("updated", new Integer(0));
+    results.put("totaldeleted", new Integer(0));
+    results.put("totalupdated", new Integer(0));
+    List<String> clients = getClients(adClientId);
+    List<String> tables = getTables(adTableId);
+    try {
+      for (String client : clients) {
+        Set<String> orgIds = new OrganizationStructureProvider().getNaturalTree(adOrgId);
+        for (String table : tables) {
+          List<String> docbasetypes = getDocbasetypes(client, table, recordId);
+          String myQuery = "select distinct e.recordID from FinancialMgmtAccountingFact e where e.organization.id in (:orgIds) and e.client.id = :clientId and e.table.id = :tableId";
+          if (recordId != null && !"".equals(recordId)) {
+            myQuery = myQuery + " and e.recordID = :recordId ";
+          }
+          for (String dbt : docbasetypes) {
+            List<Date[]> periods = new ArrayList<Date[]>();
+            String calendarId = getCalendarId(adOrgId);
+            periods = getPeriodsDates(getOpenPeriods(client, dbt, orgIds, calendarId, table,
+                recordId, strdatefrom, strdateto));
+            int docUpdated = 0;
+            int docDeleted = 0;
+            for (Date[] p : periods) {
+              StringBuffer consDate = new StringBuffer();
+              consDate.append(" and e.documentCategory = '" + dbt + "'");
+              consDate.append(" and e.accountingDate >= :dateFrom and e.accountingDate <= :dateTo");
+              String exceptionsSql = myQuery + consDate.toString();
+              consDate
+                  .append(" and not exists (select a from FinancialMgmtAccountingFact a where a.recordID = e.recordID and a.table.id = e.table.id and (a.accountingDate < :dateFrom or a.accountingDate > :dateTo))");
+              final Query query = OBDal.getInstance().getSession()
+                  .createQuery(myQuery + consDate.toString());
+              if (recordId != null && !"".equals(recordId)) {
+                query.setString("recordId", recordId);
+              }
+              query.setParameterList("orgIds", orgIds);
+              query.setString("clientId", client);
+              query.setString("tableId", table);
+              query.setDate("dateFrom", p[0]);
+              query.setDate("dateTo", p[1]);
+              if (recordId != null && !"".equals(recordId)) {
+                query.setFetchSize(1);
+              } else {
+                query.setFetchSize(FETCH_SIZE);
+              }
+              inicio = System.currentTimeMillis();
+              List<String> transactions = query.list();
+              fin = System.currentTimeMillis();
+              totalselect = totalselect + fin - inicio;
+              while (transactions.size() > 0) {
+                HashMap<String, Integer> partial = delete(transactions, table, client);
+                deleted = deleted + partial.get("deleted");
+                updated = updated + partial.get("updated");
+                docUpdated = docUpdated + partial.get("updated");
+                docDeleted = docDeleted + partial.get("deleted");
+                inicio = System.currentTimeMillis();
+                transactions = query.list();
+                fin = System.currentTimeMillis();
+                totalselect = totalselect + fin - inicio;
+              }
+              // Documents with postings in different periods are treated separately to validate all
+              // dates are within an open period
+              HashMap<String, Integer> partial = treatExceptions(exceptionsSql, recordId, table,
+                  orgIds, client, p[0], p[1], calendarId, strdatefrom, strdateto);
+              deleted = deleted + partial.get("deleted");
+              updated = updated + partial.get("updated");
+              docUpdated = docUpdated + partial.get("updated");
+              docDeleted = docDeleted + partial.get("deleted");
+            }
+            log4j.debug("docBaseType: " + dbt);
+            log4j.debug("updated: " + docUpdated);
+            log4j.debug("deleted: " + docDeleted);
+          }
+        }
+      }
+    } catch (OBException e) {
+      throw e;
+    } catch (Exception e) {
+      throw new OBException("Delete failed", e);
+    }
+    results.put("deleted", deleted);
+    results.put("updated", updated);
+    log4j.debug("total totalProcess (milies): " + (System.currentTimeMillis() - totalProcess));
+    if (recordId != null && !"".equals(recordId) && deleted == 0 && updated == 0) {
+      throw new OBException("@PeriodClosedForUnPosting@");
+    }
+    return results;
+  }
+
+  private static HashMap<String, Integer> delete(List<String> transactions, String tableId,
+      String client) throws OBException {
+    HashMap<String, Integer> result = new HashMap<String, Integer>();
+    if (transactions.size() == 0) {
+      result.put("deleted", new Integer(0));
+      result.put("updated", new Integer(0));
+      return result;
+    }
+    String tableName = "";
+    OBContext.setAdminMode(false);
+    try {
+      Table table = OBDal.getInstance().get(Table.class, tableId);
+      tableName = table.getName();
+      String strUpdate = "update "
+          + tableName
+          + " set posted='N', processNow=false where (posted<>'N' or posted is null or processNow = false) and id in (:transactions) ";
+      String strDelete = "delete from FinancialMgmtAccountingFact where table.id = :tableId and recordID in (:transactions) and client.id=:clientId";
+      final Query update = OBDal.getInstance().getSession().createQuery(strUpdate);
+      update.setParameterList("transactions", transactions);
+      int updated = update.executeUpdate();
+      final Query delete = OBDal.getInstance().getSession().createQuery(strDelete);
+      delete.setString("tableId", tableId);
+      delete.setParameterList("transactions", transactions);
+      delete.setString("clientId", client);
+      int deleted = delete.executeUpdate();
+      result.put("deleted", new Integer(deleted));
+      result.put("updated", new Integer(updated));
+      OBDal.getInstance().getConnection().commit();
+      OBDal.getInstance().getSession().clear();
+      return result;
+    } catch (Exception e) {
+      OBDal.getInstance().rollbackAndClose();
+      throw new OBException("Error Deleting Accounting", e);
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  public static HashMap<String, Integer> restore(String clientId, String adOrgId, String datefrom,
+      String dateto) throws OBException {
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", new Integer(0));
+    results.put("updated", new Integer(0));
+    List<String> tableIds = getActiveTables(clientId, adOrgId);
+    for (String tableId : tableIds) {
+      HashMap<String, Integer> partial = restore(clientId, adOrgId, tableId, datefrom, dateto);
+      results.put("deleted", results.get("deleted") + partial.get("deleted"));
+      results.put("updated", results.get("updated") + partial.get("updated"));
+
+    }
+    log4j.debug("deleted: " + results.get("deleted"));
+    log4j.debug("updated: " + results.get("updated"));
+    return results;
+  }
+
+  public static HashMap<String, Integer> restore(String clientId, String adOrgId, String tableId,
+      String datefrom, String dateto) throws OBException {
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", new Integer(0));
+    results.put("updated", new Integer(0));
+    String tableName = "";
+    String tableDate = "";
+    OBContext.setAdminMode(false);
+    try {
+      Table table = OBDal.getInstance().get(Table.class, tableId);
+      tableName = table.getName();
+      tableDate = lowerCaseFirst(camelCaseIt(table.getAcctdateColumn().getName()));
+      String strUpdate = "update "
+          + tableName
+          + " set posted='N', processNow=false where posted not in ('N','Y') and processed = 'Y' and organization.id in (:orgIds)  ";
+      if (!("".equals(datefrom))) {
+        strUpdate = strUpdate + " and " + tableDate + " >= :dateFrom ";
+      }
+      if (!("".equals(dateto))) {
+        strUpdate = strUpdate + " and " + tableDate + " <= :dateTo ";
+      }
+
+      Query update = OBDal.getInstance().getSession().createQuery(strUpdate);
+      update
+          .setParameterList("orgIds", new OrganizationStructureProvider().getNaturalTree(adOrgId));
+      try {
+        if (!("".equals(datefrom))) {
+          update.setDate("dateFrom", OBDateUtils.getDate(datefrom));
+        }
+        if (!("".equals(dateto))) {
+          update.setDate("dateTo", OBDateUtils.getDate(dateto));
+        }
+      } catch (ParseException e) {
+        // TODO Auto-generated catch block
+        log4j.debug(e);
+      }
+
+      int updated = update.executeUpdate();
+      results.put("updated", new Integer(updated));
+      OBDal.getInstance().getConnection().commit();
+      OBDal.getInstance().getSession().clear();
+      return results;
+    } catch (Exception e) {
+      OBDal.getInstance().rollbackAndClose();
+      throw new OBException("Error Reseting Accounting", e);
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getClients(String clientId) {
+    String myQuery = "select e.id from ADClient e where e.id = :clientId";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    return query.list();
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getTables(String adTableId) {
+    OBContext.setAdminMode(false);
+    try {
+      List<String> accountingTables = new ArrayList<String>();
+      if (!"".equals(adTableId)) {
+        Table myTable = OBDal.getInstance().get(Table.class, adTableId);
+        accountingTables.add(myTable.getId());
+        return accountingTables;
+      }
+      String myQuery = "select distinct e.table.id from FinancialMgmtAccountingFact e where e.table.id <> '145'";
+      accountingTables = OBDal.getInstance().getSession().createQuery(myQuery).list();
+      return accountingTables;
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+  }
+
+  @SuppressWarnings("unused")
+  private static List<Organization> getOrganizations(Client client, Set<String> orgIds) {
+    final String CLIENT_SYSTEM = "0";
+    OBCriteria<Organization> obc = OBDal.getInstance().createCriteria(Organization.class);
+    if (!CLIENT_SYSTEM.equals(client.getId())) {
+      obc.add(Restrictions.eq(Organization.PROPERTY_CLIENT, client));
+    }
+    obc.add(Restrictions.in(Organization.PROPERTY_ID, orgIds));
+    obc.setFilterOnReadableClients(false);
+    obc.setFilterOnReadableOrganization(false);
+    return obc.list();
+  }
+
+  private static List<String> getDocbasetypes(String clientId, String tableId, String recordId) {
+    String myQuery = "select distinct e.documentCategory from FinancialMgmtAccountingFact e where e.client.id = :clientId and e.table.id = :tableId ";
+    if (!"".equals(recordId)) {
+      myQuery = myQuery + "and e.recordID=:recordId";
+    }
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    query.setString("tableId", tableId);
+    if (!"".equals(recordId)) {
+      query.setString("recordId", recordId);
+      query.setFetchSize(1);
+    }
+    @SuppressWarnings("unchecked")
+    List<String> docbasetypes = query.list();
+    return docbasetypes;
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<Period> getOpenPeriods(String clientId, String docBaseType,
+      Set<String> orgIds, String calendarId, String tableId, String recordId, String datefrom,
+      String dateto) {
+    if (!"".equals(recordId)) {
+      List<Period> periods = new ArrayList<Period>();
+      periods.add(getDocumentPeriod(clientId, tableId, recordId));
+      return periods;
+    }
+    String myQuery = "select distinct p from FinancialMgmtPeriodControl e left join e.period p left join p.year y left join y.calendar c where c.id = :calendarId and e.client.id = :clientId and e.documentCategory = :docbasetype and e.periodStatus = 'O'";
+
+    if (!("".equals(datefrom))) {
+      myQuery = myQuery + " and p.startingDate >= :dateFrom";
+    }
+    if (!("".equals(dateto))) {
+      myQuery = myQuery + " and p.endingDate <=  :dateTo";
+    }
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    // TODO: Review orgIds
+    // query.setParameterList("orgIds", orgIds);
+    query.setString("calendarId", calendarId);
+    query.setString("clientId", clientId);
+    query.setString("docbasetype", docBaseType);
+    try {
+      if (!("".equals(datefrom))) {
+        query.setDate("dateFrom", OBDateUtils.getDate(datefrom));
+      }
+      if (!("".equals(dateto))) {
+        query.setDate("dateTo", OBDateUtils.getDate(dateto));
+      }
+    } catch (ParseException e) {
+      // TODO Auto-generated catch block
+      log4j.debug(e);
+    }
+    return query.list();
+  }
+
+  private static Period getDocumentPeriod(String clientId, String tableId, String recordId) {
+    String myQuery = "select distinct e.period from FinancialMgmtAccountingFact e , FinancialMgmtPeriodControl p where p.period=e.period and p.periodStatus = 'O' and e.client.id = :clientId and e.table.id = :tableId and e.recordID=:recordId";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    query.setString("tableId", tableId);
+    query.setString("recordId", recordId);
+    query.setFetchSize(1);
+    @SuppressWarnings("unchecked")
+    List<Period> periods = query.list();
+    if (periods.isEmpty()) {
+      throw new OBException("@PeriodClosedForUnPosting@");
+    }
+    return periods.get(0);
+  }
+
+  private static List<Date[]> getPeriodsDates(List<Period> periods) {
+    List<Date[]> result = new ArrayList<Date[]>();
+    for (Period period : periods) {
+      Date[] dates = new Date[2];
+      dates[0] = period.getStartingDate();
+      dates[1] = period.getEndingDate();
+      result.add(dates);
+    }
+    return result;
+  }
+
+  private static String getCalendarId(String adOrgId) {
+    Organization organization = OBDal.getInstance().get(Organization.class, adOrgId);
+    if (organization.getCalendar() != null) {
+      return organization.getCalendar().getId();
+    } else {
+      return getCalendarId(new OrganizationStructureProvider().getParentOrg(adOrgId));
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getActiveTables(String clientId, String adOrgId) {
+    String myQuery = "select distinct table.id from FinancialMgmtAcctSchemaTable where accountingSchema.id in (:accountingSchemaIds) and client.id = :clientId and active= true";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    List<String> accountingSchemaIds = getAccountingSchemaIds(clientId, adOrgId);
+    query.setParameterList("accountingSchemaIds", accountingSchemaIds);
+    query.setString("clientId", clientId);
+    return query.list();
+  }
+
+  @SuppressWarnings("unchecked")
+  private static List<String> getAccountingSchemaIds(String clientId, String orgIg) {
+    String myQuery = "select distinct accountingSchema.id from OrganizationAcctSchema where client.id = :clientId and active= true and organization.id in (:orgIds)";
+    Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    query.setString("clientId", clientId);
+    query.setParameterList("orgIds", new OrganizationStructureProvider().getNaturalTree(orgIg));
+    return query.list();
+
+  }
+
+  /**
+   * 
+   * @param myQuery
+   * @param recordId
+   * @param table
+   * @param orgIds
+   * @param client
+   * @param dateFrom
+   * @param dateTo
+   */
+  private static HashMap<String, Integer> treatExceptions(String myQuery, String recordId,
+      String table, Set<String> orgIds, String client, Date dateFrom, Date dateTo,
+      String calendarId, String datefrom, String dateto) {
+    HashMap<String, Integer> results = new HashMap<String, Integer>();
+    results.put("deleted", 0);
+    results.put("updated", 0);
+    final Query query = OBDal.getInstance().getSession().createQuery(myQuery);
+    if (recordId != null && !"".equals(recordId)) {
+      query.setString("recordId", recordId);
+    }
+    query.setParameterList("orgIds", orgIds);
+    query.setString("clientId", client);
+    query.setString("tableId", table);
+    query.setDate("dateFrom", dateFrom);
+    query.setDate("dateTo", dateTo);
+    if (recordId != null && !"".equals(recordId)) {
+      query.setFetchSize(1);
+    }
+    @SuppressWarnings("unchecked")
+    List<String> transactions = query.list();
+    for (String transaction : transactions) {
+      OBCriteria<AccountingFact> factCrit = OBDal.getInstance()
+          .createCriteria(AccountingFact.class);
+      factCrit.add(Restrictions.eq(AccountingFact.PROPERTY_RECORDID, transaction));
+      factCrit.add(Restrictions.eq(AccountingFact.PROPERTY_TABLE,
+          OBDal.getInstance().get(Table.class, table)));
+      factCrit.add(Restrictions.eq(AccountingFact.PROPERTY_CLIENT,
+          OBDal.getInstance().get(Client.class, client)));
+      List<AccountingFact> facts = factCrit.list();
+      Set<Date> exceptionDates = new HashSet<Date>();
+      for (AccountingFact fact : facts) {
+        if (dateFrom.compareTo(fact.getAccountingDate()) != 0
+            || dateTo.compareTo(fact.getAccountingDate()) != 0) {
+          exceptionDates.add(fact.getAccountingDate());
+        }
+      }
+      if (checkDates(exceptionDates, client, orgIds, facts.get(0).getDocumentCategory(),
+          calendarId, datefrom, dateto)) {
+        List<String> toDelete = new ArrayList<String>();
+        toDelete.add(transaction);
+        results = delete(toDelete, table, client);
+      } else {
+        if (recordId != null && !"".equals(recordId)) {
+          throw new OBException("@PeriodClosedForUnPosting@");
+        }
+      }
+    }
+    return results;
+  }
+
+  private static boolean checkDates(Set<Date> exceptionDates, String clientId, Set<String> orgIds,
+      String documentCategory, String calendarId, String datefrom, String dateto) {
+    List<Period> openPeriods = getOpenPeriods(clientId, documentCategory, orgIds, calendarId, "",
+        "", datefrom, dateto);
+    int validDates = 0;
+    for (Period period : openPeriods) {
+      for (Date date : exceptionDates) {
+        if (date.compareTo(period.getStartingDate()) >= 0
+            && date.compareTo(period.getEndingDate()) <= 0) {
+          validDates++;
+        }
+      }
+    }
+    if (exceptionDates.size() != validDates) {
+      return false;
+    }
+    return true;
+  }
+
+  private static String camelCaseIt(String mappingName) {
+    String localMappingName = mappingName.replaceAll("_", " ");
+    String separator = " ";
+    // strip _ at the end
+    while (localMappingName.endsWith(separator)) {
+      localMappingName = localMappingName.substring(0, localMappingName.length() - 1);
+    }
+    // strip _ at the beginning
+    while (localMappingName.startsWith(separator)) {
+      localMappingName = localMappingName.substring(1);
+    }
+
+    // "CamelCasing"
+    int pos = localMappingName.indexOf(separator);
+    while (pos != -1) {
+      final String leftPart = localMappingName.substring(0, pos);
+      final String camelLetter = String.valueOf(localMappingName.charAt(pos + 1)).toUpperCase();
+      final String rightPart = localMappingName.substring(pos + 2);
+      localMappingName = leftPart + camelLetter + rightPart;
+      pos = localMappingName.indexOf(separator);
+    }
+    return localMappingName;
+  }
+
+  private static String lowerCaseFirst(String value) {
+    if (value.length() > 1) {
+      return value.substring(0, 1).toLowerCase() + value.substring(1);
+    }
+    return value;
+  }
+
+}