Skip to content

fix(checkout): generate bills from a consistent order snapshot #254

Description

@khaira777

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendBackend (Express/SQLite)bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions