svn commit: r454315 - in /incubator/ofbiz/trunk/applications/manufacturing: data/ManufacturingData.xml src/org/ofbiz/manufacturing/mrp/MrpServices.java

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

svn commit: r454315 - in /incubator/ofbiz/trunk/applications/manufacturing: data/ManufacturingData.xml src/org/ofbiz/manufacturing/mrp/MrpServices.java

jacopoc
Author: jacopoc
Date: Mon Oct  9 02:17:38 2006
New Revision: 454315

URL: http://svn.apache.org/viewvc?view=rev&rev=454315
Log:
If a po delivery schedule (OrderDeliverySchedule) date is available, the MRP will consider this date instead of the OrderItem date.

Modified:
    incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml
    incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java

Modified: incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml?view=diff&rev=454315&r1=454314&r2=454315
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/data/ManufacturingData.xml Mon Oct  9 02:17:38 2006
@@ -23,6 +23,7 @@
     <InventoryEventPlannedType inventoryEventPlanTypeId="MANUF_ORDER_REQ" description="Manufacturing Order requirement" inOut="-"/>
     <InventoryEventPlannedType inventoryEventPlanTypeId="PROP_MANUF_O_RECP" description="Proposed Manufacturing Order receipt" inOut="+"/>
     <InventoryEventPlannedType inventoryEventPlanTypeId="PUR_ORDER_RECP" description="Purchase Order receipt" inOut="+"/>
+    <InventoryEventPlannedType inventoryEventPlanTypeId="PROD_REQ_RECP" description="Product Requirement Receipt" inOut="+"/>
     <InventoryEventPlannedType inventoryEventPlanTypeId="PROP_PUR_O_RECP" description="Proposed Purchase Order receipt" inOut="+"/>
     <InventoryEventPlannedType inventoryEventPlanTypeId="SALE_ORDER_SHIP" description="Sales order shipment" inOut="-"/>
     <TechDataCalendarWeek calendarWeekId="SUPPLIER" description="8hours/days, currently the Re-Order Process convert day to mms with 8h/days" mondayStartTime="08:30:00" mondayCapacity="2.88E7" tuesdayStartTime="08:30:00" tuesdayCapacity="2.88E7" wednesdayStartTime="08:30:00" wednesdayCapacity="2.88E7" thursdayStartTime="08:30:00" thursdayCapacity="2.88E7" fridayStartTime="08:30:00" fridayCapacity="2.88E7"/>

Modified: incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java
URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java?view=diff&rev=454315&r1=454314&r2=454315
==============================================================================
--- incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java (original)
+++ incubator/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/mrp/MrpServices.java Mon Oct  9 02:17:38 2006
@@ -147,7 +147,7 @@
         iteratorResult = null;
         parameters = UtilMisc.toMap("orderTypeId", "SALES_ORDER", "itemStatusId", "ITEM_APPROVED");
         try {
-            resultList = delegator.findByAnd("OrderHeaderAndItems", parameters);
+            resultList = delegator.findByAnd("OrderHeaderAndItems", parameters, UtilMisc.toList("orderId"));
         } catch(GenericEntityException e) {
             Debug.logError(e, "Error : delegator.findByAnd(\"OrderItem\", parameters\")", module);
             Debug.logError(e, "Error : parameters = "+parameters,module);
@@ -193,11 +193,11 @@
                 estimatedShipDate = now;
             }
             
-            parameters = UtilMisc.toMap("productId", productId, "eventDate", estimatedShipDate, "inventoryEventPlanTypeId", "PUR_ORDER_RECP");
+            parameters = UtilMisc.toMap("productId", productId, "eventDate", estimatedShipDate, "inventoryEventPlanTypeId", "PROD_REQ_RECP");
             try {
                 InventoryEventPlannedServices.createOrUpdateInventoryEventPlanned(parameters, eventQuantityTmp, delegator);
             } catch (GenericEntityException e) {
-                return ServiceUtil.returnError("Problem initializing the InventoryEventPlanned entity (PUR_ORDER_RECP)");
+                return ServiceUtil.returnError("Problem initializing the InventoryEventPlanned entity (PROD_REQ_RECP)");
             }
         }
         
@@ -206,9 +206,11 @@
         // ----------------------------------------
         resultList = null;
         iteratorResult = null;
+        String orderId = null;
+        GenericValue orderDeliverySchedule = null;
         parameters = UtilMisc.toMap("orderTypeId", "PURCHASE_ORDER", "itemStatusId", "ITEM_APPROVED");
         try {
-            resultList = delegator.findByAnd("OrderHeaderAndItems", parameters);
+            resultList = delegator.findByAnd("OrderHeaderAndItems", parameters, UtilMisc.toList("orderId"));
         } catch(GenericEntityException e) {
             Debug.logError(e, "Error : delegator.findByAnd(\"OrderItem\", parameters\")", module);
             Debug.logError(e, "Error : parameters = "+parameters,module);
@@ -217,9 +219,30 @@
         iteratorResult = resultList.iterator();
         while(iteratorResult.hasNext()){
             genericResult = (GenericValue) iteratorResult.next();
+            String newOrderId =  genericResult.getString("orderId");
+            if (!newOrderId.equals(orderId)) {
+                orderDeliverySchedule = null;
+                orderId = newOrderId;
+                try {
+                    orderDeliverySchedule = delegator.findByPrimaryKey("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", "_NA_"));
+                } catch (GenericEntityException e) {
+                }
+            }
             String productId =  genericResult.getString("productId");
             Double eventQuantityTmp = new Double(genericResult.getDouble("quantity").doubleValue());
-            Timestamp estimatedShipDate = genericResult.getTimestamp("estimatedDeliveryDate"); // TODO: verify if this field is correct
+            GenericValue orderItemDeliverySchedule = null;
+            try {
+                orderItemDeliverySchedule = delegator.findByPrimaryKey("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", genericResult.getString("orderItemSeqId")));
+            } catch (GenericEntityException e) {
+            }
+            Timestamp estimatedShipDate = null;
+            if (orderItemDeliverySchedule != null && orderItemDeliverySchedule.get("estimatedReadyDate") != null) {
+                estimatedShipDate = orderItemDeliverySchedule.getTimestamp("estimatedReadyDate");
+            } else if (orderDeliverySchedule != null && orderDeliverySchedule.get("estimatedReadyDate") != null) {
+                estimatedShipDate = orderDeliverySchedule.getTimestamp("estimatedReadyDate");
+            } else {
+                estimatedShipDate = genericResult.getTimestamp("estimatedDeliveryDate");
+            }
             if (estimatedShipDate == null) {
                 estimatedShipDate = now;
             }