[costAdjs]undo last commit
authorMiguel A. Alsasua <miguel.alsasua@openbravo.com>
Fri, 12 Sep 2014 10:07:46 +0200
changeset 24882 da69282b144b
parent 24881 3059d19a5d5a
child 24883 f4bdbf730b63
[costAdjs]undo last commit
src-db/database/sourcedata/AD_REF_LIST.xml
src/org/openbravo/costing/CostingServer.java
src/org/openbravo/costing/StandardCostAdjustment.java
--- a/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Sep 12 08:46:06 2014 +0200
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml	Fri Sep 12 10:07:46 2014 +0200
@@ -10613,6 +10613,17 @@
 <!--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 08:46:06 2014 +0200
+++ b/src/org/openbravo/costing/CostingServer.java	Fri Sep 12 10:07:46 2014 +0200
@@ -132,6 +132,7 @@
 
   private void checkCostAdjustments() {
     boolean doNotCheckPriceCorrectionTrxs = false;
+    boolean doNotCheckBackDatedTrxs = false;
     boolean doNotCheckNegativeStockCorrectionTrxs = false;
     // check if price correction is needed
     try {
@@ -220,9 +221,19 @@
       }
     }
 
-    if (getCostingRule().isBackdatedTransactionsFixed()
+    // 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
         && CostAdjustmentUtils.isNeededCostAdjustmentByBackDateTrx(transaction, getCostingRule()
             .isWarehouseDimension())) {
+
       CostAdjustment costAdjustmentHeader = CostAdjustmentUtils.insertCostAdjustmentHeader(
           transaction.getOrganization(), "BDT"); // BDT= Backdated transaction
 
@@ -246,7 +257,7 @@
 
     // check if negative stock correction should be done
     try {
-      doNotCheckNegativeStockCorrectionTrxs = Preferences.getPreferenceValue(
+      doNotCheckBackDatedTrxs = Preferences.getPreferenceValue(
           "doNotCheckNegativeStockCorrecctionTrxs", true,
           OBContext.getOBContext().getCurrentClient(),
           OBContext.getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
--- a/src/org/openbravo/costing/StandardCostAdjustment.java	Fri Sep 12 08:46:06 2014 +0200
+++ b/src/org/openbravo/costing/StandardCostAdjustment.java	Fri Sep 12 10:07:46 2014 +0200
@@ -45,7 +45,6 @@
 import org.openbravo.model.common.plm.Product;
 import org.openbravo.model.materialmgmt.cost.CostAdjustmentLine;
 import org.openbravo.model.materialmgmt.cost.Costing;
-import org.openbravo.model.materialmgmt.cost.CostingRule;
 import org.openbravo.model.materialmgmt.transaction.MaterialTransaction;
 
 @ComponentProvider.Qualifier("6A39D8B46CD94FE682D48758D3B7726B")
@@ -113,7 +112,6 @@
         (String) DalUtil.getId(getCostOrg().getClient()));
     HashMap<CostDimension, BaseOBObject> costDimensions = getCostDimensions();
     Set<String> orgs = osp.getChildTree(strCostOrgId, true);
-    CostingRule costingRule = getCostingRule();
     if (isManufacturingProduct) {
       orgs = osp.getChildTree("0", false);
       costDimensions = CostingUtils.getEmptyDimensions();
@@ -133,9 +131,6 @@
     if (warehouse != null) {
       where.append("  and loc." + Locator.PROPERTY_WAREHOUSE + " = :warehouse");
     }
-    where.append("  and trx." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE
-        + " > :startdate ))");
-
     where.append(" order by trx." + MaterialTransaction.PROPERTY_MOVEMENTDATE);
     where.append("   , trx." + MaterialTransaction.PROPERTY_TRANSACTIONPROCESSDATE);
     where.append("   , trx." + MaterialTransaction.PROPERTY_MOVEMENTLINE);
@@ -157,7 +152,6 @@
     if (warehouse != null) {
       trxQry.setNamedParameter("warehouse", warehouse);
     }
-    trxQry.setNamedParameter("startdate", costingRule.getStartingDate());
 
     return trxQry.scroll(ScrollMode.FORWARD_ONLY);