You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2026/07/24 13:38:00 UTC

[jira] [Commented] (OFBIZ-13459) Preserve known facility context on MRP events generated by the OFBiz MRP engine

    [ https://issues.apache.org/jira/browse/OFBIZ-13459?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18098896#comment-18098896 ] 

ASF subversion and git services commented on OFBIZ-13459:
---------------------------------------------------------

Commit 84858b529deef5f9b214dc5129242436c0735a69 in ofbiz-framework's branch refs/heads/trunk from Divesh Dutta
[ https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=84858b529d ]

OFBIZ-13459: Preserve facility context on MRP events 

## Jira Ticket:
https://issues.apache.org/jira/browse/OFBIZ-13459

## Summary

This PR preserves known facility context on generated `MrpEvent` rows
when the OFBiz MRP engine already has reliable facility information
available from source data or the current run context.

The goal is to improve planner traceability without changing MRP
calculation behavior, `MrpEvent` identity, or `MrpEvent` merge
semantics.

## Problem

Today, some MRP events are created without `facilityId` even when the
engine already knows the relevant warehouse or manufacturing facility.

That makes planner-facing event interpretation harder, especially for:
- product-plus-facility event timelines
- proposed supply traceability
- exception analysis
- API/UI consumers that need concrete facility context on each event

## What This PR Changes

This PR preserves facility context for these event paths when the engine
already has it:
- `SALES_ORDER_SHIP`
- `PROD_REQ_RECP`
- `PUR_ORDER_RECP`
- `MANUF_ORDER_REQ`
- `MANUF_ORDER_RECP`
- `REQUIRED_MRP`
- `MRP_REQUIREMENT`
- `PROP_PUR_O_RECP`
- `PROP_MANUF_O_RECP`
- `ERROR`

It also adds a conservative merge-side backfill:
- if an existing `MrpEvent` row has an empty `facilityId`
- and a later matching update provides a non-empty `facilityId`
- then the missing facility is filled in
- existing facility values are not overwritten

## Important Non-Goals

This PR does not:
- change MRP quantity calculation
- change `MrpEvent` primary key
- change `MrpEvent` merge semantics
- force facility assignment for organization-level signals
- change late-flag behavior
- include run-log or planner API work

## Facility Group Note

When MRP is launched with `facilityGroupId`, current code resolves the
run into concrete facilities before event creation.

This PR preserves those resolved concrete facilities on generated
`MrpEvent` rows. It does not stamp the facility group id itself.

## Why Event-Level Facility Still Matters

Run-level provenance and event-level facility serve different purposes.

A run may have an overall planning context, but individual events can
still belong to different concrete facilities within that run context,
especially across warehouse-oriented and manufacturing-oriented event
types.

> Preserve known facility context on MRP events generated by the OFBiz MRP engine
> -------------------------------------------------------------------------------
>
>                 Key: OFBIZ-13459
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-13459
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: manufacturing
>    Affects Versions: Upcoming Branch
>            Reporter: Divesh Dutta
>            Assignee: Divesh Dutta
>            Priority: Trivial
>             Fix For: Upcoming Branch
>
>
> The OFBiz MRP engine can generate {{MrpEvent}} rows without {{facilityId}} even when the engine already has reliable facility context while processing the source planning signal.
> This proposal is intended as a traceability improvement, not as a change to MRP calculation logic, event identity, or event merge behavior.
> In several MRP event creation paths, OFBiz already knows the relevant facility from source data or from the current planning context, but that context is not always preserved on the generated {{{}MrpEvent{}}}. This makes planner-facing timelines, exception analysis, and proposed supply interpretation harder to trust, especially for multi-warehouse and warehouse/plant-aware planning.
> Examples of where facility context is already available include:
>  * sales order demand records
>  * approved requirements
>  * purchase supply processed in the current planning warehouse context
>  * production run demand and receipt
>  * {{{}ProductFacility{}}}-driven minimum stock signals
>  * component requirement events generated during BOM explosion
>  * proposed purchase and manufacturing supply events
>  * facility-specific MRP error events
> Proposed rule:
>  * stamp {{facilityId}} on {{MrpEvent}} only when the OFBiz MRP engine already has a meaningful facility from source data or the current run context
>  * if the source signal is organization-level or has no reliable facility context, keep {{facilityId}} empty
> Expected scope of the change:
>  * preserve source/query facility for {{SALES_ORDER_SHIP}}
>  * preserve requirement facility for {{PROD_REQ_RECP}}
>  * preserve the current planning warehouse for {{PUR_ORDER_RECP}}
>  * preserve production facility for {{MANUF_ORDER_REQ}} and {{MANUF_ORDER_RECP}}
>  * preserve {{ProductFacility.facilityId}} for {{REQUIRED_MRP}}
>  * preserve manufacturing facility for {{MRP_REQUIREMENT}} generated during BOM explosion
>  * preserve warehouse/manufacturing facility for {{PROP_PUR_O_RECP}} and {{PROP_MANUF_O_RECP}}
>  * preserve facility on {{ERROR}} events when the failing planning context is facility-specific
>  * conservatively backfill {{facilityId}} during {{MrpEvent}} merge only when the existing row has no facility and the incoming update provides one
> Important non-goals:
>  * no change to MRP quantity calculation
>  * no change to {{MrpEvent}} primary key
>  * no change to {{MrpEvent}} merge semantics
>  * no forced facility assignment for organization-level events
>  * no change to late-flag logic
>  * no run-log or planner API changes as part of this ticket
> Additional note on {{{}facilityGroupId{}}}:
>  * when MRP is launched with {{{}facilityGroupId{}}}, current code resolves that group into concrete run facilities before event creation
>  * this ticket would preserve those resolved facilities on the generated events, not the facility group id itself
> Planner-facing benefits:
>  * better product-plus-facility event traceability
>  * clearer understanding of which warehouse or plant an event belongs to
>  * better support for downstream API/UI consumers
>  * less ambiguous interpretation of proposed supply and exception events



--
This message was sent by Atlassian Jira
(v8.20.10#820010)