Expired Spare-Part Lots Can Be Allocated
Level 2 · node · Data · Missing expiration filter allows expired inventory allocation
Scenario
A fictional maintenance warehouse stores spare parts in lots, each with a quantity and an expiration timestamp. Repair requests must use only unexpired stock at the supplied current time. The existing service checks quantity but can select an expired lot first. Inspect the repository, service, and controller paths for inventory lookup and allocation.
Requirements
List and allocate only in-stock lots that have not expired for the requested part and current timestamp. A lot expires exactly at its expiration time. Decrement only the selected lot, preserve other parts' inventory, and keep lookups read-only. Do not add external packages.
Acceptance criteria
- Return only in-stock, unexpired lots for the requested part.
- Exclude lots when the current time equals or exceeds their expiration time.
- Allocation decrements only the selected valid lot by one unit.
- Never include lots belonging to a different part in lookup or allocation.
- Raise an error when no eligible lot remains.
- Inventory lookup does not mutate stored quantities.