Skip to content

Monthly FIFO inventory report (COGS, write-offs, oversell exceptions) from a messy, shuffled stock-movement export

Exact prompt

# Task: monthly FIFO inventory report `transactions.csv` is an export of a small shop's stock movements. Write `fifo.py` (Python stdlib only) that reads `transactions.csv` from the current directory and writes `report.csv` and `exceptions.json` there, following the rules below exactly. Run it. The grader compares your two output files with the correct ones, then re-runs `fifo.py` on a freshly generated file of the same kind (different values, same rules), so do not hard-code anything. No network. ## Input Columns: `seq,date,sku,type,qty,unit_amount`. 1. `seq` is a unique integer per transaction. The export contains some exact duplicate rows (same `seq`); a row whose `seq` was already seen must be ignored. 2. Rows are NOT in order. Process transactions sorted by `date` (YYYY-MM-DD), then by `seq` ascending. 3. `sku`: trim spaces and upper-case it (` ab-1` and `AB-1` are the same SKU). `type` is case-insensitive and is one of `BUY`, `SELL`, `WRITE_OFF`. `qty` is a positive integer, possibly with surrounding spaces. 4. `unit_amount` is a decimal number that may have a leading `$`, thousands separators (`,`) and up to 4 decimal places, e.g. `$1,234.5678`. For BUY it is the unit cost; for SELL the unit sale price; for WRITE_OFF it is empty. ## Costing 5. Each BUY creates a lot (qty, unit cost). SELL and WRITE_OFF consume units from the oldest remaining lots first (FIFO), across as many lots as needed. 6. COGS of a SELL = sum over consumed units of their lot's unit cost; revenue = units actually sold x unit price. A WRITE_OFF's consumed cost is write-off cost (no revenue, not COGS, not units sold). 7. If a SELL or WRITE_OFF asks for more units than are on hand, consume everything on hand and record the missing units as an exception; revenue only counts the units actually sold. 8. Use exact decimal arithmetic. Round to 2 decimal places (half-up) only when writing the report; every reported number must equal the exact value rounded that way. ## Output 9. `report.csv` with header `month,sku,units_sold,revenue,cogs,write_off_cost,gross_margin,ending_units,ending_value`: one row per (month, sku) for every SKU that has at least one transaction in that month (month = `YYYY-MM`), sorted by month then sku. `gross_margin = revenue - cogs`, computed from the exact unrounded revenue and COGS and then rounded (so it can differ by 0.01 from subtracting the two rounded columns). `ending_units` and `ending_value` are that SKU's units on hand and their total cost at the end of that month (after all its transactions up to and including that month). Money columns are written with exactly 2 decimals (e.g. `12.50`, `0.00`, `-3.10`), no `$` or separators; unit columns as integers. 10. `exceptions.json`: a JSON list with one object `{"seq": <int>, "sku": "<normalised sku>", "short": <int missing units>}` per SELL/WRITE_OFF that was short, in processing order (`[]` if none).

Needs dedupe by seq, date+seq ordering, SKU/type normalisation, $/thousands parsing, multi-lot FIFO consumption, shortfall handling, exact Decimal maths with rounding only at output (gross margin from unrounded values), and a fresh-seed rerun blocks hand-editing. 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. report_correct: report.csv header, rows, order and every value exact to the cent, money columns with 2 decimals. 2. exceptions_correct: exceptions.json equals the expected list in processing order. 3. fresh_data_ok: fifo.py re-run on fresh data (seed 4747) produces correct report.csv and exceptions.json.

Best model for this task so far: Claude Haiku 5.5 (effort default (no --effort flag) · thinking on) (success, $0.0070, 28s).

Run this on another model

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.ⓘ

Runs for this use case
ModelCostTimeStep-insⓘAutonomyOutcomeTrustⓘDateCompare
OGPT-6.1 Soldefault · thinking on$0.0446s0Fully autonomouspassTrust 80%2026-10-22
AClaude Haiku 5.5default · thinking on$0.007028s0Fully autonomouspassTrust 80%2026-10-19
AClaude Opus 5.5default · thinking on$0.1524s0Fully autonomouspassTrust 80%2026-10-19
AClaude Sonnet 5.5default · thinking on$0.0619s0Fully autonomouspassTrust 80%2026-10-19

Embed this result

A live badge for this use case. It links back here and updates as new runs are published.

UseCaseRank badge for Monthly FIFO inventory report (COGS, write-offs, oversell exceptions) from a messy, shuffled stock-movement export

Get new runs and ranking changes weekly

Which models got better or cheaper on real tasks like this one.