svn commit: r532721 - /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: r532721 - /ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java

jacopoc
Author: jacopoc
Date: Thu Apr 26 05:19:27 2007
New Revision: 532721

URL: http://svn.apache.org/viewvc?view=rev&rev=532721
Log:
Misc bug fixes to the new service that sets the estimated delivery dates for products needing manufacturing.

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?view=diff&rev=532721&r1=532720&r2=532721
==============================================================================
--- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java (original)
+++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java Thu Apr 26 05:19:27 2007
@@ -2528,26 +2528,27 @@
                     estimatedShipDate = now;
                 }
                 if (!products.containsKey(productId)) {
-                    products.put("productId", new TreeMap());
+                    products.put(productId, new TreeMap());
                 }
                 TreeMap productMap = (TreeMap)products.get(productId);
                 if (!productMap.containsKey(estimatedShipDate)) {
                     productMap.put(estimatedShipDate, UtilMisc.toMap("remainingQty", new Double(0.0), "reservations", FastList.newInstance()));
                 }
                 Map dateMap = (Map)productMap.get(estimatedShipDate);
-                Double remainingQty = (Double)productMap.get("remainingQty");
-                //List reservations = (List)productMap.get("reservations");
+                Double remainingQty = (Double)dateMap.get("remainingQty");
+                //List reservations = (List)dateMap.get("reservations");
                 remainingQty = new Double(remainingQty.doubleValue() + qtyDiff);
+                dateMap.put("remainingQty", remainingQty);
             }
 
             // backorders
             List backordersCondList = FastList.newInstance();
             backordersCondList.add(new EntityExpr("quantityNotAvailable", EntityOperator.NOT_EQUAL, null));
             backordersCondList.add(new EntityExpr("quantityNotAvailable", EntityOperator.GREATER_THAN, new Double(0.0)));
-            backordersCondList.add(new EntityExpr(new EntityExpr("statusId", EntityOperator.EQUALS, "ITEM_CREATED"), EntityOperator.OR, new EntityExpr("statusId", EntityOperator.LESS_THAN, "ITEM_APPROVED")));
+            //backordersCondList.add(new EntityExpr(new EntityExpr("statusId", EntityOperator.EQUALS, "ITEM_CREATED"), EntityOperator.OR, new EntityExpr("statusId", EntityOperator.LESS_THAN, "ITEM_APPROVED")));
 
             List backorders = delegator.findByCondition("OrderItemAndShipGrpInvResAndItem", new EntityConditionList(backordersCondList, EntityOperator.AND), null, UtilMisc.toList("shipBeforeDate"));
-            Iterator backordersIt = resultList.iterator();
+            Iterator backordersIt = backorders.iterator();
             while (backordersIt.hasNext()) {
                 GenericValue genericResult = (GenericValue) backordersIt.next();
                 String productId = genericResult.getString("productId");
@@ -2575,6 +2576,7 @@
                     }
                     if (remainingQty.doubleValue() >= quantityNotAvailableRem) {
                         remainingQty = new Double(remainingQty.doubleValue() - quantityNotAvailableRem);
+                        currentDateMap.put("remainingQty", remainingQty);
                         GenericValue orderItemShipGrpInvRes = delegator.findByPrimaryKey("OrderItemShipGrpInvRes", UtilMisc.toMap("orderId", genericResult.getString("orderId"),
                                                                                                                                   "shipGroupSeqId", genericResult.getString("shipGroupSeqId"),
                                                                                                                                   "orderItemSeqId", genericResult.getString("orderItemSeqId"),
@@ -2586,6 +2588,7 @@
                     } else {
                         quantityNotAvailableRem = quantityNotAvailableRem - remainingQty.doubleValue();
                         remainingQty = new Double(0.0);
+                        currentDateMap.put("remainingQty", remainingQty);
                     }
                 }
             }
@@ -2593,6 +2596,7 @@
             Debug.logError(e, "Error", module);
             return ServiceUtil.returnError("Problem running the setEstimatedDeliveryDates service");
         }
-        return result;
+        return ServiceUtil.returnSuccess();
     }
+
 }