Skip to content

fix(checkout): make split checks atomic and allocation-safe #253

Closed

Description

@khaira777

Summary

Split-check creation validates source state outside the transaction and uses proportional rounding that can produce an invalid negative remainder for small totals.

Current behavior

  • main/routes/bills.ts:263-339 reads and validates the source bill before withTxn.
  • Concurrent split requests can both pass validation and create multiple split groups.
  • The final check receives totalMinor - used; rounded allocations can make this negative.
  • void_adjustment rows are not excluded from item allocation.

Expected behavior

A split operation should be atomic, repeat-safe, and allocate non-negative integer minor-unit amounts whose sums reconcile exactly.

Acceptance criteria

  • Move source-state validation and allocation reads into the transaction.
  • Allow only one split group per source order/bill.
  • Use a largest-remainder or equivalent integer-minor-unit allocation algorithm.
  • Reject or exclude invalid/void-adjustment rows.
  • Add concurrent split, one-cent total, and voided-item regression tests.

Relevant files

main/routes/bills.ts, split-check integration tests

Activity

  1. added
    area:backend
    on Aug 11, 2026
  2. khaira777 commented on Aug 12, 2026

    @khaira777
    ContributorAuthor

    Verification before implementation found this issue partially confirmed.

    The negative-remainder allocation bug and void_adjustment exposure were reproduced. Mutable split-state validation was also moved fully into the transaction as structural hardening. The claimed duplicate split-group race was not reproduced in the current synchronous runtime: concurrent HTTP requests serialize and the duplicate request receives 409. PR #269 addresses the confirmed defects and adds regression coverage.

  3. self-assigned this
    on Aug 13, 2026
  4. added a commit that references this issue on Aug 13, 2026
    61f590c
  5. added a commit that references this issue on Aug 16, 2026
    de207ae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:backend

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions