Related to issue 32364: Code review improvements
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Tue, 01 Mar 2016 18:02:57 +0100
changeset 28690 88faf8e87290
parent 28689 e86c0df009cf
child 28691 e86261103636
Related to issue 32364: Code review improvements

Call line.getProductCosts only when line.transaction != null in DocInventory.java.
src/org/openbravo/erpCommon/ad_forms/DocInventory.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocInventory.java	Mon Feb 29 17:00:12 2016 +0530
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInventory.java	Tue Mar 01 18:02:57 2016 +0100
@@ -23,7 +23,6 @@
 
 import javax.servlet.ServletException;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.costing.CostingStatus;
@@ -210,12 +209,13 @@
         setMessageResult(conn, STATUS_NotCalculatedCost, "error", parameters);
         throw new IllegalStateException();
       }
-      String costs = line.getProductCosts(DateAcct, as, conn, con);
-      log4jDocInventory.debug("CreateFact - before DR - Costs: " + costs);
+      String costs = "";
       BigDecimal b_Costs = BigDecimal.ZERO;
-      if (costs != null && !StringUtils.isBlank(costs) && !StringUtils.isEmpty(costs)) {
+      if (line.transaction != null) {
+        costs = line.getProductCosts(DateAcct, as, conn, con);
         b_Costs = new BigDecimal(costs);
       }
+      log4jDocInventory.debug("CreateFact - before DR - Costs: " + costs);
       Account assetAccount = line.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn);
       if (assetAccount == null) {
         Product product = OBDal.getInstance().get(Product.class, line.m_M_Product_ID);