Check the report against finance's numbers
Sanity-check two months of output, then reconcile each total against the figure finance closed, and explain the one that differs.
3 parts · 3, 8 and 3 min · part 2 on a computer
Free course. Your Maestro, an AI, .
Tracing a total back to its rows proves that report.py added up the file it was given. It does not tell you whether that file matches the rest of the business. Before a monthly report goes out, you verify its numbers in two passes: first against quick expectations about the shape of the data, and then against an independent figure from outside your pipeline.
Sanity-check the output first
A sanity check tests whether a result looks plausible before you dig into single transactions. You compare the output against benchmarks you already know about the business: the order of magnitude, the row count, the categories that should appear, and the plausible range of values.
For this monthly sales report, you know three expectations for any normal month:
- Each monthly file has 8 rows.
- All four regions (North, South, East, and West) are present.
- No single order is above 1,000.
Checking those three expectations in Python takes only a moment. If an export accidentally dropped a region, doubled its rows, or included a 50,000 typo, a sanity check would flag the problem immediately.
Passing every sanity check, however, only means the numbers look reasonable. A month can have 8 rows, all four regions, and normal order sizes, and still disagree with the company's accounting ledger.
Reconcile against an independent source
To know whether the total is right, you run a Glossary word: comparing your report's output against an independent figure that another system or team already closed, and explaining any difference between the two.
At month-end, finance closes the books and records its final monthly numbers in data/finance_close.csv, with columns for month, closed_total, and note. Because finance works from the accounting ledger rather than your sales export, their table is an independent benchmark.
When your report and finance's closed total differ, resist two common impulses:
- Do not assume
report.pyhas a calculation bug before reading the records behind both totals. Two accurate systems will disagree whenever they use different cutoff dates, such as a refund posted after the monthly sales export ran. - Never force the totals to match by editing the raw input file in
data/. Altering a source Glossary word by hand erases the record of what the sales system actually exported and hides the timing gap from everyone else.
Instead, calculate the exact difference, read finance's note, and inspect the specific order in the sales file. Once you can show which row accounts for the gap and why the two sources diverged, you keep the data file as it arrived and explain the difference alongside the report. If you are unsure whether a gap comes from a cutoff date or a code bug, ask your Maestro to walk through the logic with you.
Try it
Open check.py and run it to see the report totals for September and October next to finance's numbers. Then complete the two tasks in the comments:
- For each month, open
data/sales_{month}.csvand print the sanity checks: the number of rows, the sorted list of unique regions present, and the largest order amount. - Print the numeric difference between the report total and
closed_total, print finance'snote, and look up the specific order named in that note insidedata/sales_2026-10.csvto show its amount before and after the refund.
If you get stuck filtering the rows or matching the output format, ask your Maestro for a nudge.
A good place to stop. Up next: the workbench · 8 min · on a computer
A good place to stop. Up next: part 3 of 3 · 3 min
What your checks show
Both months pass every sanity check: 2026-09 and 2026-10 each have 8 rows, contain all four regions (East, North, South, and West), and stay below 1,000 on every row, with a largest order of 500.0 in September and 620.0 in October.
Reconciling the totals against data/finance_close.csv separates the two months:
- In 2026-09, the report total is 3000.0 and finance closed at 3000, a difference of 0.0.
- In 2026-10, the report total is 2800.0 while finance closed at 2750, a difference of 50.0.
Finance's note for 2026-10 explains the 50.0 gap: "refund R-17 of 50 on order S-1007 posted 2026-11-03". Because the refund was posted on 2026-11-03, after the October sales export ran, data/sales_2026-10.csv still shows order S-1007 at 190. With the 50 refund applied, S-1007 drops to 140.0 and the monthly total moves from 2800.0 to 2750.0.
Neither number is an error. Your report is right about the orders in the export, and finance is right about the closed books after the November 3 refund. Leaving data/sales_2026-10.csv untouched and stating that 50.0 timing difference tells a reader which figure fits their question.