Fixes Bug 28289: Manage null start and fix backdated from dates in Costing Rule.
authorUnai Martirena <unai.martirena@openbravo.com>
Wed, 17 Dec 2014 13:56:07 +0100
changeset 25626 e6a74e90eb49
parent 25625 9425fd00c025
child 25627 81546bd2df3d
Fixes Bug 28289: Manage null start and fix backdated from dates in Costing Rule.

Several things have been implemented in this changeset:
* A new Process Definition called 'Validate Costing Rule' has been created that replaces the old Process with the same name. This has been done to be able to use the new capabilities that these new kind of processes offer, like validations before executing the process and the posibility to show a confirmation popup. The new process action handler calls the old process java class, so all existing modules that may call or extend the old class they will continue working.
* The CostingRuleEventHandler has been removed, because it was doing a wrong validation and the fix backdated from date is managed in the CostingRuleProcess.
* 2 new functions have been created in CostingUtils ('getCostingRuleStartingDate' and 'getCostingRuleFixBackdatedFrom') that they return '01/01/1900' as costing rule Starting Date or Fix Backdated From when these are null. This has been done because in some places when these dates are null the application was giving an error. So, every time these dates are retrieved, these functions will be called.
* A validation has been added before executing the new Action Handler 'Validate Costing Rule' that shows a popup when transactions without cost calculated are found in closed periods. It asks for confirmation to proceed or the option to cancel.
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
referencedata/sampledata/F_B_International_Group/AD_PROCESS_ACCESS.xml
referencedata/sampledata/F_B_International_Group/OBUIAPP_PROCESS_ACCESS.xml
referencedata/sampledata/QA_Testing/AD_PROCESS_ACCESS.xml
referencedata/sampledata/QA_Testing/OBUIAPP_PROCESS_ACCESS.xml
src-db/database/sourcedata/AD_COLUMN.xml
src-db/database/sourcedata/AD_ELEMENT.xml
src-db/database/sourcedata/AD_MESSAGE.xml
src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-db/database/sourcedata/AD_PROCESS.xml
src-db/database/sourcedata/OBUIAPP_PROCESS.xml
src/org/openbravo/costing/AverageCostAdjustment.java
src/org/openbravo/costing/CostAdjustmentUtils.java
src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java
src/org/openbravo/costing/CostingRuleProcess.java
src/org/openbravo/costing/CostingRuleProcessActionHandler.java
src/org/openbravo/costing/CostingRuleProcessOnProcessHandler.java
src/org/openbravo/costing/CostingServer.java
src/org/openbravo/costing/CostingUtils.java
src/org/openbravo/costing/FixBackdatedTransactionsProcess.java
src/org/openbravo/costing/StandardAlgorithm.java
src/org/openbravo/costing/StandardCostAdjustment.java
src/org/openbravo/event/CostingRuleEventHandler.java
web/js/validateCostingRuleProcess.js
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java	Wed Dec 17 13:56:07 2014 +0100
@@ -463,6 +463,7 @@
     }
     globalResources.add(createStaticResource("web/js/periodControlStatus.js", true));
     globalResources.add(createStaticResource("web/js/productCharacteristicsProcess.js", true));
+    globalResources.add(createStaticResource("web/js/validateCostingRuleProcess.js", true));
 
     return globalResources;
   }
--- a/referencedata/sampledata/F_B_International_Group/AD_PROCESS_ACCESS.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/referencedata/sampledata/F_B_International_Group/AD_PROCESS_ACCESS.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -1457,20 +1457,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[073C51DDAD154C9689761F59AF30AD12]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[42D0EEB1C66F497A90DD526DC597E6F0]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.99]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.99]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[07470913999A43AC81C6F9345D2C4ED3]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[FB740AB61B0E42B198D2C88D3A0D0CE6]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[0D4689364DDB473BB3023E4E554C8762]]></AD_ROLE_ID>
@@ -2927,20 +2913,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[0F0675ED0BE44FBE82C8059E2A39BC16]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[F3196A30B53A42778727B2852FF90C24]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.985]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.985]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[0F3F7DA24E76409DA49D3C6D5AFFE71D]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[800176]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[332225C1B45C463984B8D14A3B4F15DF]]></AD_ROLE_ID>
@@ -4117,20 +4089,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[15E795DB5F7A42F893FBB263987C1BFF]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[6DCC4F942CE944F997596B9EA51A4FEB]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.982]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.982]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[15F64AF2A3194CA38EBB82DDCD82536E]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[1005400001]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[F3196A30B53A42778727B2852FF90C24]]></AD_ROLE_ID>
@@ -5685,20 +5643,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[1DADE8312B9C4696A05CCFC83983F064]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[F77D70601AD549B19DE47965F6D48D12]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.977]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.977]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[1DB51DBBEDEB422CA882E2D883DB96E3]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[E011F492B0814A74B63CD1F3B9FF0526]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[42D0EEB1C66F497A90DD526DC597E6F0]]></AD_ROLE_ID>
@@ -15135,20 +15079,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[55061BF33EA84C8A8DDE49B9E21DB0D7]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[E669860946664B24BD1AE1ACDF2F5FC3]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.949]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.949]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[5509B92C76C84ACFA6B3F91B57FE5F1D]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[222]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[6DCC4F942CE944F997596B9EA51A4FEB]]></AD_ROLE_ID>
@@ -16059,20 +15989,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[5A3E6121B6F442078F8A9CC025BAAF26]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[0D4689364DDB473BB3023E4E554C8762]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.946]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.946]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[5A3F6D8ECD81425ABA70E6CDEC41F970]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[800024]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[DB6660F6713A4DCFA320A502B4A0E670]]></AD_ROLE_ID>
@@ -19111,20 +19027,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[6B2FA894F9124230A75E2083B61FF32E]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[8CB7726D1DCD435FAF7D1654C9560F81]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.937]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.937]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[6B4CAA8D9EEE40698DEA200A1C0F3CC3]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[212]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[9A2D4EC760704A79BAFF8FF244FE0273]]></AD_ROLE_ID>
@@ -23787,20 +23689,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[86942D84A7794C2082F1BFAB5DB2ABF4]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[1CAE17A7848D4F0BAAF21FEB17045B88]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.922]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.922]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[86A1EBE977244A4BB5FB473FF2B2E076]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[1004400000]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[9D320A774FCD4E47801DF5E03AA11F2D]]></AD_ROLE_ID>
@@ -29485,20 +29373,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[A36719A6B1AC41CDBDF09A36546D42F6]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[DB6660F6713A4DCFA320A502B4A0E670]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.905]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.905]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[A36F1CD0B7B8487799E34813DDE42AED]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[190]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[1CAE17A7848D4F0BAAF21FEB17045B88]]></AD_ROLE_ID>
@@ -36149,20 +36023,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[C9203FEC0DDF4FBCA6B01940C3600E49]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[9A2D4EC760704A79BAFF8FF244FE0273]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:45:47.884]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:45:47.884]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[C9473A6D35C94E91AF2171A4032F965D]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[800000]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[1CAE17A7848D4F0BAAF21FEB17045B88]]></AD_ROLE_ID>
--- a/referencedata/sampledata/F_B_International_Group/OBUIAPP_PROCESS_ACCESS.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/referencedata/sampledata/F_B_International_Group/OBUIAPP_PROCESS_ACCESS.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -393,6 +393,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[16E56845727047588C85B80693C36749]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[DB6660F6713A4DCFA320A502B4A0E670]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[1764A5598CC44378935AAA1C220D8E5E]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[B05273730AA14DAEA91EAC7A828C8026]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[1CAE17A7848D4F0BAAF21FEB17045B88]]></AD_ROLE_ID>
@@ -925,6 +939,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[2F8177AA6C1345989962B44BBD3EF463]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[0D4689364DDB473BB3023E4E554C8762]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[315EB14058C74CB9AC6536E4E359EC97]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[41644B58FB034B62A63D2A40F69D2664]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[6DCC4F942CE944F997596B9EA51A4FEB]]></AD_ROLE_ID>
@@ -1303,6 +1331,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[466A929A98924BFDB1CE9BAF606CE4C7]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[F77D70601AD549B19DE47965F6D48D12]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[46A392EA932145C29823EAF8D23A6516]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[D395B727675C45C98320F8A40E0768E7]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[6DCC4F942CE944F997596B9EA51A4FEB]]></AD_ROLE_ID>
@@ -1387,6 +1429,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[49BCDEF95A534411AA230DA3C197FE69]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[42D0EEB1C66F497A90DD526DC597E6F0]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[49D254188F6B4FCBA31462D2E6C5230C]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[7DC2C8DC186B4C1DB18E147911950861]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[9A2D4EC760704A79BAFF8FF244FE0273]]></AD_ROLE_ID>
@@ -3263,6 +3319,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[A44B4C3FE9FC4B2A81679FFC19F15734]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[F3196A30B53A42778727B2852FF90C24]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[A50D08884E5C45B6B167A4309D879933]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[D395B727675C45C98320F8A40E0768E7]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[E669860946664B24BD1AE1ACDF2F5FC3]]></AD_ROLE_ID>
@@ -3417,6 +3487,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[AE1CE095969B43258656C33F579F6BE8]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[6DCC4F942CE944F997596B9EA51A4FEB]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[AE348FE2E2F74C77A2D1F6B6EC1336AB]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[D395B727675C45C98320F8A40E0768E7]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[9A2D4EC760704A79BAFF8FF244FE0273]]></AD_ROLE_ID>
@@ -3627,6 +3711,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[BDB0AD042975473C82F658C18BDC3B9C]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[E669860946664B24BD1AE1ACDF2F5FC3]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[BDB3804817944E718D7EACAB2722450F]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[70E42AD47E5F4698A9ACCCAF3EB72B9E]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[1CAE17A7848D4F0BAAF21FEB17045B88]]></AD_ROLE_ID>
@@ -4243,6 +4341,34 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[E3BD8D95F3F54CD4BEFFE063FC68A032]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[8CB7726D1DCD435FAF7D1654C9560F81]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[E3CD2BA38CB74BC0BA6E8AB84F406C22]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[9A2D4EC760704A79BAFF8FF244FE0273]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[E49AF63E1BE34BC598FF3E5C05D4FADE]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[5F7C5316CB7E4598898150AC88061B1B]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[F77D70601AD549B19DE47965F6D48D12]]></AD_ROLE_ID>
@@ -4691,6 +4817,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[FE0D3B2FDF764571AAE148DEED6CCB6D]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[1CAE17A7848D4F0BAAF21FEB17045B88]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[23C59575B9CF467C9620760EB255B389]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[FE3D35FAC16F4701B6258BD96A0E1904]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[6995A4C2592D434A9E16B71E1694CBCA]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[42D0EEB1C66F497A90DD526DC597E6F0]]></AD_ROLE_ID>
--- a/referencedata/sampledata/QA_Testing/AD_PROCESS_ACCESS.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/referencedata/sampledata/QA_Testing/AD_PROCESS_ACCESS.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -2311,20 +2311,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[2FF230E06DA74D0E8BA5CAF009ABB09E]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[0256D4272D82412C9CDF41B67E362599]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:38:18.088]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:38:18.088]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[3009C96F203A4B91A6C497BB48A3D35C]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[FF80818132A4F6AD0132A573DD7A0021]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[CC6AB5B4C4B54CB79103C96AD2B90750]]></AD_ROLE_ID>
@@ -4691,20 +4677,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[5773AFAD549E498BB410FC156461CDAA]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[CC6AB5B4C4B54CB79103C96AD2B90750]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:38:18.08]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:38:18.08]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[57A97E89CFD44D16B058D93557D814AD]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[800148]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[0256D4272D82412C9CDF41B67E362599]]></AD_ROLE_ID>
@@ -10263,20 +10235,6 @@
 </AD_PROCESS_ACCESS>
 
 <AD_PROCESS_ACCESS>
