[Subcontracting] Refactor event subscriber for planning components and add test for Vendor-supplied components - #9130
Conversation
…ndor-supplied components
|
Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link. |
Agentic PR Review - Round 1Recommendation: AcceptWhat this PR doesThis PR moves the vendor-supplied planning exclusion from the BOM transfer area to The code change is the right extension point for this scenario. It keeps vendor-supplied Planning Components in the worksheet, while excluding them from demand calculation; the existing SuggestionsNone. The linked work item is missing from the PR body, but this is being supplied separately, so it is not treated as a blocker here. Please make sure the approved issue or AB# work item is linked before merge so Work Item Validation passes. Risk assessment and necessityRisk: The code risk is narrow: it adds one filter to Necessity: The diff describes a valid and important fix: vendor-supplied subcontracting components should not be planned as separate component demand after the parent item is already in the Planning Worksheet. The scenario is clear and the scope is right for a bug fix.
|
Copilot PR ReviewIteration 1 · Outcome: completed
Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
Pull request was closed
What & why
This pull request introduces a targeted fix to the planning logic for vendor-supplied components in the subcontracting manufacturing process. It ensures that components marked as "Vendor-Supplied" do not generate separate planning demand, while still allowing them to appear in the planning worksheet for consumption registration. Additionally, a comprehensive test is added to verify this behavior.
Planning Logic Update:
OnTransferBOMOnBeforeUpdatePlanningCompevent inMfg. Planning Line Managementis replaced with a new subscriber to theOnAfterFilterLinesWithItemToPlanevent on thePlanning Componenttable. This new subscriber filters out planning components with the supply method set to "Vendor-Supplied," preventing them from generating separate demand lines. (SubcPlanningLineMgmtExt.Codeunit.al)Automated Testing Enhancements:
VendorSuppliedPlanningComponentNotPlannedSeparately, is added to verify that vendor-supplied components do not generate requisition lines during planning runs, but still remain in the planning worksheet and production order for consumption tracking. The test also checks that if the supply method is changed, the component is once again planned. (SubcSubcontractingTest.Codeunit.al)Why the
PlanningComponent_OnAfterFilterLinesWithItemToPlansubscriber was addedBackground
When a BOM component has
Component Supply Method = Vendor-Supplied, it means the subcontractor provides that material themselves — it is purchased as part of the subcontracting order, not separately by your company. The existing subscriber onProd. Order Componentalready prevented the planning engine from generating a separate purchase requisition when a Released Production Order existed with such a component.The gap
The planning engine has two separate demand sources it queries when running
CalcRegenPlanfor a component item:The
ProdOrderComponent_OnAfterFilterLinesWithItemToPlansubscriber only covered the first case. When the planning engine encountered existing Planning Components (i.e., the parent item had already been planned in the worksheet viaCalcRegenPlanorRefreshPlanningLine), those components were not filtered — so a second planning run for the component item would still generate a spurious requisition line, even though the component would already be covered by the subcontracting purchase order.What the new subscriber covers
PlanningComponent_OnAfterFilterLinesWithItemToPlancloses this gap. When the planning engine asks "which Planning Components constitute demand for this item?", the subscriber excludes any component withComponent Supply Method = Vendor-Supplied. The result:Planning Componentrecord remains in the worksheet — it is still needed for consumption registration (posting output) against the subcontracting operation.Requisition Lineis generated for the component item — it will be purchased through the subcontracting purchase order, not independently.MakeSupplyOrders), theProd. Order ComponentwithVendor-Suppliedis correctly transferred and present in the production order — it was never removed, only excluded from demand calculation.In one sentence
Without this subscriber, a component marked as Vendor-Supplied would be ordered twice whenever the parent item had an active planning worksheet line: once implicitly through the subcontracting purchase order, and once explicitly through a separate requisition generated by the planning engine reading the
Planning Componentas unmet demand.Linked work
Fixes AB#630597
How I validated this
What I tested and the outcome (required — be specific: scenarios, commands, screenshots for UI changes)
Risk & compatibility
None