Checkout reserves stock before payment. A reservation is later released, which returns the stock, or committed, which sells it. The nightly reconciliation keeps finding stock counts that do not match the reservations beh…
Checkout reserves stock before payment. A reservation is later released, which returns the stock, or committed, which sells it. The nightly reconciliation keeps finding stock counts that do not match the reservations behind them.
{"A": 5}.A as r1, then call release("r1") twice.available("A") reports 7.reserve(reservation_id, sku, quantity) returns True only when the SKU exists, the quantity is positive, the reservation ID is new and there is enough stock.reserve changes nothing: no stock moves and no reservation is stored.release(reservation_id) works once, for an active reservation: it restores the stock exactly once and removes the reservation.commit(reservation_id) works once, for an active reservation: it removes the reservation without restoring stock.available(sku) returns the current stock, or 0 for an unknown SKU.Stock can be restored more than once, and reconciliation finds reservations that were silently replaced.
ValueError.The code lives in src/inventory_reservations.py. Read how InventoryService, InventoryItem, Reservation, ReservationStore and ReservationStatus work together before changing anything. Run the existing tests with pytest tests/visible.
Visible test command
pytest tests/visibleThe repository’s own tests. Run all tests includes them, and so does every submission.
Repository
inventory-reservations
Changes under src/ are evaluated.