Actual Code All articles
Careers

Nine Boxes and a Nervous Accountant: A Day Sat With Finance Taught Me What a VAT Return Really Is

Actual Code
Nine Boxes and a Nervous Accountant: A Day Sat With Finance Taught Me What a VAT Return Really Is

Photo: Infoacrosseverything, CC BY 4.0, via Wikimedia Commons

The ticket was four lines long. Build a VAT report. Show the totals by period. Export to CSV. Done by Friday.

It was not done by Friday. It was not really a report, and the person who could have told us that in ten minutes was sitting forty feet away, doing the returns by hand in a spreadsheet and a HMRC portal login.

The brief versus the reality

The brief assumed a VAT return is an output: nine numbers derived from invoices, printed, filed. What we built was a calculator. What finance actually runs is a process with state, deadlines, amendments, corrections and a receipt from HMRC that has to be kept.

So we did the obvious thing, which is embarrassingly rare: we asked to sit with them for a day.

Nine boxes, and none of them are the total

On a UK VAT return, boxes 1 to 9 are not a running total of anything. Box 1 is VAT due on sales. Box 4 is VAT reclaimed on purchases. Box 3 is the sum. Box 5 is the difference and can be negative — that is a repayment, not an error. Boxes 6 and 7 are net values excluding VAT. Boxes 2 and 8 cover acquisitions and dispatches, and after Brexit they are largely the Northern Ireland story rather than the EU one.

Our first draft treated box 5 as a number that could not go below zero. The accountant looked at it the way you would look at a spellchecker that had autocorrected a legal name.

If you model VAT as a single figure attached to an invoice, you will be wrong within a month. Each line has a rate, a treatment and a VAT amount. Zero-rated and exempt are different things and both matter at return time. Some purchases are outside the scope. Some have reverse charge applied. The return is an aggregation of treatments, not of money.

The rounding argument that lasted until lunch

VAT is calculated per line or per invoice, rounded to the nearest penny, and the return sums what has already been computed. The mistake developers make is to recompute the VAT from the net total at return time and hope the numbers match.

They will not. A twenty-line invoice with odd quantities will round differently depending on where you round, and HMRC does not want a new answer each month. The safe model is to store the VAT amount as calculated at the moment of invoicing and never derive it again. If a return needs to add them up, it adds up the stored values.

The consequence is that a one-penny difference between your system and the accountant's spreadsheet is not automatically a bug. It might be a different but equally valid rounding convention, which means it is a conversation, not a fix.

Reversals are not negative invoices

Credit notes are their own document. They reference the original invoice, they carry their own VAT treatment, and they can be raised in a different period from the one they relate to — which is when the fun starts.

Then there is bad debt relief: if a customer has not paid after six months, VAT already accounted for can sometimes be reclaimed, and if they pay later it has to be paid back. That is a state machine hiding in an accounts receivable table. Nothing in the original ticket hinted that we needed one.

Making Tax Digital is a workflow, not an export button

Making Tax Digital means the return is submitted through compatible software via an API, and the figures going in must be digitally linked to the records they came from. In practice, for a developer, that means:

Edge cases that no specification mentions

After a day of shadowing we had a list that would have taken a month of reading to assemble:

None of that is exotic. It is a normal Tuesday for a finance team.

What it taught us about modelling

A submitted return should be immutable. Corrections are adjustments with their own audit trail, not edits to history. The obligation exists before the numbers do and outlives them. Every figure on the return should be traceable back to the documents that produced it, or the next audit will be somebody's worst week.

We ended up with a domain model, not a report. It took longer than Friday. It has not been rewritten since.

The career bit

The most valuable thing a developer can do in a regulated domain is not learn the framework. It is learning how to sit with the people who use the system every month, ask naive questions without embarrassment, and write down the answers in language the domain recognises.

That skill does not appear on many CVs. It probably should. Nobody has ever regretted a day spent with the finance team. Plenty of teams have regretted a Friday deadline instead.

All Articles

Related Articles

Five Years On: What Happened to the Apprentice, the Bootcamp Grad and the Computer Science Kid

Five Years On: What Happened to the Apprentice, the Bootcamp Grad and the Computer Science Kid

Nobody Packed Up the Mentoring: Lessons From an Agency That Went Remote by Mistake

Nobody Packed Up the Mentoring: Lessons From an Agency That Went Remote by Mistake

Monday Me, Friday Me and the Sunday Night Phone Call: A Freelancer's Week in Full

Monday Me, Friday Me and the Sunday Night Phone Call: A Freelancer's Week in Full