[5.x] Fix reserved stock not updating after fulfillment or inventory transfers - #4367
Draft
lukeholder wants to merge 2 commits into
Draft
lukeholder wants to merge 2 commits into
lukeholder wants to merge 2 commits into
Conversation
Fulfillment could exceed a stock location's physical on-hand quantity since InventoryFulfillMovement had no balance guard (only committed stock, which is allowed to go negative by design, was checked). Added an on-hand validation rule modeled on InventoryManualMovement's existing negative-balance checks. Inventory transfers also never touched order-linked RESERVED stock: moving a transfer to Pending always debited AVAILABLE at the origin, and receiving a transfer only ever credited AVAILABLE at the destination, leaving reservations created by orderCompleteHandler()'s shortfall logic permanently stranded. Transfers now debit RESERVED stock (oldest reservation first) before AVAILABLE at Pending, and receiving a transfer resolves those earmarked units into COMMITTED stock at the destination, tagged to the correct order line item. Fixes #4268
The fulfillment modal only ever showed a generic "Invalid inventory movements." toast on failure — the specific validation message (e.g. the new on-hand stock guard) was returned in the response but never displayed, since the modal's fields don't have a data-attribute for the per-field error mechanism to attach to. Use the actual validation message as the toast text instead.
lukeholder
marked this pull request as draft
September 16, 2026 11:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an order needs more stock than one location has, Commerce reserves the shortfall at another location. But nothing ever resolved that reservation afterwards:
Resolves #4268
Fix
Testing