feat(parser): warn when receipt totals do not reconcile #95

Closed
opened 2026-07-07 09:26:26 +01:00 by TimCane · 1 comment
TimCane commented 2026-07-07 09:26:26 +01:00 (Migrated from github.com)

Parent: #77 (Phase B, capability). Invariants live in the epic.

Flag receipts whose parts do not add up to the printed total.

Anchors

  • ReceiptParser.cs:211 - new Bill(tax, tip, service, total?.Amount ?? 0);
    the parsed pieces to reconcile.
  • Warnings list: ReceiptParser.cs:82.
  • backend/src/BillSplitter.Domain/Bill.cs - field names.

Steps

  1. Add a validator in Parsing/Validation: compare
    sum(items) + tax + tip + service against the printed grand total within a
    tolerance.
  2. On mismatch, add a Warnings entry the host sees at review. No DTO/Redis
    change.

Done

  • New fixture(s): one reconciling, one not.
  • Existing corpus green; change an expected.json only if a receipt
    legitimately does not reconcile, with justification in the PR.
Parent: #77 (Phase B, capability). Invariants live in the epic. Flag receipts whose parts do not add up to the printed total. ## Anchors - `ReceiptParser.cs:211` - `new Bill(tax, tip, service, total?.Amount ?? 0)`; the parsed pieces to reconcile. - Warnings list: `ReceiptParser.cs:82`. - `backend/src/BillSplitter.Domain/Bill.cs` - field names. ## Steps 1. Add a validator in `Parsing/Validation`: compare `sum(items) + tax + tip + service` against the printed grand total within a tolerance. 2. On mismatch, add a `Warnings` entry the host sees at review. No DTO/Redis change. ## Done - [ ] New fixture(s): one reconciling, one not. - [ ] Existing corpus green; change an `expected.json` only if a receipt legitimately does not reconcile, with justification in the PR.
TimCane commented 2026-07-07 15:55:05 +01:00 (Migrated from github.com)

Not planning this: the reconcile signal is already covered. SplitCalculator owns the items-vs-total checksum (bill.checksumMinor) and ChecksumBanner shows it on the review screen, formatted and live. A parser-level warning would be a duplicate of that math (which CLAUDE.md keeps solely in SplitCalculator). See #108 for the details.

Not planning this: the reconcile signal is already covered. `SplitCalculator` owns the items-vs-total checksum (`bill.checksumMinor`) and `ChecksumBanner` shows it on the review screen, formatted and live. A parser-level warning would be a duplicate of that math (which CLAUDE.md keeps solely in `SplitCalculator`). See #108 for the details.
Sign in to join this conversation.
No description provided.