[Master]-Incorrect Reservation Split Generated After Replanning a Replenishment Production Order Created by MRP Planning Run - #9788
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses an MRP replanning defect where, if the same component item appears on multiple production order component lines, the reservation split could remain partially based on the old demand, leading to incorrect reserved quantities per component line. The fix introduces logic to force deletion/rebuild of the affected order-to-order reservation entries and adds a regression test to validate the correct split after replanning.
Changes:
- Add a manufacturing-focused event subscriber on
Inventory Profile Offsetting.OnAfterShouldDeleteReservEntryto force deletion of order-to-order reservation entries when the same component item exists on multiple prod. order component lines. - Add a new SCM manufacturing test that creates a released production order with the same component twice (different calculation formulas), replans, and verifies the reserved quantity split remains correct.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Layers/W1/Tests/SCM-Manufacturing/SCMProductionOrdersII.Codeunit.al | Adds a regression test plus helper procedures to reproduce and validate the reservation split scenario after replanning. |
| src/Layers/W1/BaseApp/Manufacturing/Inventory/Tracking/MfgInvtProfileOffsetting.Codeunit.al | Adds an event subscriber that forces deletion of reservation entry pairs to ensure the split is rebuilt during replanning for the problematic scenario. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
…ProfileOffsetting.Codeunit.al Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Layers/W1/BaseApp/Manufacturing/Inventory/Tracking/MfgInvtProfileOffsetting.Codeunit.al:188
- PR description says "No base-app ... changes", but this change is in src/Layers/W1/BaseApp/... and adds behavior to a BaseApp codeunit (99000869). Either update the PR description to reflect that BaseApp is modified, or move the subscriber to the intended non-BaseApp layer so the description stays accurate.
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Inventory Profile Offsetting", 'OnAfterShouldDeleteReservEntry', '', true, false)]
local procedure OnAfterShouldDeleteReservEntry(ReservationEntry: Record "Reservation Entry"; ToDate: Date; var DeleteCondition: Boolean; TemplateName: Code[10]; WorksheetName: Code[10])
var
AB#643972
When the same component item is used on multiple prod. order component lines, replanning kept the old reservation split and only adjusted the delta, producing an incorrect reserved quantity per line.
Fix: A small manufacturing-layer event subscriber (OnAfterShouldDeleteReservEntry) now force-rebuilds the split for these cases. No base-app or schema changes.