Fixes issue 29729 & Fixes issue 29702 & Fixes issue 29728
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Thu, 02 Jul 2015 15:12:55 +0200
changeset 27087 b45cf0559789
parent 27086 fb92cb9bd2eb
child 27088 8adae72ecaee
Fixes issue 29729 & Fixes issue 29702 & Fixes issue 29728

Cost Adjustments will not be created in transactions calculated with Standard Algorithm.
src/org/openbravo/costing/CostingServer.java
src/org/openbravo/costing/PriceDifferenceProcess.java
--- a/src/org/openbravo/costing/CostingServer.java	Fri Jul 03 11:08:17 2015 +0200
+++ b/src/org/openbravo/costing/CostingServer.java	Thu Jul 02 15:12:55 2015 +0200
@@ -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) 2012-2014 Openbravo SLU
+ * All portions are Copyright (C) 2012-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -23,6 +23,7 @@
 import java.util.Date;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -133,6 +134,13 @@
   private void checkCostAdjustments() {
     TrxType trxType = TrxType.getTrxType(transaction);
     boolean adjustmentAlreadyCreated = false;
+
+    // With Standard Algorithm, no cost adjustment is needed
+    if (StringUtils.equals(transaction.getCostingAlgorithm().getJavaClassName(),
+        "org.openbravo.costing.StandardAlgorithm")) {
+      return;
+    }
+
     if (trxType == TrxType.InventoryClosing) {
       OBDal.getInstance().refresh(transaction.getPhysicalInventoryLine().getPhysInventory());
       if (transaction.getPhysicalInventoryLine().getPhysInventory()
--- a/src/org/openbravo/costing/PriceDifferenceProcess.java	Fri Jul 03 11:08:17 2015 +0200
+++ b/src/org/openbravo/costing/PriceDifferenceProcess.java	Thu Jul 02 15:12:55 2015 +0200
@@ -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) 2014-15 Openbravo SLU
+ * All portions are Copyright (C) 2014-2015 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -24,6 +24,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.lang.StringUtils;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import org.hibernate.ScrollMode;
@@ -50,6 +51,13 @@
   private static boolean calculateTransactionPriceDifference(MaterialTransaction materialTransaction)
       throws OBException {
     boolean costAdjCreated = false;
+
+    // With Standard Algorithm, no cost adjustment is needed
+    if (StringUtils.equals(materialTransaction.getCostingAlgorithm().getJavaClassName(),
+        "org.openbravo.costing.StandardAlgorithm")) {
+      return false;
+    }
+
     if (materialTransaction.isCostPermanent()) {
       // Permanently adjusted transaction costs are not checked for price differences.
       return false;