svn commit: r807955 - /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r807955 - /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java

jacopoc
Author: jacopoc
Date: Wed Aug 26 10:36:58 2009
New Revision: 807955

URL: http://svn.apache.org/viewvc?rev=807955&view=rev
Log:
Fix for NPE.

Modified:
    ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java

Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java?rev=807955&r1=807954&r2=807955&view=diff
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Wed Aug 26 10:36:58 2009
@@ -953,12 +953,14 @@
             double actualTotalMilliSeconds = 0.0;
             Double actualSetupMillis = workEffort.getDouble("actualSetupMillis");
             Double actualMilliSeconds = workEffort.getDouble("actualMilliSeconds");
-            if (actualSetupMillis != null) {
-                actualTotalMilliSeconds += actualSetupMillis.doubleValue();
+            if (actualSetupMillis == null) {
+                actualSetupMillis = new Double(0.0);
             }
-            if (actualMilliSeconds != null) {
-                actualTotalMilliSeconds += actualMilliSeconds.doubleValue();
+            if (actualMilliSeconds == null) {
+                actualMilliSeconds = new Double(0.0);
             }
+            actualTotalMilliSeconds += actualSetupMillis.doubleValue();
+            actualTotalMilliSeconds += actualMilliSeconds.doubleValue();
             // Get the template (aka routing task) of the work effort
             GenericValue routingTaskAssoc = EntityUtil.getFirst(EntityUtil.filterByDate(delegator.findByAnd("WorkEffortAssoc",
                                                             UtilMisc.toMap("workEffortIdTo", productionRunTaskId,
@@ -1027,7 +1029,15 @@
                 GenericValue usageCost = EntityUtil.getFirst(EntityUtil.filterByDate(usageCosts));
                 if (UtilValidate.isNotEmpty(setupCost) || UtilValidate.isNotEmpty(usageCost)) {
                     String currencyUomId = (setupCost != null? setupCost.getString("amountUomId"): usageCost.getString("amountUomId"));
-                    BigDecimal fixedAssetCost = (setupCost.getBigDecimal("amount").multiply(BigDecimal.valueOf(actualSetupMillis.doubleValue()))).add(usageCost.getBigDecimal("amount").multiply(BigDecimal.valueOf(actualMilliSeconds.doubleValue()))).setScale(decimals, rounding);
+                    BigDecimal setupCostAmount = ZERO;
+                    if (setupCost != null) {
+                        setupCostAmount = setupCost.getBigDecimal("amount").multiply(BigDecimal.valueOf(actualSetupMillis.doubleValue()));
+                    }
+                    BigDecimal usageCostAmount = ZERO;
+                    if (usageCost != null) {
+                        usageCostAmount = usageCost.getBigDecimal("amount").multiply(BigDecimal.valueOf(actualMilliSeconds.doubleValue()));
+                    }
+                    BigDecimal fixedAssetCost = setupCostAmount.add(usageCostAmount).setScale(decimals, rounding);
                     fixedAssetCost = fixedAssetCost.divide(BigDecimal.valueOf(3600000), decimals, rounding);
                     // store the cost
                     Map inMap = UtilMisc.toMap("userLogin", userLogin, "workEffortId", productionRunTaskId);