Skip to content

OFBIZ-13459: Preserve facility context on MRP events#1474

Open
diveshdut wants to merge 1 commit into
apache:trunkfrom
diveshdut:mrp-event-facility-stamping-upstream
Open

OFBIZ-13459: Preserve facility context on MRP events#1474
diveshdut wants to merge 1 commit into
apache:trunkfrom
diveshdut:mrp-event-facility-stamping-upstream

Conversation

@diveshdut

@diveshdut diveshdut commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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.

This PR only preserves event-level facility when the engine already knows it.

Files Changed

  • applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/MrpServices.java
  • applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/mrp/InventoryEventPlannedServices.java

Verification

Verified on a clean checkout of mrp-event-facility-stamping-upstream using Java 17:

  • ./gradlew checkstyleTest
  • ./gradlew check javadoc
  • ./gradlew codenarcMain codenarcTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant