Make invoice maths exact: half-up line rounding, per-rate VAT, largest-remainder allocation, banker's FX rounding
Exact prompt
# Task: make the invoice maths exact `money.py` uses binary floats and produces off-by-a-cent results. Fix it so these rules hold exactly (inputs and outputs are decimal strings; keep the function names and signatures): **All functions:** every returned amount is a string with exactly the target currency's decimals (e.g. "0.00", "-1.50", "1200" for JPY, "1.001" for BHD). Never output a negative zero such as "-0.00": a zero is always unsigned. `currency`/`to_currency` default to EUR where shown. **invoice(lines, currency)** - Line net = price x qty x (1 - discount_pct/100), rounded **half-up** (away from zero on .5) to the currency's decimals (EUR/USD 2, JPY 0, BHD 3). `qty` may be fractional, `discount_pct` is optional (default 0). Negative prices (credit lines) are allowed: half-up means 0.5 rounds away from zero for them too. - `net` = sum of rounded line nets. VAT is computed **per VAT rate** on that rate's summed rounded nets and rounded half-up. `vat` maps each rate string exactly as given (e.g. "20", "5.5") to its amount, in first-appearance order. `gross` = net + sum of VAT amounts. **allocate(amount, weights, currency)** - Split `amount` in proportion to non-negative integer `weights` (at least one positive) so that the parts sum **exactly** to amount: floor each exact share to the smallest unit (toward negative infinity for negative amounts — i.e. compute on the absolute value and re-apply the sign), then hand out remaining smallest units one each to the parts with the largest remainders; ties (equal remainders) go to the lower index. Example: `allocate("0.05", [3, 7])` -> `["0.02", "0.03"]` (exact shares 1.5 and 3.5 cents, equal remainders, the extra cent goes to index 0). Zero weight gets zero. Raise `ValueError` if all weights are 0. **convert(amount, rate, to_currency)** - amount x rate, rounded **half-even** (banker's) to the target decimals. Standard library only. No network.
Float classics (1.005, 2.675), half-up for negatives, VAT on grouped rounded nets, -0.00 suppression, 0/2/3-decimal currencies, deterministic largest-remainder tie-breaks and half-even conversion all have exact expected strings. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).
Success criteria: 1. All 9 hidden unittest cases pass: half-up line rounding incl. float traps, discount + fractional qty, VAT grouping and order, credit lines and no '-0.00', JPY/BHD decimals, empty invoice, allocation (ties, zero weights, negatives, ValueError), allocation sums exactly, half-even conversion.
Best model for this task so far: Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) (success, $0.0070, 30s).
All runs (4)
100% pass rate across 4 eligible runs: 4 pass, 0 partial, 0 fail. Partial and failed runs are listed below with everything else.ⓘ
| Model | Cost | Time | Step-insⓘ | Autonomy | Outcome | Trustⓘ | Date | Compare |
|---|---|---|---|---|---|---|---|---|
| OGPT-6.1 Soldefault · thinking on | $0.07 | 50s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-19 | |
| AClaude Haiku 5.5default · thinking on | $0.0070 | 30s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 | |
| AClaude Opus 5.5default · thinking on | $0.28 | 1m | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 | |
| AClaude Sonnet 5.5default · thinking on | $0.07 | 24s | 0 | Fully autonomous | pass | Trust 80% | 2026-10-17 |
Embed this result
A live badge for this use case. It links back here and updates as new runs are published.
Get new runs and ranking changes weekly
Which models got better or cheaper on real tasks like this one.