[main] Bug 647499 Bin Replenishment with Pick by FEFO Creates Incorrect Inventory Movements - #10522
Conversation
Agentic PR Review - Round 1Recommendation: Request ChangesWhat this PR doesThe fix targets Bin Replenishment with Pick by FEFO in basic warehouse locations (codeunit 7322). When FEFO leaves the worksheet line's The two changes are aligned with those root causes: SuggestionsS1 - No automated test for inventory movement fix S2 - Destination-bin exclusion is not limited to FEFO Risk assessment and necessityRisk: Medium-high. Codeunit 7322 drives inventory pick and movement creation for all basic warehouse locations, so a change to availability summing and handled-line buffering has a wide blast radius. The destination-bin exclusion (S2) is not FEFO-gated, so non-FEFO movements can also be affected. Without a test, a regression here would surface as wrong on-hand quantities in the field. Necessity: The scenario is valid and important - incorrect inventory movements and stuck worksheet lines are a real data-integrity defect. The fix is warranted; it just needs test coverage and a confirmed scope before it can merge safely.
|
Bug 647499: [master][ALL-E] Bin Replenishment with Pick by FEFO Creates Incorrect Inventory Movements and Leaves Movement Worksheet Lines Unprocessed in Basic Warehouse Locations
Fixes AB#647499
Issue
Bin Replenishment with Pick by FEFO Creates Incorrect Inventory Movements and Leaves Movement Worksheet Lines Unprocessed in Basic Warehouse Locations
Root cause
Under Pick According to FEFO, Calculate Bin Replenishment leaves the worksheet line's From Bin blank (FEFO picks source bins at movement time). In codeunit 7322 this blank From Bin breaks two things:
1.Wrong quantity: CalcQtyAvailToPickOnBins counts a lot's stock across all bins including the destination bin. When the earliest FEFO lot already sits in the bin being replenished, that quantity gets reserved but can't be moved (can't move a bin onto itself), so it's dropped instead of rolling to the next lot — the movement comes up short.
2.Worksheet not cleared: UpdateHandledWhseActivityLineBuffer records the handled qty under the real take bin, but DeleteHandledWhseWorksheetLines matches it back to the worksheet line on From Bin (blank) — keys never match, so lines aren't removed and no confirmation shows.
Solution
CalcQtyAvailToPickOnBins: for a FEFO inventory movement, exclude the destination bin from the availability sum so FEFO moves on to the next movable lot and fulfills the full quantity.
UpdateHandledWhseActivityLineBuffer: when the source line is FEFO (blank From Bin), record the buffer under a blank From Bin so it reconciles with the worksheet line and the handled lines are deleted.