Blog
Why your invoice total is off by a cent
Two correct ways to round tax give two different totals, and computers add a third error of their own. Worked examples, and what HMRC and the ATO allow.
When your invoice and your client’s system disagree by a single cent, it is almost never a typo. It is usually one of two things: you rounded the tax on the total and they rounded it on each line, or a piece of software rounded a number that was never quite the number it looked like. The first is a legitimate difference that tax authorities allow for. The second is a bug.
This post shows both with real numbers, and says which method each authority accepts. It matters most once you are registered for VAT or GST, which is also when the rest of what goes on an invoice becomes a legal requirement.
Cause one: tax per line or tax on the total
Take an invoice with four items at £4.99 each, and 20% VAT.
Tax on the total. The subtotal is £19.96. Twenty percent of that is £3.992, which rounds to £3.99.
Tax on each line. Twenty percent of £4.99 is £0.998, which rounds to £1.00. Four of those is £4.00.
Same items, same rate, both calculations done correctly, and the tax differs by a penny. Here is a second one, with three different prices:
| Line | Price | 20% VAT, exact | Rounded per line |
|---|---|---|---|
| A | £9.99 | £1.998 | £2.00 |
| B | £4.99 | £0.998 | £1.00 |
| C | £2.49 | £0.498 | £0.50 |
| Totals | £17.47 | £3.494 | £3.50 |
Rounded once on the total, the VAT is £3.49. Rounded on each line and then added, it is £3.50.
Rounding each line settles every fraction separately, and when several lean the same way, as they do here, the errors add up. Rounding once on the total lets the fractions combine before any rounding happens. Neither is wrong. They are two answers to the question of when to round.
What the rules allow
There is no single rule. The EU’s highest court said so in the Wetherspoon case, about the pub chain’s prices: EU law “contains no specific requirement concerning the method of rounding amounts of value added tax”, so it is for each member state to decide.
UK. HMRC’s VAT Notice 700, section 17.5, allows both, with conditions:
- On the total, you may round the VAT on the whole invoice down to a whole penny and ignore the fraction.
- On each line, you may round down to the nearest 0.1p, or to the nearest 1p or 0.5p. “Whatever you decide, you must be consistent.”
- The round down concession is for businesses that issue invoices. Retailers must not round VAT down.
Australia. The ATO describes the same two choices and names them. Under the total invoice rule you work out the GST for each sale and round each one to the nearest cent. Under the taxable sale rule (the legislation calls it the taxable supply rule) you work out the GST for each sale, add them up, and round the total to the nearest cent, with half a cent rounding up. The ATO also says: “You and your customers don’t need to use the same rounding rules.”
That last sentence is the practical answer to the one cent dispute. Your invoice and your client’s books can both be right, even when they differ.
Cause two: the number was never what it looked like
This one is a software problem, and it catches spreadsheets and hand written invoice tools alike.
Computers store most decimals in binary, and binary cannot hold 0.1 exactly, any more than decimal can hold one third exactly. The number is stored as the nearest value binary can represent. Usually the difference is invisible. Sometimes it lands on exactly the wrong side of a rounding line.
A charge of $1.005, rounded to the cent, should be $1.01. In JavaScript, the language every web based invoice tool runs on:
1.005 * 100 // 100.49999999999999
Math.round(1.005 * 100) // 100, so the invoice says $1.00
(1.005).toFixed(2) // "1.00"
0.1 + 0.2 // 0.30000000000000004
1.005 is stored as something very slightly less than 1.005, so it rounds down.
The customer is billed a cent less than the arithmetic on paper says. On one line
that is trivial. On a tool that bills thousands of lines, or that adds up floats
before rounding, it is a reconciliation problem that nobody can find by reading the
invoice, because every number printed on it looks right.
Two standard fixes:
- Work in whole minor units. Cents, pence, whole yen. Integers are exact in binary, so once an amount is 101 cents it stays 101 cents through any number of additions.
- Clean the product before rounding it. Rounding to twelve significant digits
first turns
100.49999999999999back into100.5, which then rounds to 101 as it should. Twelve digits is far more than any invoice needs, and far enough below the limit of a double that the stray digits fall away.
How our generator does it
We use both fixes, and one tax method. In order:
- Each line’s quantity times rate is converted to minor units immediately, cleaned to twelve significant digits, and rounded to a whole cent. From there on, everything is an integer. $1.005 comes out as $1.01.
- The subtotal is the sum of those whole cent line amounts.
- Tax is worked out once, on the subtotal, and rounded to the nearest cent.
- The total is subtotal plus tax, with no further rounding.
Currencies without cents are handled the same way with their own number of decimals, read from the browser: three items at ¥333 with 10% tax is ¥999 plus ¥99.9 of tax, which is shown as ¥100.
That third step is the ATO’s taxable sale rule exactly, since the tax on the subtotal is the same as adding up the unrounded tax on each line. Under HMRC’s rules it is the total method, but rounded to the nearest penny rather than down, so now and then our VAT figure is a fraction of a penny higher than the lowest HMRC allows: a £10.03 subtotal gives £2.006 of VAT, which we show as £2.01 and HMRC would let you round down to £2.00. We chose the nearest penny because it is what people check an invoice against with a calculator. If your accountant prefers the round down method, the difference is at most one penny per invoice.
The generator has one tax rate per invoice, and no per line rounding option yet.
Further reading
- VAT guide, VAT Notice 700, HMRC. Section 17.5 is rounding on invoices, 17.6 is the rule for retailers.
- Judgment in case C-302/07, J D Wetherspoon, the Court of Justice of the European Union, on why VAT rounding is left to each member state.
- Tax invoices: rounding of GST, Australian Taxation Office.
- What Every Computer Scientist Should Know About Floating-Point Arithmetic, David Goldberg’s classic paper on why 0.1 cannot be stored exactly.
- Number.prototype.toFixed(),
MDN, whose own examples show
(2.55).toFixed(1)giving “2.5” for the same reason.