details:   https://code.openbravo.com/erp/devel/pi/rev/e86c0df009cf
changeset: 28689:e86c0df009cf
user:      Atul Gaware <atul.gaware <at> openbravo.com>
date:      Mon Feb 29 17:00:12 2016 +0530
summary:   Fixes Issue 32364:NullPointerException when posting a Physical 
Inventory
with a line without an associated transaction (not stocked product)

- Avoid insertion of zero quantity products in inventory line having
stocked flag as No.
- Code improvement to handle line with null transaction.

details:   https://code.openbravo.com/erp/devel/pi/rev/88faf8e87290
changeset: 28690:88faf8e87290
user:      Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
date:      Tue Mar 01 18:02:57 2016 +0100
summary:   Related to issue 32364: Code review improvements

Call line.getProductCosts only when line.transaction != null in 
DocInventory.java.

diffstat:

 src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml |   1 +
 src/org/openbravo/erpCommon/ad_forms/DocInventory.java     |  17 +++++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diffs (56 lines):

diff -r 817351be2c23 -r 88faf8e87290 
src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml
--- a/src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml        Tue Mar 
01 13:19:21 2016 +0100
+++ b/src-db/database/model/functions/M_INVENTORY_LISTCREATE.xml        Tue Mar 
01 18:02:57 2016 +0100
@@ -219,6 +219,7 @@
       LEFT JOIN m_attributeset aset ON p.m_attributeset_id = 
aset.m_attributeset_id    
       WHERE p.AD_Client_ID=v_Client_ID  --    only ..
         AND p.IsActive='Y'
+        AND p.IsStocked='Y'
         AND(v_ProductValue IS NULL
         OR UPPER(p.Value) LIKE v_ProductValue)
         AND(v_Locator_ID IS NULL
diff -r 817351be2c23 -r 88faf8e87290 
src/org/openbravo/erpCommon/ad_forms/DocInventory.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocInventory.java    Tue Mar 01 
13:19:21 2016 +0100
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInventory.java    Tue Mar 01 
18:02:57 2016 +0100
@@ -11,7 +11,7 @@
  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
  * created by ComPiere are Copyright (C) ComPiere, Inc.;   All Rights Reserved.
  * Contributor(s): Openbravo SLU
- * Contributions are Copyright (C) 2001-2014 Openbravo S.L.U.
+ * Contributions are Copyright (C) 2001-2016 Openbravo S.L.U.
  ******************************************************************************
  */
 package org.openbravo.erpCommon.ad_forms;
@@ -180,12 +180,13 @@
     int countInvLinesWithTrnCostZero = 0;
     for (int i = 0; i < p_lines.length; i++) {
       DocLine_Material line = (DocLine_Material) p_lines[i];
-      if ("NC".equals(line.transaction.getCostingStatus())) {
+      if (line.transaction != null && 
"NC".equals(line.transaction.getCostingStatus())) {
         setStatus(STATUS_NotCalculatedCost);
       }
 
-      if (line.transaction.getTransactionCost() != null
-          && line.transaction.getTransactionCost().compareTo(ZERO) == 0) {
+      if (line.transaction == null
+          || (line.transaction.getTransactionCost() != null && line.transaction
+              .getTransactionCost().compareTo(ZERO) == 0)) {
         countInvLinesWithTrnCostZero++;
       }
     }
@@ -208,9 +209,13 @@
         setMessageResult(conn, STATUS_NotCalculatedCost, "error", parameters);
         throw new IllegalStateException();
       }
-      String costs = line.getProductCosts(DateAcct, as, conn, con);
+      String costs = "";
+      BigDecimal b_Costs = BigDecimal.ZERO;
+      if (line.transaction != null) {
+        costs = line.getProductCosts(DateAcct, as, conn, con);
+        b_Costs = new BigDecimal(costs);
+      }
       log4jDocInventory.debug("CreateFact - before DR - Costs: " + costs);
-      BigDecimal b_Costs = new BigDecimal(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);

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to