DEV Community

Olga Dimitrova
Olga Dimitrova

Posted on

Demo data that has to raise an alarm, without faking the total

I built a small payroll dashboard: plan against actual for seven departments over twelve months, on one screen, for an HR director who opens it on a phone. Its job is to signal when the year goes over budget. So the demo data had to trip the 3% overspend alarm, and I did not want to get there by setting the total and working backwards.

Live page: https://olgadimitrovagit.github.io/comp-budget-lab/budget-plan-fact/

The rule

Each department gets a monthly deviation from plan of 1 to 3 percent, always in the same direction. The company total is never set. It is whatever the departments add up to. The generator is seeded, so it gives the same CSV on every run.

Where it broke

The rule alone could not produce the alarm. I tried three times:

Round What I tried Year
1 All departments inside ±1-3% +0.82%. Engineering is 24% of payroll and underspends, which cancelled out the rest
2 Engineering at the bottom of its range, everyone else at the top +2.16% at most, still under 3%
3 Let one department, Sales, break out at 9-10% +3.25%

Round 3 is tuning, and I would rather say so. I didn't set the total, but I chose which department breaks out knowing what it would do to the year. It is also how I've seen payroll budgets fail in practice: in one place, not evenly. The exception is named in the code, and a check fails if a second department leaves the range.

The bug no test caught

From September the forecast adds a pay equalisation: €33,020 a month across 52 of 212 employees. Reading the output, I asked a simple question: why does the fourth quarter show a smaller overspend, when nothing is saved there and only a pay rise is added?

The generator had forecast = plan + uplift, so every department snapped back to plan in September. It should have been the department's own trend plus the uplift. All eight checks passed, and one of them even confirmed the wrong formula. I build these tools with an AI coding agent, and the checks were written together with the code, so they shared its blind spot. What caught it was a question from someone who knows how payroll behaves.

I rewrote that check and added three: the year must cross the alarm threshold, Sep-Dec must run hotter than Jan-Aug, and exactly one department may leave the range. Putting the old formula back now fails three of the 11 checks.

Smaller things that held

  • The Excel model recalculates in real Excel and matches the CSV to 0.000000 on all five control totals. On the way it was off by 136,081 EUR, then by 17.06 EUR. Both times I fixed the cause instead of widening the tolerance.
  • The whole dashboard is one HTML file of about 680 KB, with React and Recharts bundled inside, so it loads nothing from the network.
  • After my first post, a reader asked whether my network check also covered what happens after someone uploads a file. It didn't. Now both tools have a check that picks the sample CSV through the real file input and fails on any request. Thank you to that reader.

The data is synthetic, and the contribution rates are Spain 2026.

Repo, workbook, sample CSV, generator and checks: https://github.com/OlgaDimitrovaGit/comp-budget-lab/tree/main/budget-plan-fact

Top comments (0)