title: How to calculate the original value given a percentage inclusive value?
body: <p>We have a shopping cart that is used in different places, therefore the tax is stored in a config file, presently in New Zealand it is 15%, so in the config file we are storing <code>.15</code> but this number can be changed, so I need to formulas to not rely on this value being a specifc value!</p>
  
  <p>We also have another key that stores whether the prices we are storing are tax inclusive or exclusive (users are picky, some want to enter prices with, some without :/).</p>
  
  <p>So, if the key contains <code>inclusive</code> it means that the prices are stored containing the gst content as well.</p>
  
  <p>if the key contains <code>exclusive</code>, well. you get the idea.</p>
  
  <p>Anyway.</p>
  
  <p>I am having a wee bit of an issue wrapping my head around the formulas to get the tax inclusive and exclusive prices.</p>
  
  <p>Let's use these variables.</p>
  
  <pre><code>$tax_type = 'exclusive'
  $product_price = 150
  $tax_amount = 0.15
  </code></pre>
  
  <p>If a product has it's price stored tax exclusive thats easy.</p>
  
  <p>Exclusive price = <code>$product_price</code> = 150<br>
  Inclusive price = <code>$product_price + ($product_price*$tax_amount)</code> = <code>150 + (150*0.15)</code></p>
  
  <p>But if a product has it's price stored tax inclusive that's where I get confused.</p>
  
  <p>So, the variables now become </p>
  
  <pre><code>$tax_type = 'inclusive'
  $product_price = 172.5
  $tax_amount = 0.15
  </code></pre>
  
  <p>The tax inclusive price is now $product_price.
  But how do I calculate the tax exclusive price?</p>
  
  <p>On the IRD website, it states you can use <code>$product_price - ($product_price*3/23)</code> but I imagine that is only for tax at 15%?</p>