diff --git a/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl b/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl index d81555489d..473a7df402 100644 --- a/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl +++ b/applications/manufacturing/webapp/manufacturing/mrp/findInventoryEventPlan.ftl @@ -154,12 +154,22 @@ document.lookupinventory.productId.focus(); <#if ! product.equals( productTmp )> <#assign quantityAvailableAtDate = 0> <#assign errorEvents = delegator.findByAnd("InventoryEventPlanned", Static["org.ofbiz.base.util.UtilMisc"].toMap("inventoryEventPlanTypeId", "ERROR", "productId", inven.productId))> - <#assign initialQohEvent = Static["org.ofbiz.entity.util.EntityUtil"].getFirst(delegator.findByAnd("InventoryEventPlanned", Static["org.ofbiz.base.util.UtilMisc"].toMap("inventoryEventPlanTypeId", "INITIAL_QOH", "productId", inven.productId)))> - <#if initialQohEvent?exists && initialQohEvent.eventQuantity?has_content> - <#assign quantityAvailableAtDate = initialQohEvent.eventQuantity> + <#assign qohEvents = delegator.findByAnd("InventoryEventPlanned", Static["org.ofbiz.base.util.UtilMisc"].toMap("inventoryEventPlanTypeId", "INITIAL_QOH", "productId", inven.productId))> + <#assign additionalErrorMessage = ""> + <#assign initialQohEvent = null> + <#assign productFacility = null> + <#if qohEvents?has_content> + <#assign initialQohEvent = Static["org.ofbiz.entity.util.EntityUtil"].getFirst(qohEvents)> #if> - <#if initialQohEvent?exists && initialQohEvent.facilityId?has_content> - <#assign productFacility = delegator.findByPrimaryKey("ProductFacility", Static["org.ofbiz.base.util.UtilMisc"].toMap("facilityId", initialQohEvent.facilityId, "productId", inven.productId))?if_exists> + <#if initialQohEvent != null> + <#if initialQohEvent.eventQuantity?has_content> + <#assign quantityAvailableAtDate = initialQohEvent.eventQuantity> + #if> + <#if initialQohEvent.facilityId?has_content> + <#assign productFacility = delegator.findByPrimaryKey("ProductFacility", Static["org.ofbiz.base.util.UtilMisc"].toMap("facilityId", initialQohEvent.facilityId, "productId", inven.productId))?if_exists> + #if> + <#else> + <#assign additionalErrorMessage = "No QOH information found, assuming 0."> #if>