Blog ·
"How many are in stock?" is a question with several answers
Available to sell, physically present, or committed to someone: they diverge constantly, and treating them as one number is how a salesperson sells something that left the warehouse yesterday.

Ask how many units are in stock and the honest answer is another question: available to sell, physically present, or committed to someone?
They diverge constantly — and treating them as one number is how a salesperson sells something that left the warehouse yesterday.
The states a unit passes through
And none of them are “in stock” or “out of stock”:
- Physically present and free.
- Reserved for an order that isn’t invoiced yet. Still on the shelf; no longer sellable.
- Invoiced and awaiting dispatch.
- On a truck. Not in the warehouse, not yet the customer’s — and if the delivery fails, it comes back.
- Delivered.
Plus in transit between warehouses, which belongs to neither end for the duration.
What follows from modelling it properly
Availability is a computation, not a column. Physical quantity minus reservations, per location. If it’s stored as a single number, something has to keep it right on every transition — and eventually one path forgets.
Movements are the source of truth and the quantity is derived — the same argument as a ledger. When the numbers are wrong, you need to see what happened, not just what the total says.
A failed delivery is a normal path, not an error. The goods return, the reservation is restored, and the document goes back to a state it was already in. If the model only handles the happy path, that becomes a manual fix.
The underlying point: “in stock” is a business question with several correct answers. A single integer answers none of them well.
It’s the model behind the multi-warehouse logistics in YSY Empresa: movements as the source of truth, availability computed per location, and the failed delivery as part of the flow.