details:   https://code.openbravo.com/erp/devel/pi/rev/26cbf54910c2
changeset: 25761:26cbf54910c2
user:      Unai Martirena <unai.martirena <at> openbravo.com>
date:      Tue Jan 27 20:08:23 2015 +0100
summary:   Fixes bug 28792: Null Pointer exception now is avoided in Costing 
Background


The problem was in AverageCostAdjustment java process while calling 
AverageAlgorithm.getProductCost method. While returning null, Null Pointer 
Exception error was raised.

diffstat:

 src/org/openbravo/costing/AverageCostAdjustment.java |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r a6433daf19d1 -r 26cbf54910c2 
src/org/openbravo/costing/AverageCostAdjustment.java
--- a/src/org/openbravo/costing/AverageCostAdjustment.java      Tue Jan 27 
17:19:36 2015 +0100
+++ b/src/org/openbravo/costing/AverageCostAdjustment.java      Tue Jan 27 
20:08:23 2015 +0100
@@ -119,6 +119,11 @@
     // Initialize current unit cost including the cost adjustments.
     Costing costing = AverageAlgorithm.getProductCost(trxDate, 
basetrx.getProduct(),
         getCostDimensions(), getCostOrg());
+    if (costing == null) {
+      throw new OBException("@NoAvgCostDefined@ @Organization@: " + 
getCostOrg().getName()
+          + ", @Product@: " + basetrx.getProduct().getName() + ", @Date@: "
+          + OBDateUtils.formatDate(trxDate));
+    }
     BigDecimal cost = null;
     // If current stock is zero the cost is not modified until a related 
transaction that modifies
     // the stock is found.
@@ -383,6 +388,11 @@
       // This is the current costing rule. Check if current average cost needs 
to be updated.
       Costing currentCosting = AverageAlgorithm.getProductCost(new Date(), 
basetrx.getProduct(),
           getCostDimensions(), getCostOrg());
+      // if (currentCosting == null) {
+      // throw new OBException("@NoAvgCostDefined@ @Organization@: " + 
getCostOrg().getName()
+      // + ", @Product@: " + basetrx.getProduct().getName() + ", @Date@: "
+      // + OBDateUtils.formatDate(new Date()));
+      // }
       if (currentCosting.getCost().compareTo(cost) != 0) {
         basetrx = getTransaction();
         Date newDate = new Date();

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to