[costAdjs]changed preference doNotCheckBDTTrxs by flag isBDTFixed in costing rule
authorMiguel A. Alsasua <miguel.alsasua@openbravo.com>
Fri, 12 Sep 2014 10:10:11 +0200
changeset 24883 f4bdbf730b63
parent 24882 da69282b144b
child 24884 1885b76d6b03
[costAdjs]changed preference doNotCheckBDTTrxs by flag isBDTFixed in costing rule
src-db/database/sourcedata/AD_REF_LIST.xml
src/org/openbravo/costing/CostingServer.java
src/org/openbravo/costing/StandardAlgorithm.java
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Sep 12 10:07:46 2014 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Sep 12 10:10:11 2014 +0200
@@ -10613,17 +10613,6 @@
 <!--93CDB0B07AC64DB7B0C92CB3C173C1D5-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
 <!--93CDB0B07AC64DB7B0C92CB3C173C1D5--></AD_REF_LIST>
 
-<!--94016AB72D574413A0267D0B848EB120--><AD_REF_LIST>
-<!--94016AB72D574413A0267D0B848EB120-->  <AD_REF_LIST_ID><![CDATA[94016AB72D574413A0267D0B848EB120]]></AD_REF_LIST_ID>
-<!--94016AB72D574413A0267D0B848EB120-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--94016AB72D574413A0267D0B848EB120-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--94016AB72D574413A0267D0B848EB120-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--94016AB72D574413A0267D0B848EB120-->  <VALUE><![CDATA[doNotCheckBackDatedTrxs]]></VALUE>
-<!--94016AB72D574413A0267D0B848EB120-->  <NAME><![CDATA[Do Not Check BackDated Transactions]]></NAME>
-<!--94016AB72D574413A0267D0B848EB120-->  <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
-<!--94016AB72D574413A0267D0B848EB120-->  <AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
-<!--94016AB72D574413A0267D0B848EB120--></AD_REF_LIST>
-
 <!--940939F3D7DA422A8FBD46D5B477F716--><AD_REF_LIST>
 <!--940939F3D7DA422A8FBD46D5B477F716-->  <AD_REF_LIST_ID><![CDATA[940939F3D7DA422A8FBD46D5B477F716]]></AD_REF_LIST_ID>
 <!--940939F3D7DA422A8FBD46D5B477F716-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src/org/openbravo/costing/CostingServer.java	Fri Sep 12 10:07:46 2014 +0200
+++ b/src/org/openbravo/costing/CostingServer.java	Fri Sep 12 10:10:11 2014 +0200
@@ -132,7 +132,6 @@
 
   private void checkCostAdjustments() {
     boolean doNotCheckPriceCorrectionTrxs = false;
-    boolean doNotCheckBackDatedTrxs = false;
     boolean doNotCheckNegativeStockCorrectionTrxs = false;
     // check if price correction is needed
     try {
@@ -221,19 +220,9 @@
       }
     }
 
-    // check if cost adjustment should be done
-    try {
-      doNotCheckBackDatedTrxs = Preferences.getPreferenceValue("doNotCheckBackDatedTrxs", true,
-          OBContext.getOBContext().getCurrentClient(),
-          OBContext.getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
-          OBContext.getOBContext().getRole(), null).equals("Y");
-    } catch (PropertyException e1) {
-      doNotCheckBackDatedTrxs = false;
-    }
-    if (!doNotCheckBackDatedTrxs
+    if (getCostingRule().isBackdatedTransactionsFixed()
         && CostAdjustmentUtils.isNeededCostAdjustmentByBackDateTrx(transaction, getCostingRule()
             .isWarehouseDimension())) {
-
       CostAdjustment costAdjustmentHeader = CostAdjustmentUtils.insertCostAdjustmentHeader(
           transaction.getOrganization(), "BDT"); // BDT= Backdated transaction
 
@@ -257,7 +246,7 @@
 
     // check if negative stock correction should be done
     try {
-      doNotCheckBackDatedTrxs = Preferences.getPreferenceValue(
+      doNotCheckNegativeStockCorrectionTrxs = Preferences.getPreferenceValue(
           "doNotCheckNegativeStockCorrecctionTrxs", true,
           OBContext.getOBContext().getCurrentClient(),
           OBContext.getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
--- a/src/org/openbravo/costing/StandardAlgorithm.java	Fri Sep 12 10:07:46 2014 +0200
+++ b/src/org/openbravo/costing/StandardAlgorithm.java	Fri Sep 12 10:10:11 2014 +0200
@@ -22,10 +22,7 @@
 import java.math.RoundingMode;
 
 import org.openbravo.dal.core.DalUtil;
-import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
-import org.openbravo.erpCommon.businessUtility.Preferences;
-import org.openbravo.erpCommon.utility.PropertyException;
 import org.openbravo.financial.FinancialUtils;
 import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.materialmgmt.cost.Costing;
@@ -83,19 +80,9 @@
   }
 
   private boolean isNotBackdatedTrx() {
-    boolean doNotCheckBackDatedTrxs = false;
-    try {
-      doNotCheckBackDatedTrxs = Preferences.getPreferenceValue("doNotCheckBackDatedTrxs", true,
-          OBContext.getOBContext().getCurrentClient(),
-          OBContext.getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
-          OBContext.getOBContext().getRole(), null).equals("Y");
-    } catch (PropertyException ignore) {
-      doNotCheckBackDatedTrxs = false;
-    }
-    if (doNotCheckBackDatedTrxs) {
+    if (!costingRule.isBackdatedTransactionsFixed()) {
       return true;
     }
-
     return !CostAdjustmentUtils.isNeededCostAdjustmentByBackDateTrx(transaction,
         costingRule.isWarehouseDimension());
   }