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 http://www.hmrc.gov.uk/VAT/forms-rates/rates/calculating.htm the correct ways to calculate VAT are as follows: