svn commit: r1809594 - /ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/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: r1809594 - /ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java

jacopoc
Author: jacopoc
Date: Mon Sep 25 09:11:24 2017
New Revision: 1809594

URL: http://svn.apache.org/viewvc?rev=1809594&view=rev
Log:
Fixed: MRP incorrectly computes quantity already received in open purchase order
shipments.
(OFBIZ-9525)

The MRP algorithm incorrectly computed the quantity of items partially received
in a purchase shipment because it leveraged the
OrderReadHelper.getItemShippedQuantity(...) method that is intended to be used
only to count the quantity shipped of sales order.

Thanks: Amit Gadaley for the patch to fix the issue..

Modified:
    ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java?rev=1809594&r1=1809593&r2=1809594&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java Mon Sep 25 09:11:24 2017
@@ -274,12 +274,15 @@ public class MrpServices {
                 if (UtilValidate.isNotEmpty(cancelledQuantity)) {
                     shipGroupQuantity = shipGroupQuantity.subtract(cancelledQuantity);
                 }
-    
-                OrderReadHelper orh = new OrderReadHelper(delegator, orderId);
-                BigDecimal shippedQuantity = null;
-                shippedQuantity = orh.getItemShippedQuantity(genericResult.getRelatedOne("OrderItem", false));
-                if (UtilValidate.isNotEmpty(shippedQuantity)) {
-                    shipGroupQuantity = shipGroupQuantity.subtract(shippedQuantity);
+
+                try {
+                    List<GenericValue> shipmentReceipts = EntityQuery.use(delegator).select("quantityAccepted", "quantityRejected").from("ShipmentReceipt").where("orderId", genericResult.getString("orderId"), "orderItemSeqId", genericResult.getString("orderItemSeqId")).queryList();
+                    for (GenericValue shipmentReceipt : shipmentReceipts) {
+                        shipGroupQuantity = shipGroupQuantity.subtract(shipmentReceipt.getBigDecimal("quantityAccepted"));
+                        shipGroupQuantity = shipGroupQuantity.subtract(shipmentReceipt.getBigDecimal("quantityRejected"));
+                    }
+                } catch (GenericEntityException e) {
+                    Debug.logWarning(e, module);
                 }
     
                 GenericValue orderItemDeliverySchedule = null;