VAT calculation for Webshop filled with pre-tax prices (internationally accepted): Which is correct and why?
<p>We have a PHP online shop which is filled with pre-tax prices - the customer has the following bill:</p>

<blockquote>
  <p>Beer, VAT 10%, Price 1.99 $, Amount 15 </p>
  
  <p>Bread, VAT 10%, Price 0.73 $, Amount 5 </p>
  
  <p>Wine, VAT 13%, Price 4.77 $, Amount 7 </p>
  
  <p>Glasses, VAT 20%, Price 7.66 $, Amount 5</p>
  
  <p>Voucher, 15 % off</p>
  
  <p>Shipping costs, VAT 20%, Price 5.97 $</p>
</blockquote>

<p><strong>Possibility 1: Calculate the overall before-vat price and deduct it later</strong></p>

<p>a) Calculate overall for different tax rates</p>

<ol>
<li>For 10% VAT: 1.99 * 15 + 0.73 * 5 = 33.50 $</li>
<li>For 13% VAT: 4.77 * 7 = 33.39 $</li>
<li>For 20% VAT: 7.66 * 5 + 5.97 = 44.27 $</li>
</ol>

<p>b) Apply voucher</p>

<ol>
<li>For 10% VAT: 33.50*0.85 = 28.48 $</li>
<li>For 13% VAT: 33.39*0.85 = 28.38 $</li>
<li>For 20% VAT: 44.27*0.85 = 37.63 $</li>
</ol>

<p>c) Deduct VAT: VAT = (pre-tax price / (100 + tax rate) ) * tax rate</p>

<ol>
<li>For 10% VAT: VAT = (28.48 / (100 + 10)) * 10 = 2.59 $</li>
<li>For 13% VAT: VAT = (28.38 / (100 + 13)) * 13 = 3.26 $</li>
<li>For 20% VAT: VAT = (37.63 / (100 + 20)) * 20 = 6.27 $</li>
</ol>

<p>d) </p>

<ul>
<li>Final VAT = 12.12 $</li>
<li>Price after tax = 44.27 + 33.39 + 33.50 - 12.12 = 99.04 $</li>
<li>Price total = 111.16 $</li>
</ul>

<p><strong>Possibility 2: Calculate the price per row, deduct VAT per row</strong></p>

<p>a) Calculate row prices</p>

<ol>
<li>Beer: 1.99 * 15 = 29.85 $</li>
<li>Bread: 0.73 * 5 = 3.65 $</li>
<li>Wine: 4.77 * 7 = 33.39 $</li>
<li>Glasses: 7.66 * 5 = 38.30 $</li>
<li>Shipping costs: 5.97 $</li>
</ol>

<p>b) Apply voucher</p>

<ol>
<li>Beer: 29.85 * 0.85 = 25.37 $</li>
<li>Bread: 3.65 * 0.85 = 3.10 $</li>
<li>Wine: 33.39 * 0.85 = 28.38 $</li>
<li>Glasses: 38.30 * 0.85 = 32.56 $</li>
<li>Shipping costs: 5.97 * 0.85 = 5.07 $</li>
</ol>

<p>c) Deduct VAT:</p>

<ol>
<li>Beer: (25.37 / (100 + 10)) * 10 = 2.31 $</li>
<li>Bread: (3.10 / (100 + 10)) * 10 = 0.28 $</li>
<li>Wine: (28.38 / (100 + 13)) * 13 = 3.26 $</li>
<li>Glasses: (32.56 / (100 + 20)) * 20 = 5.43 $</li>
<li>Shipping costs: (5.07 / (100 + 20)) * 20 = 0.84 $</li>
</ol>

<p>d) </p>

<ul>
<li>Final VAT = 12.12 $</li>
<li>Price after tax = 99.04 $</li>
<li>Price total = 111.16 $</li>
</ul>

<p>Note: Bad example but with bad roundings the VAT could be slightly different.</p>

<p><strong>Possibility 3: Calculate before-vat price per product and sum up later</strong></p>

<p>a) Apply voucher + b) deduct VAT</p>

<ol>
<li>Beer: (1.99 * 0.85 / (100 + 10)) * 10 = 0.15 $</li>
<li>Bread: (0.73 * 0.85 / (100 + 10)) * 10 = 0.06 $</li>
<li>Wine: (4.77 * 0.85 / (100 + 13)) * 13 = 0.47 $</li>
<li>Glasses: (7.66 * 0.85 / (100 + 20)) * 20 = 1.09 $</li>
<li>Shipping costs: (5.97 * 0.85 / (100 + 20)) * 20 = 0.85 $</li>
</ol>

<p>c) Calculate row tax (and usually prices but we dont need em here)</p>

<ol>
<li>Beer: 0.15 * 15 = 2.25 $</li>
<li>Bread: 0.06 * 5 = 0.30 $</li>
<li>Wine: 0.47 * 7 = 3.29 $</li>
<li>Glasses: 1.09 * 5 = 5.45 $</li>
<li>Shipping costs: 0.85 * 1 = 0.85 $</li>
</ol>

<p>d)</p>

<ul>
<li>Final VAT = 12.14 $</li>
<li>Price after tax = 99.02 $</li>
<li>Price total = 111.16 $</li>
</ul>

<p>As you can see there is a little difference in the final VAT in example 3.</p>

<p>My question is: Which kind of calculation is correct? Which is incorrect and why? Which is the correct order of actions to calculate the VAT inside the checkout of an online shop (there are still different orders possible which I did not list in the example)?</p>

<p>This is especially important to know as I have a shop with B2B customers which see the prices excluding VAT.</p>