-  <AD_PROCESS_ACCESS_ID><![CDATA[BD0D5AF02B3C46AEA6496E171A2FE5D8]]></AD_PROCESS_ACCESS_ID>
-  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-  <AD_ROLE_ID><![CDATA[4028E6C72959682B01295A071429011E]]></AD_ROLE_ID>
-  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
-  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-  <CREATED><![CDATA[2013-07-04 23:38:18.06]]></CREATED>
-  <CREATEDBY><![CDATA[0]]></CREATEDBY>
-  <UPDATED><![CDATA[2013-07-04 23:38:18.06]]></UPDATED>
-  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
-  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
-</AD_PROCESS_ACCESS>
-
-<AD_PROCESS_ACCESS>
   <AD_PROCESS_ACCESS_ID><![CDATA[BD1766F2E1154FB0B57E06691B0268B7]]></AD_PROCESS_ACCESS_ID>
   <AD_PROCESS_ID><![CDATA[D5B90B539C254B959045EDCA1DC99BDF]]></AD_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[4028E6C72959682B01295A071429011E]]></AD_ROLE_ID>
--- a/referencedata/sampledata/QA_Testing/OBUIAPP_PROCESS_ACCESS.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/referencedata/sampledata/QA_Testing/OBUIAPP_PROCESS_ACCESS.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -29,6 +29,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[049E1A1278FD4A28A7C73F5A06743AFA]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[4028E6C72959682B01295A071429011E]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[065117B73103407D9F4C41FFBF0EEF5A]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[C600DAD457664EFDA6B1AA76931552BA]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[CC6AB5B4C4B54CB79103C96AD2B90750]]></AD_ROLE_ID>
@@ -281,6 +295,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[48298B8AE2C0468880F9F882F8F2539D]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[0256D4272D82412C9CDF41B67E362599]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[49019FD873AC4798B8710B181BA3C016]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[653F9E5D2CCB48E081D98D000EE7CBCF]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[CC6AB5B4C4B54CB79103C96AD2B90750]]></AD_ROLE_ID>
@@ -1233,6 +1261,20 @@
 </OBUIAPP_PROCESS_ACCESS>
 
 <OBUIAPP_PROCESS_ACCESS>
+  <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[E2D99E8AC7AD4DB6B5DEFF6645240848]]></OBUIAPP_PROCESS_ACCESS_ID>
+  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+  <AD_ROLE_ID><![CDATA[CC6AB5B4C4B54CB79103C96AD2B90750]]></AD_ROLE_ID>
+  <AD_CLIENT_ID><![CDATA[4028E6C72959682B01295A070852010D]]></AD_CLIENT_ID>
+  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+  <CREATED><![CDATA[2014-12-16 10:09:05.0]]></CREATED>
+  <CREATEDBY><![CDATA[0]]></CREATEDBY>
+  <UPDATED><![CDATA[2014-12-16 10:09:05.0]]></UPDATED>
+  <UPDATEDBY><![CDATA[0]]></UPDATEDBY>
+  <ISREADWRITE><![CDATA[Y]]></ISREADWRITE>
+</OBUIAPP_PROCESS_ACCESS>
+
+<OBUIAPP_PROCESS_ACCESS>
   <OBUIAPP_PROCESS_ACCESS_ID><![CDATA[EA911F575D4E4C4D9A38548D39B57881]]></OBUIAPP_PROCESS_ACCESS_ID>
   <OBUIAPP_PROCESS_ID><![CDATA[B5C942145F354ABEBC9F16235D80D776]]></OBUIAPP_PROCESS_ID>
   <AD_ROLE_ID><![CDATA[CC6AB5B4C4B54CB79103C96AD2B90750]]></AD_ROLE_ID>
--- a/src-db/database/sourcedata/AD_COLUMN.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/src-db/database/sourcedata/AD_COLUMN.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -313314,7 +313314,7 @@
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <NAME><![CDATA[Process_Rule]]></NAME>
-<!--BA3FDC0C32A790E0E040007F01005DCC-->  <HELP><![CDATA[Validate and initialize the Costing Rule]]></HELP>
+<!--BA3FDC0C32A790E0E040007F01005DCC-->  <HELP><![CDATA[Validate and initialize the Costing Rule. It automatically creates and process the Close and Opening Physical inventories to overwrite an existing Costing Rule. If the instance is using the legacy engine costs it is mandatory to run the Cost Migration Process in advance with System Administrator role.]]></HELP>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <COLUMNNAME><![CDATA[Process_Rule]]></COLUMNNAME>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <AD_TABLE_ID><![CDATA[3CF4E9CC4AD94D63BE9DF1822E5B4239]]></AD_TABLE_ID>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <AD_REFERENCE_ID><![CDATA[28]]></AD_REFERENCE_ID>
@@ -313330,7 +313330,6 @@
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <ISENCRYPTED><![CDATA[N]]></ISENCRYPTED>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <ISSELECTIONCOLUMN><![CDATA[N]]></ISSELECTIONCOLUMN>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <AD_ELEMENT_ID><![CDATA[BA3FDC0C32A990E0E040007F01005DCC]]></AD_ELEMENT_ID>
-<!--BA3FDC0C32A790E0E040007F01005DCC-->  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <ISSESSIONATTR><![CDATA[N]]></ISSESSIONATTR>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <ISSECONDARYKEY><![CDATA[N]]></ISSECONDARYKEY>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <ISDESENCRYPTABLE><![CDATA[N]]></ISDESENCRYPTABLE>
@@ -313342,6 +313341,7 @@
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <VALIDATEONNEW><![CDATA[Y]]></VALIDATEONNEW>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <IMAGESIZEVALUESACTION><![CDATA[N]]></IMAGESIZEVALUESACTION>
 <!--BA3FDC0C32A790E0E040007F01005DCC-->  <ISUSEDSEQUENCE><![CDATA[N]]></ISUSEDSEQUENCE>
+<!--BA3FDC0C32A790E0E040007F01005DCC-->  <EM_OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></EM_OBUIAPP_PROCESS_ID>
 <!--BA3FDC0C32A790E0E040007F01005DCC--></AD_COLUMN>
 
 <!--BA4CE0755A044CF9A0651F4CD3814ACC--><AD_COLUMN>
--- a/src-db/database/sourcedata/AD_ELEMENT.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/src-db/database/sourcedata/AD_ELEMENT.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -30829,9 +30829,9 @@
 <!--BA3FDC0C32A990E0E040007F01005DCC-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
 <!--BA3FDC0C32A990E0E040007F01005DCC-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
 <!--BA3FDC0C32A990E0E040007F01005DCC-->  <COLUMNNAME><![CDATA[Process_Rule]]></COLUMNNAME>
-<!--BA3FDC0C32A990E0E040007F01005DCC-->  <NAME><![CDATA[Process_Rule]]></NAME>
-<!--BA3FDC0C32A990E0E040007F01005DCC-->  <PRINTNAME><![CDATA[Process_Rule]]></PRINTNAME>
-<!--BA3FDC0C32A990E0E040007F01005DCC-->  <HELP><![CDATA[Validate and initialize the Costing Rule]]></HELP>
+<!--BA3FDC0C32A990E0E040007F01005DCC-->  <NAME><![CDATA[Validate Costing Rule]]></NAME>
+<!--BA3FDC0C32A990E0E040007F01005DCC-->  <PRINTNAME><![CDATA[Validate Costing Rule]]></PRINTNAME>
+<!--BA3FDC0C32A990E0E040007F01005DCC-->  <HELP><![CDATA[Validate and initialize the Costing Rule. It automatically creates and process the Close and Opening Physical inventories to overwrite an existing Costing Rule. If the instance is using the legacy engine costs it is mandatory to run the Cost Migration Process in advance with System Administrator role.]]></HELP>
 <!--BA3FDC0C32A990E0E040007F01005DCC-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--BA3FDC0C32A990E0E040007F01005DCC-->  <ISGLOSSARY><![CDATA[N]]></ISGLOSSARY>
 <!--BA3FDC0C32A990E0E040007F01005DCC--></AD_ELEMENT>
--- a/src-db/database/sourcedata/AD_MESSAGE.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -16162,6 +16162,18 @@
 <!--0C94766918BF4101ACA373FB25799D72-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--0C94766918BF4101ACA373FB25799D72--></AD_MESSAGE>
 
+<!--0CCA597468C94D558DB1057AECA33933--><AD_MESSAGE>
+<!--0CCA597468C94D558DB1057AECA33933-->  <AD_MESSAGE_ID><![CDATA[0CCA597468C94D558DB1057AECA33933]]></AD_MESSAGE_ID>
+<!--0CCA597468C94D558DB1057AECA33933-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--0CCA597468C94D558DB1057AECA33933-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--0CCA597468C94D558DB1057AECA33933-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--0CCA597468C94D558DB1057AECA33933-->  <VALUE><![CDATA[CostNotCalculatedForTrxWithMovDateInPeriodClosed]]></VALUE>
+<!--0CCA597468C94D558DB1057AECA33933-->  <MSGTEXT><![CDATA[There are transactions dated on a period closed whose costs need to be calculated. If you press "OK" the cost of those transactions will be calculated but it will not be possible to post them unless you open the corresponding periods. Otherwise please enter an starting date for the costing rule within an open period]]></MSGTEXT>
+<!--0CCA597468C94D558DB1057AECA33933-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--0CCA597468C94D558DB1057AECA33933-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--0CCA597468C94D558DB1057AECA33933-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--0CCA597468C94D558DB1057AECA33933--></AD_MESSAGE>
+
 <!--0D275D0619E346B197FE50C2F45B6715--><AD_MESSAGE>
 <!--0D275D0619E346B197FE50C2F45B6715-->  <AD_MESSAGE_ID><![CDATA[0D275D0619E346B197FE50C2F45B6715]]></AD_MESSAGE_ID>
 <!--0D275D0619E346B197FE50C2F45B6715-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -17267,6 +17279,18 @@
 <!--22C5A1E8768D4F6D9968DD48D807C8D3-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--22C5A1E8768D4F6D9968DD48D807C8D3--></AD_MESSAGE>
 
