VAT calculations

Posted on 28 November 2008 in Programming, Resolver One

There's been an interesting discussion over at Smurf on Spreadsheets about the consequences of the UK government's temporary VAT rate reduction. For the benefit of non-UK readers, VAT is basically the british sales tax (it differs a little in implementation from a simple sales tax). It is currently 17.5%, but as a reaction to the financial crisis, it will be reduced to 15% from 1 December 2008 until 31 January 2010 inclusive. Whether this makes sense as a matter of economic policy is, of course, highly contentious. But this is a technical blog so I'll stick to its effect on spreadsheets :-)

The problem is, of course, that there are thousands of spreadsheets throughout the UK using formulae like =A1 * 1.175 to calculate gross prices from net. Finding and fixing all of these is like a miniature version of fixing y2k bugs, worsened by the fact that this rate change was announced with just one week's notice (which makes sense, as otherwise spending could have frozen up until the new rate came in, but is still a pain for people who have to implement the change).

Now, I don't think there's any way that this could have been avoided entirely. Spreadsheets frequently start out has a scratchpad, where someone is just running some numbers and intends to throw the sheet away. Sometimes these scratchpads are valuable enough to be kept, and sometimes when that happens, magic numbers like 1.175 aren't extracted into a named cell called vatRate. They should be, of course, but they won't always be. So there are a lot of crappy spreadsheets out there.

If some spreadsheets are always going to be broken, the interesting question is: what happens with the well-designed spreadsheets? The ones where there's a named vatRate cell which just needs to be updated? Well, unfortunately, they're going to be broken too. There are two problems:

How to fix the mess? Or, at least, how could you write spreadsheets to guard against this kind of problem? Obviously, as someone who runs a company producing a souped-up Python-based spreadsheet, I was hoping that there was some kind of useful trick to handle this in our product -- and after a bit of thought, I realised there is.

In Resolver One you can create a single spreadsheet to represent your VAT calculations, and then use it like a function from other sheets. So you can create a spreadsheet that, given a date and a VAT type (some products get a reduced VAT rate, or are entirely exempt -- for example, there's no VAT on groceries), will work out the VAT rate. You can then use this in your other spreadsheets, and so changes like this can be updated in one place, and will be picked up by every other sheet you have.

This is probably the kind of thing where it's better to see an example rather that read about it, so if you want to check out how it works, the Resolver Exchange has a file containing a VAT calculator spreadsheet and a spreadsheet that uses it to work out some prices. If you download and unpack it, you can open them up and see how it works. (I've saved them both under a Creative Commons license, so if you don't have Resolver One, you can take a look at them using the free non-commercial version.)

(Oh, and if you're coming from Excel and are wondering where the formulae are in the second sheet, they're column-level -- click on the column headers to see them.)

Here's what I'd really like to know -- is there a way to do this in Excel without having to encode all of the information about VAT rates into some kind of add-in?