Summary
Bill generation can use an order snapshot read before its transaction, allowing a concurrent order mutation to produce a bill that does not match the committed order totals.
Current behavior
main/routes/bills.ts:163-245 reads the order before acquiring the transaction and creates or synchronizes the bill from that object. Concurrent discount, item-add, or cancellation work can commit between the read and bill write.
Expected behavior
Bill generation must snapshot the authoritative order state atomically and preserve a consistent subtotal, tax, discount, and total relationship.
Acceptance criteria
- Re-read or version-check the order inside the bill transaction.
- Define behavior for concurrent item, discount, cancellation, and payment mutations.
- Add concurrency tests asserting that the generated bill matches the committed order snapshot.
- Preserve existing tax snapshot and rounding contracts.
Relevant files
main/routes/bills.ts, main/routes/orders.ts
Summary
Bill generation can use an order snapshot read before its transaction, allowing a concurrent order mutation to produce a bill that does not match the committed order totals.
Current behavior
main/routes/bills.ts:163-245reads the order before acquiring the transaction and creates or synchronizes the bill from that object. Concurrent discount, item-add, or cancellation work can commit between the read and bill write.Expected behavior
Bill generation must snapshot the authoritative order state atomically and preserve a consistent subtotal, tax, discount, and total relationship.
Acceptance criteria
Relevant files
main/routes/bills.ts,main/routes/orders.ts