Bug 640958: Guided error for subcontracting direct transfer from whse-handling location#9085
Bug 640958: Guided error for subcontracting direct transfer from whse-handling location#9085alexei-dobriansky wants to merge 2 commits into
Conversation
…-handling location SubcCreateTransfOrder.InsertTransferHeader unconditionally validated "Direct Transfer" := true when no in-transit route existed; the OnValidate calls VerifyNoOutboundWhseHandlingOnLocation which TestFields Require Pick/Require Shipment = false, throwing a raw error for warehouse-handling source locations. Add CheckDirectTransferAllowed that raises a guided error explaining the situation (set up an in-transit route or use Direct Transfer posting) when the source location requires a pick or shipment and posting is not Direct Transfer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Agentic PR Review - Round 1Recommendation: Request ChangesWhat this PR doesThis PR adds a pre-check before the subcontracting report falls back to a direct transfer when no in-transit route is found. The bug scenario is valid and clear: a source location that requires pick or shipment currently gets a raw Location The check is in the right area of SuggestionsS1 - Effective posting type is checked too early S2 - Regression tests miss Direct Transfer setup Risk assessment and necessityRisk: The change is narrow, but it sits in transfer order creation for subcontracting components and WIP. BaseApp verification shows Necessity: The bug is important because users with warehouse-handling source locations otherwise get a raw Location field error and no guidance. The scope is right for a bug fix, but it must preserve the documented workaround of setting Direct Transfer Posting to Direct Transfer.
|
PR review follow-up (#9085 S1): CheckDirectTransferAllowed read TransferHeader."Direct Transfer Posting", which is still blank before Validate("Direct Transfer", true) computes it from the transfer route / Inventory Setup. A company whose Inventory Setup uses Direct Transfer posting was therefore wrongly blocked from a require-shipment source location, even though that posting type skips the outbound warehouse-handling check. Compute the effective posting type (mirroring TransferHeader.GetDirectTransferPosting) and only raise the guided error when it is not Direct Transfer. Adds a positive test (Inventory Setup Direct Transfer posting -> transfer created) and pins the Inventory Setup posting type in the negative test so both rely on explicit, correct data. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed S1 and S2: the guard now computes the effective Direct Transfer Posting type (mirroring |
| // outbound warehouse-handling check, so it must be allowed even from Require Pick/Shipment locations. | ||
| if GetEffectiveDirectTransferPosting(TransferFromLocation, TransferToLocation) = "Direct Transfer Posting Type"::"Direct Transfer" then | ||
| exit; | ||
| if not Location.Get(TransferFromLocation) then |
There was a problem hiding this comment.
CheckDirectTransferAllowed calls Location.Get(TransferFromLocation) but only reads the boolean fields "Require Pick" and "Require Shipment" afterward.
Location is a wide master table, so this Get materializes every column when two would do. This procedure runs inside the component/WIP transfer loops (HandleComponentsForPurchLine, HandleWIPTransferForPurchLine), so the extra column transfer repeats per unique transfer-from location. Add SetLoadFields before the Get.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
Location.SetLoadFields("Require Pick", "Require Shipment");
if not Location.Get(TransferFromLocation) then
exit;Knowledge:
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| TransferHeader.Validate("Transfer-to Code", TransferToLocationCode); | ||
| if not TransferRoute.Get(TransferFromLocation, TransferToLocationCode) or (TransferRoute."In-Transit Code" = '') then | ||
| if not TransferRoute.Get(TransferFromLocation, TransferToLocationCode) or (TransferRoute."In-Transit Code" = '') then begin | ||
| CheckDirectTransferAllowed(TransferFromLocation, TransferToLocationCode); |
There was a problem hiding this comment.
InsertTransferHeader already fetches the full Transfer Route record for (TransferFromLocation, TransferToLocationCode) at the outer 'if not TransferRoute.Get(...)' guard.
When that Get fails or the route has no In-Transit Code, CheckDirectTransferAllowed is called, which internally re-fetches the same Transfer Route row (with SetLoadFields) inside GetEffectiveDirectTransferPosting purely to read "Direct Transfer"/"Direct Transfer Posting". This is a second round-trip for a key already queried moments earlier, and InsertTransferHeader runs inside the component/WIP-transfer loops so the duplicate lookup repeats per distinct location pair. Consider passing the already-loaded TransferRoute record (or its two relevant fields) into CheckDirectTransferAllowed instead of re-querying.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
Copilot PR ReviewIteration 1 · Outcome: completed Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 Findings by domainFindings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).
Totals: 2 knowledge-backed · 0 agent findings. Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
Fixes AB#640958
SubcCreateTransfOrder.InsertTransferHeaderunconditionally validated"Direct Transfer" := truewhen no in-transit route existed; the OnValidate callsVerifyNoOutboundWhseHandlingOnLocationwhichTestFields Require Pick/Require Shipment = false, throwing a raw error for warehouse-handling source locations. AddCheckDirectTransferAllowedthat raises a guided error (set up an in-transit route or use Direct Transfer posting) when the source location requires a pick or shipment and posting is not Direct Transfer. Adds a negative test.