} catch (Exception e) {
return ServiceUtil.returnError("An error occurred exploding the product [" + product.getString("productId") + "]");
}
components = (List)serviceResponse.get("components");
if (UtilValidate.isNotEmpty(components)) {
BOMNode node = ((BOMNode)components.get(0)).getParentNode();
isBuilt = node.isManufactured();
} else {
isBuilt = false;
}
// #####################################################
oldProductId = productId;
}
stockTmp = stockTmp.add(eventQuantity);
if (stockTmp.compareTo(minimumStock) < 0) {
BigDecimal qtyToStock = minimumStock.subtract(stockTmp);
//need to buy or build the product as we have not enough stock
eventDate = inventoryEventForMRP.getTimestamp("eventDate");
// to be just before the requirement
eventDate.setTime(eventDate.getTime()-1);
ProposedOrder proposedOrder = new ProposedOrder(product, facilityId, manufacturingFacilityId, isBuilt, eventDate, qtyToStock);
proposedOrder.setMrpName(mrpName);
// calculate the ProposedOrder quantity and update the quantity object property.
proposedOrder.calculateQuantityToSupply(reorderQuantity, minimumStock, iteratorListInventoryEventForMRP);
// -----------------------------------------------------
// The components are also loaded thru the configurator
Map serviceResponse = null;
try {
serviceResponse = dispatcher.runSync("getManufacturingComponents", UtilMisc.<String, Object>toMap("productId", product.getString("productId"), "quantity", proposedOrder.getQuantity(), "excludeWIPs", Boolean.FALSE, "userLogin", userLogin));
} catch (Exception e) {
return ServiceUtil.returnError("An error occurred exploding the product [" + product.getString("productId") + "]");
}
components = (List)serviceResponse.get("components");
String routingId = (String)serviceResponse.get("workEffortId");
if (routingId != null) {
try {
routing = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", routingId));
} catch (GenericEntityException e) {
return ServiceUtil.returnError("Problem, can not find the product for a event, for more detail look at the log");
}
} else {
routing = null;
}
if (UtilValidate.isNotEmpty(components)) {
BOMNode node = ((BOMNode)components.get(0)).getParentNode();
isBuilt = node.isManufactured();
} else {
isBuilt = false;
}
// #####################################################