Correct VAT calculations in PHP

Posted by Andrew McCombe on Mon Jan 4, 2010

Due to the so called ‘Credit Crunch’ the British government had decided to change the VAT rate for one year between December 2008 and Jan 2010.  Many developers in the UK had made the mistake of hardcoding the VAT rate in their code which caused issues.

After discussions with colleagues it became clear that each developer has different approaches to calculating the VAT on a nett price and deducting VAT from a gross price.

According to the correct ways to calculate VAT are as follows: