Inventory Internal Consumption QA
Manual source-ledger checks for holds, issue, consumption, return, and expiry jobs.
Scope
This guide covers Inventory U4. Use a disposable tenant and two facilities. U5 now provides source HTTP routes. Use the source service or HTTP QA guide; Hospital screen integration is still separate. Follow the foundation setup. Grant View and consumption Manage through Shell. Use a separate adjustments grant for reversals. Use a separate stock manager with View and Manage to receive setup stock. Do not add receipt grants to the consumption-only actor.
Manual Checks
- Receive 10 units. Reserve six. Confirm on-hand 10, reserved six, and free four.
- Consume two against that allocation with the current reservation version. Confirm on-hand eight and reserved four.
- Release the remainder. Confirm on-hand eight and reserved zero. Repeat the same command key. Confirm no second effect.
- Reserve six and issue six from a store to an OT. Confirm the hold moves with physical stock. Confirm no consumption or billing event exists.
- Consume two against the issued custody and return four unused. Confirm custody is exhausted and four units return to the store.
- Try another return from that issue. Confirm a shortage and no new operation.
- Issue the same item twice into one OT bucket. Consume the first issue. Confirm the second issue cannot make the first returnable.
- Transfer free custody from OT to ward. Confirm the original issue link stays the same. Confirm later consumption reduces that custody's returnable amount.
- Try to consume unnamed issued stock or another hold's units. Confirm denial without partial changes.
- Reverse consumption with adjustments permission. Confirm stock and custody return, but the old hold does not return.
- Reverse the remaining part of an issue with an active hold. Confirm physical stock and that remaining hold move back together.
- Test a multi-line consumption with a shortage on the last line. Confirm every line rolls back.
- Roll back a Clinical caller transaction after a successful source command. Confirm operation identity, audit, holds, and physical stock all roll back.
- Leave a hold beyond its expiry without running the expiry job. Confirm it cannot authorize consumption.
- Leave an expiry-tracked lot unresolved. Confirm reserve and consume fail. Validate its label with approved interpretation evidence and test again.
- Correct the lot cutoff to the past. Confirm the hold stays recorded and quantities do not change. Confirm use fails and explicit release still works.
- Return expired or damaged units. Confirm quarantine stock increases, not usable stock.
- Run the expiry job twice with explicit tenant/facility IDs. Confirm one service operation, one release per remaining allocation, and no physical movement.
- Confirm foreign facility IDs, revoked grants, and stale versions fail, including identical retries.
Scheduled Job
config/schedule.rb enqueues the sweep every five minutes. The sweep enqueues one expiry job for each facility with elapsed holds.
Each expiry job enters an explicit tenant context and restores the prior context.
Commands check reservation and lot expiry under the stock lock. They do not rely on the sweep being on time.
Deployment must refresh the Whenever crontab and run the default Sidekiq queue.
These deployment checks have not been run by the automated source tests.
Evidence
- Attach the Inventory model, service, request where available, job, and RLS test results.
- Attach independent-connection race results for reserve, consume, issue, return, and custody transfer.
- Record migration, unused rollback, populated rollback refusal, and fresh schema-load results.
- Record reviewer findings and their fixes. Keep operator QA and deployment acceptance separate from local tests.