Skip to content

[5.x] Fix reserved stock not updating after fulfillment or inventory transfers - #4367

Draft
lukeholder wants to merge 2 commits into
5.xfrom
bugfix/5.x-4268-inventory-reserved-stock
Draft

lukeholder wants to merge 2 commits into
5.xfrom
bugfix/5.x-4268-inventory-reserved-stock

Conversation

@lukeholder

@lukeholder lukeholder commented Sep 15, 2026

Copy link
Copy Markdown
Member

When an order needs more stock than one location has, Commerce reserves the shortfall at another location. But nothing ever resolved that reservation afterwards:

  • Orders could be fulfilled for more than a location physically had in stock.
  • Moving that reserved stock via an inventory transfer only ever touched plain "available" stock, never the reservation itself — so the reservation was left stranded even after the stock had actually moved.

Resolves #4268

Fix

  • Fulfilling an order can no longer exceed the physical stock actually on hand at that location.
  • When a transfer moves stock out of a location that has reserved stock, it now draws down that reservation first (oldest reservation first) instead of just decrementing available stock.
  • When that transfer is received, the reserved stock is committed to the correct order at the destination, instead of becoming generic available stock.

Testing

  • Added unit tests covering the fulfillment guard and the transfer/reservation flow.

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 lukeholder changed the title Fix reserved stock not updating after fulfillment or inventory transfers [5.x] Fix reserved stock not updating after fulfillment or inventory transfers Sep 16, 2026
@lukeholder
lukeholder marked this pull request as draft September 16, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[5.x]: "Reserved" stock is not updated after order fulfillment or inventory transfer

1 participant