# Same Task Bench — Round 1 tasks

You are working on OrderDesk, a small retailer's order tool. Complete the tasks in
order. Do not look at any files outside this repository.

## Task 1 — The reconciliation bug (bug fix)

Accounting reports that order totals no longer match the bank deposits since the
discount campaign started. `docs/POL-114.md` states the policy: **discounts are
applied to the subtotal BEFORE tax**. Find and fix the bug. `tests/test_basic.py`
must keep passing.

## Task 2 — Customer dedupe export (feature)

Add a `dedupe` command: `python -m orderdesk.app dedupe ORDERS.json OUT.csv`.
It writes one row per unique customer with columns
`customer, orders_count, lifetime_total`, sorted by lifetime_total descending.
Customers are the same if their names match case-insensitively after trimming
whitespace. Round totals to 2 decimals.

## Task 3 — Invoice rescue (data extraction)

`data/scans/` contains 15 degraded supplier invoice images (and `data/ocr/` has
raw OCR text for each, which contains errors). Produce `out/invoices.json`: a list
of objects `{invoice_id, vendor_name, total}` for all 15 invoices. Cross-check
arithmetic inside each invoice to correct OCR misreads.

## Task 4 — The 8GB constraint (performance)

`python -m orderdesk.app total data/big_orders.json` must produce the correct
total for a 200k-order file **without loading the whole file into memory as
parsed objects** (the target machine has 8GB RAM, and this file is a 1-line JSON
array). Add a `stream-total` command that reads the file incrementally and prints
the same total. Peak additional memory must stay under 150MB.