+<!--2316A35743F74FA8AFD69997F421331D--><AD_MESSAGE>
+<!--2316A35743F74FA8AFD69997F421331D-->  <AD_MESSAGE_ID><![CDATA[2316A35743F74FA8AFD69997F421331D]]></AD_MESSAGE_ID>
+<!--2316A35743F74FA8AFD69997F421331D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--2316A35743F74FA8AFD69997F421331D-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--2316A35743F74FA8AFD69997F421331D-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--2316A35743F74FA8AFD69997F421331D-->  <VALUE><![CDATA[CostingRuleStartingDateNullNoPeriodClosed]]></VALUE>
+<!--2316A35743F74FA8AFD69997F421331D-->  <MSGTEXT><![CDATA[The cost of all existing transactions booked is going to be calculated as no costing rule starting date is provided.]]></MSGTEXT>
+<!--2316A35743F74FA8AFD69997F421331D-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--2316A35743F74FA8AFD69997F421331D-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--2316A35743F74FA8AFD69997F421331D-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--2316A35743F74FA8AFD69997F421331D--></AD_MESSAGE>
+
 <!--234443E5BAB34ABC892AFDE05F9C229D--><AD_MESSAGE>
 <!--234443E5BAB34ABC892AFDE05F9C229D-->  <AD_MESSAGE_ID><![CDATA[234443E5BAB34ABC892AFDE05F9C229D]]></AD_MESSAGE_ID>
 <!--234443E5BAB34ABC892AFDE05F9C229D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -22423,6 +22447,18 @@
 <!--A3F8EB17ED994625ABC723174FBBCAE7-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--A3F8EB17ED994625ABC723174FBBCAE7--></AD_MESSAGE>
 
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16--><AD_MESSAGE>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <AD_MESSAGE_ID><![CDATA[A4307E4EBD4D421DB974DE7CBB8FAE16]]></AD_MESSAGE_ID>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <VALUE><![CDATA[CostingRuleHelp]]></VALUE>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <MSGTEXT><![CDATA[Validate and initialize the Costing Rule. It automatically creates and process the Close and Opening Physical inventories to overwrite an existing Costing Rule. If the instance is using the legacy engine costs it is mandatory to run the Cost Migration Process in advance with System Administrator role.]]></MSGTEXT>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16-->  <ISINCLUDEINI18N><![CDATA[Y]]></ISINCLUDEINI18N>
+<!--A4307E4EBD4D421DB974DE7CBB8FAE16--></AD_MESSAGE>
+
 <!--A53BDE2248524E4A995AC163467B21A9--><AD_MESSAGE>
 <!--A53BDE2248524E4A995AC163467B21A9-->  <AD_MESSAGE_ID><![CDATA[A53BDE2248524E4A995AC163467B21A9]]></AD_MESSAGE_ID>
 <!--A53BDE2248524E4A995AC163467B21A9-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -24834,6 +24870,18 @@
 <!--DD486C2E01F64B2F989DE923C43D41DB-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
 <!--DD486C2E01F64B2F989DE923C43D41DB--></AD_MESSAGE>
 
+<!--DD89935E99164E87897CEE1CC67F5BB0--><AD_MESSAGE>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <AD_MESSAGE_ID><![CDATA[DD89935E99164E87897CEE1CC67F5BB0]]></AD_MESSAGE_ID>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <VALUE><![CDATA[FixBackdateFromBeforeStartingDate]]></VALUE>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <MSGTEXT><![CDATA[Fix Backdated From Date is before Starting Date, and this is wrong. It should be equal or later.]]></MSGTEXT>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--DD89935E99164E87897CEE1CC67F5BB0-->  <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--DD89935E99164E87897CEE1CC67F5BB0--></AD_MESSAGE>
+
 <!--DD9A9C93BB2842F79A517817303A6934--><AD_MESSAGE>
 <!--DD9A9C93BB2842F79A517817303A6934-->  <AD_MESSAGE_ID><![CDATA[DD9A9C93BB2842F79A517817303A6934]]></AD_MESSAGE_ID>
 <!--DD9A9C93BB2842F79A517817303A6934-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -3857,18 +3857,6 @@
 <!--6DAAF7531ABD453383873AA790B1967A-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--6DAAF7531ABD453383873AA790B1967A--></AD_MODEL_OBJECT>
 
-<!--6E4B444F00A742AD86F4C8E013884933--><AD_MODEL_OBJECT>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <AD_MODEL_OBJECT_ID><![CDATA[6E4B444F00A742AD86F4C8E013884933]]></AD_MODEL_OBJECT_ID>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <ACTION><![CDATA[P]]></ACTION>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <CLASSNAME><![CDATA[org.openbravo.costing.CostingRuleProcess]]></CLASSNAME>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <ISDEFAULT><![CDATA[Y]]></ISDEFAULT>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-<!--6E4B444F00A742AD86F4C8E013884933-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
-<!--6E4B444F00A742AD86F4C8E013884933--></AD_MODEL_OBJECT>
-
 <!--70AAEDDC523E44C6B903E7DAFD3C3228--><AD_MODEL_OBJECT>
 <!--70AAEDDC523E44C6B903E7DAFD3C3228-->  <AD_MODEL_OBJECT_ID><![CDATA[70AAEDDC523E44C6B903E7DAFD3C3228]]></AD_MODEL_OBJECT_ID>
 <!--70AAEDDC523E44C6B903E7DAFD3C3228-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/AD_PROCESS.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/src-db/database/sourcedata/AD_PROCESS.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -6542,28 +6542,6 @@
 <!--9EB2228A60684C0DBEC12D5CD8D85218-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
 <!--9EB2228A60684C0DBEC12D5CD8D85218--></AD_PROCESS>
 
-<!--A269DCA4DE114E438695B66E166999B4--><AD_PROCESS>
-<!--A269DCA4DE114E438695B66E166999B4-->  <AD_PROCESS_ID><![CDATA[A269DCA4DE114E438695B66E166999B4]]></AD_PROCESS_ID>
-<!--A269DCA4DE114E438695B66E166999B4-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--A269DCA4DE114E438695B66E166999B4-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--A269DCA4DE114E438695B66E166999B4-->  <VALUE><![CDATA[CostingRuleProcess]]></VALUE>
-<!--A269DCA4DE114E438695B66E166999B4-->  <NAME><![CDATA[Validate Costing Rule]]></NAME>
-<!--A269DCA4DE114E438695B66E166999B4-->  <HELP><![CDATA[Validate and initialize the Costing Rule. It automatically creates and process the Close and Opening Physical inventories to overwrite an existing Costing Rule. If the instance is using the legacy engine costs it is mandatory to run the Cost Migration Process in advance with System Administrator role.]]></HELP>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISUSERSTARTABLE><![CDATA[N]]></ISUSERSTARTABLE>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISREPORT><![CDATA[N]]></ISREPORT>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISDIRECTPRINT><![CDATA[N]]></ISDIRECTPRINT>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISJASPER><![CDATA[N]]></ISJASPER>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISEXTERNALSERVICE><![CDATA[N]]></ISEXTERNALSERVICE>
-<!--A269DCA4DE114E438695B66E166999B4-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--A269DCA4DE114E438695B66E166999B4-->  <UIPATTERN><![CDATA[S]]></UIPATTERN>
-<!--A269DCA4DE114E438695B66E166999B4-->  <ISADVANCEDFEATURE><![CDATA[N]]></ISADVANCEDFEATURE>
-<!--A269DCA4DE114E438695B66E166999B4-->  <PREVENTCONCURRENT><![CDATA[N]]></PREVENTCONCURRENT>
-<!--A269DCA4DE114E438695B66E166999B4-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
-<!--A269DCA4DE114E438695B66E166999B4--></AD_PROCESS>
-
 <!--A34A85C161B342E0916642E86842086F--><AD_PROCESS>
 <!--A34A85C161B342E0916642E86842086F-->  <AD_PROCESS_ID><![CDATA[A34A85C161B342E0916642E86842086F]]></AD_PROCESS_ID>
 <!--A34A85C161B342E0916642E86842086F-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Tue Dec 09 10:03:20 2014 +0100
+++ b/src-db/database/sourcedata/OBUIAPP_PROCESS.xml	Wed Dec 17 13:56:07 2014 +0100
@@ -72,6 +72,27 @@
 <!--41644B58FB034B62A63D2A40F69D2664-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
 <!--41644B58FB034B62A63D2A40F69D2664--></OBUIAPP_PROCESS>
 
+<!--45ED6D0400FD42BEA9771C549A9AE8AB--><OBUIAPP_PROCESS>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <OBUIAPP_PROCESS_ID><![CDATA[45ED6D0400FD42BEA9771C549A9AE8AB]]></OBUIAPP_PROCESS_ID>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <VALUE><![CDATA[Validate Costing Rule]]></VALUE>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <NAME><![CDATA[Validate Costing Rule]]></NAME>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <HELP><![CDATA[Validate and initialize the Costing Rule. It automatically creates and process the Close and Opening Physical inventories to overwrite an existing Costing Rule. If the instance is using the legacy engine costs it is mandatory to run the Cost Migration Process in advance with System Administrator role.]]></HELP>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <ACCESSLEVEL><![CDATA[3]]></ACCESSLEVEL>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <CLASSNAME><![CDATA[org.openbravo.costing.CostingRuleProcessActionHandler]]></CLASSNAME>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <ISBACKGROUND><![CDATA[N]]></ISBACKGROUND>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <UIPATTERN><![CDATA[OBUIAPP_PickAndExecute]]></UIPATTERN>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <ISMULTIRECORD><![CDATA[N]]></ISMULTIRECORD>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <IS_EXPLICIT_ACCESS><![CDATA[N]]></IS_EXPLICIT_ACCESS>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <CLIENTSIDEVALIDATION><![CDATA[OB.ValidateCostingRule.onProcess]]></CLIENTSIDEVALIDATION>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <ISGRIDLEGACY><![CDATA[N]]></ISGRIDLEGACY>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <ON_LOAD_FUNCTION><![CDATA[OB.ValidateCostingRule.onLoad]]></ON_LOAD_FUNCTION>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB-->  <ISCANADDRECORDSTOSELECTOR><![CDATA[N]]></ISCANADDRECORDSTOSELECTOR>
+<!--45ED6D0400FD42BEA9771C549A9AE8AB--></OBUIAPP_PROCESS>
+
 <!--4AD70293357245AB96E59C2CDB43A35D--><OBUIAPP_PROCESS>
 <!--4AD70293357245AB96E59C2CDB43A35D-->  <OBUIAPP_PROCESS_ID><![CDATA[4AD70293357245AB96E59C2CDB43A35D]]></OBUIAPP_PROCESS_ID>
 <!--4AD70293357245AB96E59C2CDB43A35D-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/costing/AverageCostAdjustment.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java	Wed Dec 17 13:56:07 2014 +0100
@@ -570,7 +570,7 @@
     trxQry.setNamedParameter("product", trx.getProduct());
     if (costingRule.isBackdatedTransactionsFixed()) {
       trxQry.setNamedParameter("mvtdate", trx.getMovementDate());
-      trxQry.setNamedParameter("fixbdt", costingRule.getFixbackdatedfrom());
+      trxQry.setNamedParameter("fixbdt", CostingUtils.getCostingRuleFixBackdatedFrom(costingRule));
     }
     trxQry.setNamedParameter("trxtypeprio",
         CostAdjustmentUtils.getTrxTypePrio(trx.getMovementType()));
@@ -584,7 +584,7 @@
     if (costingRule.getEndingDate() != null) {
       trxQry.setNamedParameter("enddate", costingRule.getEndingDate());
     }
-    trxQry.setNamedParameter("startdate", costingRule.getStartingDate());
+    trxQry.setNamedParameter("startdate", CostingUtils.getCostingRuleStartingDate(costingRule));
 
     return trxQry.scroll(ScrollMode.FORWARD_ONLY);
   }
@@ -603,7 +603,8 @@
   protected void calculateNegativeStockCorrectionAdjustmentAmount(CostAdjustmentLine costAdjLine) {
     MaterialTransaction basetrx = costAdjLine.getInventoryTransaction();
     boolean areBaseTrxBackdatedFixed = getCostingRule().isBackdatedTransactionsFixed()
-        && !getCostingRule().getFixbackdatedfrom().before(basetrx.getTransactionProcessDate());
+        && !CostingUtils.getCostingRuleFixBackdatedFrom(getCostingRule()).before(
+            basetrx.getTransactionProcessDate());
     BigDecimal currentStock = CostAdjustmentUtils.getStockOnTransactionDate(getCostOrg(), basetrx,
         getCostDimensions(), isManufacturingProduct, areBaseTrxBackdatedFixed);
     BigDecimal currentValueAmt = CostAdjustmentUtils.getValuedStockOnTransactionDate(getCostOrg(),
--- a/src/org/openbravo/costing/CostAdjustmentUtils.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/CostAdjustmentUtils.java	Wed Dec 17 13:56:07 2014 +0100
@@ -280,7 +280,7 @@
     Date backdatedTrxFrom = null;
     if (backdatedTransactionsFixed) {
       CostingRule costRule = CostingUtils.getCostDimensionRule(org, date);
-      backdatedTrxFrom = costRule.getFixbackdatedfrom();
+      backdatedTrxFrom = CostingUtils.getCostingRuleFixBackdatedFrom(costRule);
     }
 
     Object trxprocessDate = trxsubQry.uniqueResult();
@@ -413,7 +413,7 @@
 
     if (costingRule.isBackdatedTransactionsFixed()) {
       trxQry.setParameter("mvtdate", trx.getMovementDate());
-      trxQry.setParameter("fixbdt", costingRule.getFixbackdatedfrom());
+      trxQry.setParameter("fixbdt", CostingUtils.getCostingRuleFixBackdatedFrom(costingRule));
     }
 
     if (costDimensions.get(CostDimension.Warehouse) != null) {
@@ -502,7 +502,7 @@
     Date backdatedTrxFrom = null;
     if (backdatedTransactionsFixed) {
       CostingRule costRule = CostingUtils.getCostDimensionRule(org, date);
-      backdatedTrxFrom = costRule.getFixbackdatedfrom();
+      backdatedTrxFrom = CostingUtils.getCostingRuleFixBackdatedFrom(costRule);
     }
 
     Object trxprocessDate = trxsubQry.uniqueResult();
@@ -673,7 +673,7 @@
     trxQry.setParameter("trxid", trx.getId());
     if (costingRule.isBackdatedTransactionsFixed()) {
       trxQry.setParameter("mvtdate", trx.getMovementDate());
-      trxQry.setParameter("fixbdt", costingRule.getFixbackdatedfrom());
+      trxQry.setParameter("fixbdt", CostingUtils.getCostingRuleFixBackdatedFrom(costingRule));
     }
 
     trxQry.setParameterList("orgs", orgs);
--- a/src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/CostingAlgorithmAdjustmentImp.java	Wed Dec 17 13:56:07 2014 +0100
@@ -96,10 +96,11 @@
     trxType = CostingServer.TrxType.getTrxType(transaction);
     CostingRule costingRule = costingServer.getCostingRule();
     strCostingRuleId = costingRule.getId();
-    startingDate = costingRule.getStartingDate();
+    startingDate = CostingUtils.getCostingRuleStartingDate(costingRule);
     strClientId = costingRule.getClient().getId();
     areBackdatedTrxFixed = costingRule.isBackdatedTransactionsFixed()
-        && !transaction.getTransactionProcessDate().before(costingRule.getFixbackdatedfrom());
+        && !transaction.getTransactionProcessDate().before(
+            CostingUtils.getCostingRuleFixBackdatedFrom(costingRule));
 
     HashMap<CostDimension, BaseOBObject> costDimensions = CostingUtils.getEmptyDimensions();
     // Production products cannot be calculated by warehouse dimension.
--- a/src/org/openbravo/costing/CostingRuleProcess.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/CostingRuleProcess.java	Wed Dec 17 13:56:07 2014 +0100
@@ -77,6 +77,11 @@
       OBContext.setAdminMode(false);
       final String ruleId = (String) bundle.getParams().get("M_Costing_Rule_ID");
       CostingRule rule = OBDal.getInstance().get(CostingRule.class, ruleId);
+      if (rule.getStartingDate() != null && rule.getFixbackdatedfrom() != null
+          && rule.isBackdatedTransactionsFixed()
+          && rule.getFixbackdatedfrom().before(rule.getStartingDate())) {
+        throw new OBException("@FixBackdateFromBeforeStartingDate@");
+      }
       if (rule.getOrganization().getCurrency() == null) {
         throw new OBException("@NoCurrencyInCostingRuleOrg@");
       }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/costing/CostingRuleProcessActionHandler.java	Wed Dec 17 13:56:07 2014 +0100
@@ -0,0 +1,95 @@
+/*
+ *************************************************************************
+ * 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) 2012-2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.costing;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.client.application.process.BaseProcessActionHandler;
+import org.openbravo.client.kernel.RequestContext;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.utility.OBError;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.scheduling.ProcessBundle;
+import org.openbravo.service.db.DalConnectionProvider;
+import org.openbravo.service.db.DbUtility;
+
+public class CostingRuleProcessActionHandler extends BaseProcessActionHandler {
+  private static final Logger log4j = Logger.getLogger(CostingRuleProcessActionHandler.class);
+  private static final String costingRuleTabId = "6868B706DA8340158DE353A6C252A564";
+
+  @Override
+  protected JSONObject doExecute(Map<String, Object> parameters, String content) {
+    JSONObject jsonResponse = new JSONObject();
+    JSONObject msg = new JSONObject();
+    final VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
+    ConnectionProvider conn = new DalConnectionProvider(true);
+    try {
+      OBContext.setAdminMode(true);
+      JSONObject jsonRequest = new JSONObject(content);
+      final String ruleId = (String) jsonRequest.get("M_Costing_Rule_ID");
+      String processId = (String) parameters.get("processId");
+
+      // Intitilize the Process Bundle
+      ProcessBundle bundle = new ProcessBundle(processId, vars).init(conn);
+      HashMap<String, Object> params = new HashMap<String, Object>();
+      params.put("M_Costing_Rule_ID", ruleId);
+      params.put("adOrgId", vars.getStringParameter("inpadOrgId"));
+      params.put("adClientId", vars.getStringParameter("inpadClientId"));
+      params.put("tabId", costingRuleTabId);
+      bundle.setParams(params);
+
+      // Initialize CostingRuleProcess
+      CostingRuleProcess process = new CostingRuleProcess();
+      process.execute(bundle);
+      OBError result = (OBError) bundle.getResult();
+      if (result.getType().equalsIgnoreCase("error")) {
+        msg.put("severity", "error");
+      } else if (result.getType().equalsIgnoreCase("success")) {
+        msg.put("severity", "success");
+      }
+      msg.put("title", result.getTitle());
+      msg.put("text", Utility.parseTranslation(new DalConnectionProvider(false), vars,
+          vars.getLanguage(), result.getMessage()));
+      jsonResponse.put("message", msg);
+    } catch (Exception e) {
+      OBDal.getInstance().rollbackAndClose();
+      Throwable ex = DbUtility.getUnderlyingSQLException(e);
+      String message = OBMessageUtils.translateError(ex.getMessage()).getMessage();
+      log4j.error(message, e);
+      try {
+        msg = new JSONObject();
+        msg.put("severity", "error");
+        msg.put("text", message);
+        msg.put("title", OBMessageUtils.messageBD("Error"));
+        jsonResponse.put("message", msg);
+      } catch (Exception ignore) {
+      }
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    return jsonResponse;
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/openbravo/costing/CostingRuleProcessOnProcessHandler.java	Wed Dec 17 13:56:07 2014 +0100
@@ -0,0 +1,189 @@
+/*
+ *************************************************************************
+ * 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) 2012-2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
+package org.openbravo.costing;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.client.kernel.RequestContext;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.security.OrganizationStructureProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.dal.service.OBQuery;
+import org.openbravo.erpCommon.utility.OBDateUtils;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.common.plm.Product;
+import org.openbravo.model.financialmgmt.calendar.Period;
+import org.openbravo.model.financialmgmt.calendar.PeriodControl;
+import org.openbravo.model.materialmgmt.cost.CostingRule;
+import org.openbravo.model.materialmgmt.transaction.MaterialTransaction;
+import org.openbravo.service.db.DalConnectionProvider;
+import org.openbravo.service.db.DbUtility;
+
+public class CostingRuleProcessOnProcessHandler extends BaseActionHandler {
+  private static final Logger log4j = Logger.getLogger(CostingRuleProcessOnProcessHandler.class);
+
+  @Override
+  protected JSONObject execute(Map<String, Object> parameters, String content) {
+    JSONObject jsonResponse = new JSONObject();
+    JSONObject msg = new JSONObject();
+    final VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
+    try {
+      OBContext.setAdminMode(true);
+      JSONObject jsonRequest = new JSONObject(content);
+      final String ruleId = jsonRequest.getString("ruleId");
+      CostingRule rule = OBDal.getInstance().get(CostingRule.class, ruleId);
+      OrganizationStructureProvider osp = OBContext.getOBContext()
+          .getOrganizationStructureProvider(rule.getClient().getId());
+      final Set<String> childOrgs = osp.getChildTree(rule.getOrganization().getId(), true);
+      final Set<String> naturalOrgs = osp.getNaturalTree(rule.getOrganization().getId());
+
+      String message = null;
+      // Checks
+      CostingRule prevCostingRule = getPreviousRule(rule);
+      boolean existsPreviousRule = prevCostingRule != null;
+      boolean existsTransactions = existsTransactions(naturalOrgs, childOrgs);
+      if (!existsPreviousRule && existsTransactions) {
+        if (!rule.getOrganization().getOrganizationType().isLegalEntity()
+            && rule.getStartingDate() == null) {
+          message = Utility.parseTranslation(new DalConnectionProvider(false), vars,
+              vars.getLanguage(), "@CostingRuleStartingDateNullNoPeriodClosed@");
+        } else if (rule.getOrganization().getOrganizationType().isLegalEntity()) {
+          Date movementDateInClosedPeriod = checkTransactionsWithMovDateInClosedPeriod(naturalOrgs,
+              childOrgs, rule);
+          if (movementDateInClosedPeriod != null) {
+            message = Utility.parseTranslation(new DalConnectionProvider(false), vars,
+                vars.getLanguage(), "@CostNotCalculatedForTrxWithMovDateInPeriodClosed@");
+          } else if (movementDateInClosedPeriod == null && rule.getStartingDate() == null) {
+            message = Utility.parseTranslation(new DalConnectionProvider(false), vars,
+                vars.getLanguage(), "@CostingRuleStartingDateNullNoPeriodClosed@");
+          }
+        }
+      }
+      msg.put("severity", "success");
+      msg.put("title", "Success");
+      msg.put("text", message);
+      jsonResponse.put("message", msg);
+    } catch (Exception e) {
+      OBDal.getInstance().rollbackAndClose();
+      Throwable ex = DbUtility.getUnderlyingSQLException(e);
+      String message = OBMessageUtils.translateError(ex.getMessage()).getMessage();
+      log4j.error(message, e);
+      try {
+        msg = new JSONObject();
+        msg.put("severity", "error");
+        msg.put("text", message);
+        msg.put("title", OBMessageUtils.messageBD("Error"));
+        jsonResponse.put("message", msg);
+      } catch (Exception ignore) {
+      }
+    } finally {
+      OBContext.restorePreviousMode();
+    }
+    return jsonResponse;
+  }
+
+  private Date checkTransactionsWithMovDateInClosedPeriod(Set<String> naturalOrgs,
+      Set<String> childOrgs, CostingRule rule) {
+    StringBuilder hql = new StringBuilder();
+    final Session session = OBDal.getInstance().getSession();
+    hql.append(" select min(trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE + ")");
+    hql.append(" from " + MaterialTransaction.ENTITY_NAME + " as trx");
+    hql.append(" join trx." + MaterialTransaction.PROPERTY_PRODUCT + " as p");
+    hql.append("\n where trx." + MaterialTransaction.PROPERTY_ISCOSTCALCULATED + " = false");
+    hql.append("   and p." + Product.PROPERTY_PRODUCTTYPE + " = 'I'");
+    hql.append("   and p." + Product.PROPERTY_STOCKED + " = true");
+    hql.append("  and p." + Product.PROPERTY_ORGANIZATION + ".id in (:porgs)");
+    hql.append("   and trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE + " >= :startingDate");
+    hql.append("   and trx." + MaterialTransaction.PROPERTY_ORGANIZATION + ".id in (:childOrgs)");
+    hql.append("   and exists");
+    hql.append("     (select 1 from " + PeriodControl.ENTITY_NAME + " pc");
+    hql.append("       inner join  pc." + PeriodControl.PROPERTY_PERIOD + " p");
+    hql.append("       where " + PeriodControl.PROPERTY_PERIODSTATUS + " <>'O'");
+    hql.append("       and p." + Period.PROPERTY_CLIENT + "= :client");
+    hql.append("       and pc." + PeriodControl.PROPERTY_ORGANIZATION + "= :org");
+    hql.append("       and to_date(trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE
+        + ") >= p.startingDate");
+    hql.append("       and to_date(trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE
+        + ") < p.endingDate + 1)");
+
+    final Query query = session.createQuery(hql.toString());
+
+    query.setParameterList("porgs", naturalOrgs);
+    query.setParameter("startingDate", CostingUtils.getCostingRuleStartingDate(rule));
+    query.setParameterList("childOrgs", childOrgs);
+    query.setParameter("client", rule.getClient());
+    query.setParameter("org", rule.getOrganization());
+
+    Date movementDateInPeriodClosed = null;
+    try {
+      movementDateInPeriodClosed = (Date) query.uniqueResult();
+      if (movementDateInPeriodClosed != null) {
+        movementDateInPeriodClosed = OBDateUtils.getDate(OBDateUtils
+            .formatDate(movementDateInPeriodClosed));
+      }
+    } catch (ParseException e) {
+      log4j.error("Error executing process", e);
+    }
+
+    return movementDateInPeriodClosed;
+  }
+
+  private CostingRule getPreviousRule(CostingRule rule) {
+    StringBuffer where = new StringBuffer();
+    where.append(" as cr");
+    where.append(" where cr." + CostingRule.PROPERTY_ORGANIZATION + " = :ruleOrg");
+    where.append("   and cr." + CostingRule.PROPERTY_VALIDATED + " = true");
+    where.append("   order by cr." + CostingRule.PROPERTY_STARTINGDATE + " desc");
+
+    OBQuery<CostingRule> crQry = OBDal.getInstance().createQuery(CostingRule.class,
+        where.toString());
+    crQry.setFilterOnReadableOrganization(false);
+    crQry.setNamedParameter("ruleOrg", rule.getOrganization());
+    crQry.setMaxResult(1);
+    return (CostingRule) crQry.uniqueResult();
+  }
+
+  private boolean existsTransactions(Set<String> naturalOrgs, Set<String> childOrgs) {
+    StringBuffer where = new StringBuffer();
+    where.append(" as p");
+    where.append(" where p." + Product.PROPERTY_PRODUCTTYPE + " = 'I'");
+    where.append("   and p." + Product.PROPERTY_STOCKED + " = true");
+    where.append("   and p." + Product.PROPERTY_ORGANIZATION + ".id in (:porgs)");
+    where.append("   and exists (select 1 from " + MaterialTransaction.ENTITY_NAME);
+    where.append("     where " + MaterialTransaction.PROPERTY_PRODUCT + " = p");
+    where
+        .append("      and " + MaterialTransaction.PROPERTY_ORGANIZATION + " .id in (:childOrgs))");
+
+    OBQuery<Product> pQry = OBDal.getInstance().createQuery(Product.class, where.toString());
+    pQry.setFilterOnReadableOrganization(false);
+    pQry.setNamedParameter("porgs", naturalOrgs);
+    pQry.setNamedParameter("childOrgs", childOrgs);
+    return pQry.count() > 0;
+  }
+}
--- a/src/org/openbravo/costing/CostingServer.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/CostingServer.java	Wed Dec 17 13:56:07 2014 +0100
@@ -229,9 +229,10 @@
     }
 
     if (getCostingRule().isBackdatedTransactionsFixed()
-        && transaction.getMovementDate().after(getCostingRule().getStartingDate())
+        && transaction.getMovementDate().after(
+            CostingUtils.getCostingRuleStartingDate(getCostingRule()))
         && CostAdjustmentUtils.isNeededBackdatedCostAdjustment(transaction, getCostingRule()
-            .isWarehouseDimension(), getCostingRule().getStartingDate())) {
+            .isWarehouseDimension(), CostingUtils.getCostingRuleStartingDate(getCostingRule()))) {
       // BDT= Backdated transaction
       CostAdjustment costAdjustmentHeader = CostAdjustmentUtils.insertCostAdjustmentHeader(
           transaction.getOrganization(), "BDT");
--- a/src/org/openbravo/costing/CostingUtils.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/CostingUtils.java	Wed Dec 17 13:56:07 2014 +0100
@@ -19,6 +19,7 @@
 package org.openbravo.costing;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
@@ -548,4 +549,40 @@
     }
     return null;
   }
+
+  /**
+   * Returns the Starting Date of a Costing Rule, if is null returns 01/01/1900
+   */
+  public static Date getCostingRuleStartingDate(CostingRule rule) {
+    if (rule.getStartingDate() == null) {
+      SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy");
+      try {
+        return outputFormat.parse("01-01-1900");
+      } catch (ParseException e) {
+        // Error parsing the date.
+        log4j.error("Error parsing the date.", e);
+        return null;
+      }
+    } else {
+      return rule.getStartingDate();
+    }
+  }
+
+  /**
+   * Returns the Fix Backdated From of a Costing Rule, if is null returns 01/01/1900
+   */
+  public static Date getCostingRuleFixBackdatedFrom(CostingRule rule) {
+    if (rule.getStartingDate() == null) {
+      SimpleDateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy");
+      try {
+        return outputFormat.parse("01-01-1900");
+      } catch (ParseException e) {
+        // Error parsing the date.
+        log4j.error("Error parsing the date.", e);
+        return null;
+      }
+    } else {
+      return rule.getStartingDate();
+    }
+  }
 }
--- a/src/org/openbravo/costing/FixBackdatedTransactionsProcess.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/FixBackdatedTransactionsProcess.java	Wed Dec 17 13:56:07 2014 +0100
@@ -76,7 +76,7 @@
         } catch (ParseException ignore) {
         }
       } else {
-        fixbackdatedfrom = rule.getStartingDate();
+        fixbackdatedfrom = CostingUtils.getCostingRuleStartingDate(rule);
       }
       rule.setFixbackdatedfrom(fixbackdatedfrom);
       try {
@@ -92,7 +92,7 @@
           while (transactions.next()) {
             MaterialTransaction trx = (MaterialTransaction) transactions.get()[0];
             if (CostAdjustmentUtils.isNeededBackdatedCostAdjustment(trx,
-                rule.isWarehouseDimension(), rule.getStartingDate())) {
+                rule.isWarehouseDimension(), CostingUtils.getCostingRuleStartingDate(rule))) {
               createCostAdjustmenHeader(rule.getOrganization());
               CostAdjustmentLine cal = CostAdjustmentUtils.insertCostAdjustmentLine(trx,
                   costAdjHeader, null, Boolean.TRUE, trx.getMovementDate());
--- a/src/org/openbravo/costing/StandardAlgorithm.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/StandardAlgorithm.java	Wed Dec 17 13:56:07 2014 +0100
@@ -84,7 +84,7 @@
       return true;
     }
     return !CostAdjustmentUtils.isNeededBackdatedCostAdjustment(transaction,
-        costingRule.isWarehouseDimension(), costingRule.getStartingDate());
+        costingRule.isWarehouseDimension(), CostingUtils.getCostingRuleStartingDate(costingRule));
   }
 
   private void insertCost(Costing currentCosting, BigDecimal newCost) {
--- a/src/org/openbravo/costing/StandardCostAdjustment.java	Tue Dec 09 10:03:20 2014 +0100
+++ b/src/org/openbravo/costing/StandardCostAdjustment.java	Wed Dec 17 13:56:07 2014 +0100
@@ -147,7 +147,7 @@
     if (warehouse != null) {
       trxQry.setNamedParameter("warehouse", warehouse);
     }
-    trxQry.setNamedParameter("startdate", costingRule.getStartingDate());
+    trxQry.setNamedParameter("startdate", CostingUtils.getCostingRuleStartingDate(costingRule));
 
     return trxQry.scroll(ScrollMode.FORWARD_ONLY);
 
--- a/src/org/openbravo/event/CostingRuleEventHandler.java	Tue Dec 09 10:03:20 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-/*
- *************************************************************************
- * 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-2014 Openbravo SLU
- * All Rights Reserved.
- * Contributor(s):  ______________________________________.
- *************************************************************************
- */
-package org.openbravo.event;
-
-import java.text.ParseException;
-import java.util.Date;
-
-import javax.enterprise.event.Observes;
-
-import org.apache.log4j.Logger;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.openbravo.base.exception.OBException;
-import org.openbravo.base.model.Entity;
-import org.openbravo.base.model.ModelProvider;
-import org.openbravo.base.model.Property;
-import org.openbravo.client.kernel.event.EntityNewEvent;
-import org.openbravo.client.kernel.event.EntityPersistenceEvent;
-import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
-import org.openbravo.client.kernel.event.EntityUpdateEvent;
-import org.openbravo.dal.service.OBDal;
-import org.openbravo.erpCommon.utility.OBDateUtils;
-import org.openbravo.erpCommon.utility.OBMessageUtils;
-import org.openbravo.model.materialmgmt.cost.CostingRule;
-
-public class CostingRuleEventHandler extends EntityPersistenceEventObserver {
-  private static Entity[] entities = { ModelProvider.getInstance().getEntity(
-      CostingRule.ENTITY_NAME) };
-  protected Logger logger = Logger.getLogger(this.getClass());
-
-  @Override
-  protected Entity[] getObservedEntities() {
-    return entities;
-  }
-
-  public void onSave(@Observes
-  EntityUpdateEvent event) {
-    if (!isValidEvent(event)) {
-      return;
-    }
-    final Entity costingRule = ModelProvider.getInstance().getEntity(CostingRule.ENTITY_NAME);
-    final Property genericProperty = costingRule
-        .getProperty(CostingRule.PROPERTY_BACKDATEDTRANSACTIONSFIXED);
-    Boolean isbackdatedtransaction = (Boolean) event.getCurrentState(genericProperty);
-    CostingRule rule = (CostingRule) event.getTargetInstance();
-    checkFixBackdatedFrom(isbackdatedtransaction, rule, event, costingRule);
-  }
-
-  public void onUpdate(@Observes
-  EntityUpdateEvent event) {
-    if (!isValidEvent(event)) {
-      return;
-    }
-    final Entity costingRule = ModelProvider.getInstance().getEntity(CostingRule.ENTITY_NAME);
-    final Property genericProperty = costingRule
-        .getProperty(CostingRule.PROPERTY_BACKDATEDTRANSACTIONSFIXED);
-    Boolean isbackdatedtransaction = (Boolean) event.getCurrentState(genericProperty);
-    CostingRule rule = (CostingRule) event.getTargetInstance();
-    checkFixBackdatedFrom(isbackdatedtransaction, rule, event, costingRule);
-  }
-
-  public void onNew(@Observes
-  EntityNewEvent event) {
-    if (!isValidEvent(event)) {
-      return;
-    }
-    final Entity costingRule = ModelProvider.getInstance().getEntity(CostingRule.ENTITY_NAME);
-    final Property genericProperty = costingRule
-        .getProperty(CostingRule.PROPERTY_BACKDATEDTRANSACTIONSFIXED);
-    Boolean isbackdatedtransaction = (Boolean) event.getCurrentState(genericProperty);
-    CostingRule rule = (CostingRule) event.getTargetInstance();
-    checkFixBackdatedFrom(isbackdatedtransaction, rule, event, costingRule);
-  }
-
-  private void checkFixBackdatedFrom(Boolean isbackdatedtransaction, CostingRule rule,
-      EntityPersistenceEvent event, Entity costingRule) {
-    StringBuilder hql = new StringBuilder();
-    final Session session = OBDal.getInstance().getSession();
-    hql.append("select min(p.startingDate)  from FinancialMgmtPeriodControl pc"
-        + " inner join  pc.period p" + " where  periodstatus='O' " + " and p.client= :client"
-        + " and pc.organization= :org ");
-
-    final Query query = session.createQuery(hql.toString());
-    query.setParameter("client", rule.getClient());
-    query.setParameter("org", rule.getOrganization());
-
-    try {
-      Date lastPeriodStartingDate = OBDateUtils.getDate(OBDateUtils.formatDate((Date) query
-          .uniqueResult()));
-      final Property ruleStartingDateProperty = costingRule
-          .getProperty(CostingRule.PROPERTY_STARTINGDATE);
-      final Property ruleFixBackDatedFromProperty = costingRule
-          .getProperty(CostingRule.PROPERTY_FIXBACKDATEDFROM);
-      if (rule.getStartingDate() == null) {
-        rule.setStartingDate(lastPeriodStartingDate);
-        event.setCurrentState(ruleStartingDateProperty, lastPeriodStartingDate);
-        OBDal.getInstance().save(rule);
-      }
-      if (isbackdatedtransaction) {
-        if (rule.getFixbackdatedfrom() == null && !(rule.getStartingDate() == null)) {
-          rule.setFixbackdatedfrom(rule.getStartingDate());
-          event.setCurrentState(ruleFixBackDatedFromProperty, rule.getStartingDate());
-        }
-      }
-      if (rule.getFixbackdatedfrom() != null) {
-        if (rule.getFixbackdatedfrom().before(lastPeriodStartingDate)) {
-          throw new OBException(OBMessageUtils.messageBD("WrongFixBackdatedFrom"));
-        }
-      }
-
-    } catch (HibernateException e) {
-      logger.error("Error executing process", e);
-    } catch (ParseException e) {
-      logger.error("Error executing process", e);
-    }
-  }
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/js/validateCostingRuleProcess.js	Wed Dec 17 13:56:07 2014 +0100
@@ -0,0 +1,48 @@
+/*
+ *************************************************************************
+ * 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) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ ************************************************************************
+ */
+
+OB.ValidateCostingRule = {};
+
+
+OB.ValidateCostingRule.onLoad = function (view) {
+  view.messageBar.setMessage(isc.OBMessageBar.TYPE_INFO, null, OB.I18N.getLabel('CostingRuleHelp'));
+};
+
+
+OB.ValidateCostingRule.onProcess = function (view, actionHandlerCall) {
+  var callbackOnProcessActionHandler, execute;
+  callbackOnProcessActionHandler = function (response, data, request) {
+    execute = function (ok) {
+      if (ok) {
+        actionHandlerCall(view);
+      } else {
+        view.parentElement.parentElement.closeClick();
+      }
+    };
+    if (data.message.text) {
+      isc.confirm(data.message.text, execute);
+    } else {
+      actionHandlerCall(view);
+    }
+  };
+  view.messageBar.setMessage(isc.OBMessageBar.TYPE_INFO, null, OB.I18N.getLabel('CostingRuleHelp'));
+  OB.RemoteCallManager.call('org.openbravo.costing.CostingRuleProcessOnProcessHandler', {
+    ruleId: view.parentWindow.view.lastRecordSelected.id
+  }, {}, callbackOnProcessActionHandler);
+};
\ No newline at end of file