Fixed: MRP generates duplicate requirements when items are initially under
minimum quantity and have with pending approved purchase orders. (OFBIZ-9526) With this change the requirements to replenish the inventory up to the minimum stock quantity is generated, if needed, only when the first demand event is processed or at the end. Thanks: Amit Gadaley for the help in recreating the issue and testing the fix. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1802766 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+5
-1
@@ -688,8 +688,12 @@ public class MrpServices {
|
||||
bomLevelWithNoEvent = 0;
|
||||
|
||||
oldProductId = "";
|
||||
int eventCount = 0;
|
||||
for (GenericValue inventoryEventForMRP : listInventoryEventForMRP) {
|
||||
eventCount++;
|
||||
|
||||
productId = inventoryEventForMRP.getString("productId");
|
||||
boolean isLastEvent = (eventCount == listInventoryEventForMRP.size() || !productId.equals(listInventoryEventForMRP.get(eventCount).getString("productId")));
|
||||
eventQuantity = inventoryEventForMRP.getBigDecimal("quantity");
|
||||
|
||||
if (!productId.equals(oldProductId)) {
|
||||
@@ -746,7 +750,7 @@ public class MrpServices {
|
||||
}
|
||||
|
||||
stockTmp = stockTmp.add(eventQuantity);
|
||||
if (stockTmp.compareTo(minimumStock) < 0) {
|
||||
if (stockTmp.compareTo(minimumStock) < 0 && (eventQuantity.compareTo(BigDecimal.ZERO) < 0 || isLastEvent)) { // No need to create a supply event/requirement if the current event is not a demand and there are other events to process
|
||||
BigDecimal qtyToStock = minimumStock.subtract(stockTmp);
|
||||
//need to buy or build the product as we have not enough stock
|
||||
eventDate = inventoryEventForMRP.getTimestamp("eventDate");
|
||||
|
||||
Reference in New Issue
Block a user