Skip to main content

Inventory Lifecycle

Inventory in the embedded engine distinguishes on-hand from available. The gap between them is reservations, and getting that protocol right is what prevents overselling.

Setup

Create an item

Read stock

Reservations: the three-step protocol

This is the part worth understanding properly.
A reservation that is never confirmed or released holds stock indefinitely. It will not time out on its own.Wrap it so both outcomes are covered, including on the error path:

Why reserve at all

Without a reservation, two concurrent checkouts both read available stock as 1 and both succeed. Reserving makes the read-and-hold atomic, so the second checkout sees 0. Order the calls as reserve → authorise → confirm. Reserving first closes the race; confirming last means a declined card releases the stock rather than stranding it.

Adjustments

For counted corrections, damage, and shrinkage:
Adjustments are recorded as movements with an audit trail, not as a silent overwrite of a quantity — so a later discrepancy can be traced to the adjustment that caused it.

Cycle counts

For a systematic recount rather than a one-off correction, use the cycle-count workflow — draft → in-progress → completed, with variance applied transactionally to location inventory and a cycle_count movement record written. See Finance & Accounting.

Where reservations come from