URS-016 · Auto-decrement Inventory After Order Submission
Status: FAIL · Duration: 1m 13s · Run Date: April 21, 2026
Test Scenarios
Section titled “Test Scenarios”Step 1: Initial inventory
Section titled “Step 1: Initial inventory”

Step 2: First order
Section titled “Step 2: First order”




Step 3: Verify first decrement
Section titled “Step 3: Verify first decrement”
Playwright execution
Section titled “Playwright execution”Recordings
Section titled “Recordings”step 01 initial inventory
Section titled “step 01 initial inventory”step 02 first order
Section titled “step 02 first order”step 03 verify decrement
Section titled “step 03 verify decrement”Database Validations
Section titled “Database Validations”Inventory items exist at trunk
Section titled “Inventory items exist at trunk”Both test inventory items (SpeedPatch and FiberLocker) should exist at TRUNK-36
SELECT ii.id, ii.di, ii.lot, ii.quantity_ready, ii.quantity_backordered, ii.quantity_in_transit FROM inventory_items ii WHERE ii.real_world_location_id = $1 AND ii.lot IN ($2, $3) ORDER BY ii.lot| id | di | lot | quantity_ready | quantity_backordered | quantity_in_transit |
|---|---|---|---|---|---|
| baf7086a-9bf8-4647-948a-6a1d97108e33 | 07649988202247 | URS016-FL-001 | 13 | 0 | 0 |
| cdc2b050-ed32-454d-b123-24feb9fa4254 | 07649988202230 | URS016-SP-001 | 17 | 0 | 0 |
Inventory quantities decremented
Section titled “Inventory quantities decremented”Both inventory items should have quantity_ready less than their initial values
SELECT ii.lot, ii.quantity_ready, CASE WHEN ii.lot = $2 THEN 20 WHEN ii.lot = $3 THEN 15 END as initial_quantity, CASE WHEN ii.lot = $2 THEN 20 - ii.quantity_ready WHEN ii.lot = $3 THEN 15 - ii.quantity_ready END as total_decremented FROM inventory_items ii WHERE ii.real_world_location_id = $1 AND ii.lot IN ($2, $3) ORDER BY ii.lot| lot | quantity_ready | initial_quantity | total_decremented |
|---|---|---|---|
| URS016-FL-001 | 13 | 15 | 2 |
| URS016-SP-001 | 17 | 20 | 3 |
Recent billing orders created
Section titled “Recent billing orders created”At least one billing order should have been created by Bob Kauffman in the last 30 minutes
SELECT bo.id, bo.order_number, bo.status, bo.procedure_date, bo.created_at, bo.created_by_user_id FROM billing_orders bo WHERE bo.created_by_user_id = $1 AND bo.created_at > NOW() - INTERVAL '30 minutes' ORDER BY bo.created_at DESC LIMIT 5| id | order_number | status | procedure_date | created_at | created_by_user_id |
|---|---|---|---|---|---|
| 019dade6-83cd-772f-8d65-2a3312027e9a | BO-1 | submitted | 2026-04-20T05:00:00.000Z | 2026-04-21T02:37:38.620Z | 17b8c9d0-e1f2-3456-1234-567890123456 |
Billing order items reference correct products
Section titled “Billing order items reference correct products”Billing order items should reference SpeedPatch and/or FiberLocker products
SELECT boi.id, boi.billing_order_id, op.title as product_name, boi.lot_number, boi.serial_number, boi.location_id, boi.inventory_discrepancy FROM billing_order_items boi JOIN org_products op ON boi.product_id = op.id JOIN billing_orders bo ON boi.billing_order_id = bo.id WHERE bo.created_by_user_id = $1 AND bo.created_at > NOW() - INTERVAL '30 minutes' ORDER BY bo.created_at DESC, op.title| id | billing_order_id | product_name | lot_number | serial_number | location_id | inventory_discrepancy |
|---|---|---|---|---|---|---|
| 019dade6-83ca-7215-ba15-cee0b01a5b19 | 019dade6-83cd-772f-8d65-2a3312027e9a | FiberLocker® Instrument SN | URS016-FL-001 | a6e7f8a9-b0c1-2345-0123-456789012345 | false | |
| 019dade6-83ca-7215-ba15-cee1a24c7aa7 | 019dade6-83cd-772f-8d65-2a3312027e9a | FiberLocker® Instrument SN | URS016-FL-001 | a6e7f8a9-b0c1-2345-0123-456789012345 | false | |
| 019dade6-83ca-7215-ba15-cee2651b1461 | 019dade6-83cd-772f-8d65-2a3312027e9a | SpeedPatch® PET | URS016-SP-001 | a6e7f8a9-b0c1-2345-0123-456789012345 | false | |
| 019dade6-83ca-7215-ba15-cee33600bfc7 | 019dade6-83cd-772f-8d65-2a3312027e9a | SpeedPatch® PET | URS016-SP-001 | a6e7f8a9-b0c1-2345-0123-456789012345 | false | |
| 019dade6-83ca-7215-ba15-cee4c99ed511 | 019dade6-83cd-772f-8d65-2a3312027e9a | SpeedPatch® PET | URS016-SP-001 | a6e7f8a9-b0c1-2345-0123-456789012345 | false |
Inventory history records bill_only_order removals
Section titled “Inventory history records bill_only_order removals”Inventory history should contain records with action=removed and reason=bill_only_order
SELECT ih.id, ih.item_id, ih.quantity, ih.status, ih.info, ih.created_at, ih.inventory_id FROM inventory_history ih WHERE ih.item_id IN ( SELECT id FROM inventory_items WHERE real_world_location_id = $1 AND lot IN ($2, $3) ) AND ih.created_at > NOW() - INTERVAL '30 minutes' AND ih.info->>'action' = 'removed' AND ih.info->>'reason' = 'bill_only_order' ORDER BY ih.created_at DESC LIMIT 20| id | item_id | quantity | status | info | created_at | inventory_id |
|---|---|---|---|---|---|---|
| 019dade6-83d3-7441-b6ec-88404d3172f9 | baf7086a-9bf8-4647-948a-6a1d97108e33 | 2 | ready | [object Object] | 2026-04-21T02:37:38.620Z | 019dade5-e978-7ffd-ae76-88b746f288c3 |
| 019dade6-83d3-7441-b6ec-8841d5d603d3 | cdc2b050-ed32-454d-b123-24feb9fa4254 | 3 | ready | [object Object] | 2026-04-21T02:37:38.620Z | 019dade5-e978-7ffd-ae76-88b746f288c3 |
Inventory transactions created
Section titled “Inventory transactions created”Inventory transactions should exist with source_type = bill_only_order
SELECT it.id, it.source_type, it.source_id, it.created_at, it.distributor_organization_id, it.manufacturer_organization_id FROM inventory_transactions it WHERE it.source_type = 'bill_only_order' AND it.created_at > NOW() - INTERVAL '30 minutes' AND (it.distributor_organization_id = $1 OR it.manufacturer_organization_id = $1) ORDER BY it.created_at DESC LIMIT 10| id | source_type | source_id | created_at | distributor_organization_id | manufacturer_organization_id |
|---|---|---|---|---|---|
| 019dade6-83d1-7e4d-819c-61d4b420b53b | bill_only_order | 019dade6-83cd-772f-8d65-2a3312027e9a | 2026-04-21T02:37:38.620Z | b2c3d4e5-f6a7-8901-bcde-f12345678901 |
No negative inventory quantities
Section titled “No negative inventory quantities”Inventory quantities should never go below zero (CHECK constraint enforced)
SELECT ii.id, ii.lot, ii.quantity_ready FROM inventory_items ii WHERE ii.real_world_location_id = $1 AND ii.lot IN ($2, $3) AND ii.quantity_ready < 0No rows returned.