[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-647067-main-BinReplenishment_FEFOPick_IncorrectInvt
|
Fixed S1 and S2 |
Agentic PR Review - Round 2Recommendation: AcceptWhat this PR doesThe fix targets Bin Replenishment with Pick by FEFO in basic warehouse locations (codeunit 7322). When FEFO leaves the worksheet line's Since round 1 both prior blockers are resolved. In Status of previous suggestions
New observations (commits since round 1)None - the changes only addressed the two prior suggestions, and no new issues were found. Risk assessment and necessityRisk: Low, and lower than round 1. The availability-sum exclusion and the handled-line buffer change are both now gated on Necessity: Unchanged from round 1. Incorrect inventory movements and stuck worksheet lines are a real data-integrity defect; the fix is warranted, correctly scoped, and now covered by a test.
|
There was a problem hiding this comment.
Pull request overview
Fixes a FEFO bin replenishment edge case in basic warehouse locations where a blank From Bin (FEFO-selected at movement time) could (1) miscalculate available quantity by including the destination bin and (2) prevent handled worksheet lines from being deleted due to key mismatches.
Changes:
- Exclude the destination bin from FEFO inventory-movement availability calculations when the worksheet line’s From Bin is blank.
- Reconcile handled-quantity buffering for FEFO (blank From Bin) movements by recording the buffer under a blank From Bin so deletion can match the worksheet line.
- Add a regression test covering the “earliest lot already in destination bin” scenario and worksheet-line cleanup.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Layers/W1/BaseApp/Warehouse/Activity/CreateInventoryPickMovement.Codeunit.al | Adjusts FEFO movement bin-availability and handled-line buffering logic for blank From Bin scenarios. |
| src/Layers/W1/Tests/SCM-Warehouse/SCMMovement.Codeunit.al | Adds a regression test and supporting helpers for FEFO replenishment when the earliest lot is already in the destination bin. |
Suppressed comments (1)
src/Layers/W1/Tests/SCM-Warehouse/SCMMovement.Codeunit.al:1211
- This comment refers to specific lot/bin labels ("L1", "L2", "F1", "F2"), but lots and bins are generated as GUIDs in the test. Using neutral wording avoids confusion when reading test output.
// [GIVEN] Earliest lot "L1" is split between source bin "F1" (50) and the pick bin itself (50); later lot "L2" has 100 in "F2"
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.