Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate the original value given a percentage inclusive value?

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 .15 but this number can be changed, so I need to formulas to not rely on this value being a specifc value!

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 :/).

So, if the key contains inclusive it means that the prices are stored containing the gst content as well.

if the key contains exclusive, well. you get the idea.

Anyway.

I am having a wee bit of an issue wrapping my head around the formulas to get the tax inclusive and exclusive prices.

Let's use these variables.

$tax_type = 'exclusive'
$product_price = 150
$tax_amount = 0.15

If a product has it's price stored tax exclusive thats easy.

Exclusive price = $product_price = 150
Inclusive price = $product_price + ($product_price*$tax_amount) = 150 + (150*0.15)

But if a product has it's price stored tax inclusive that's where I get confused.

So, the variables now become

$tax_type = 'inclusive'
$product_price = 172.5
$tax_amount = 0.15

The tax inclusive price is now $product_price. But how do I calculate the tax exclusive price?

On the IRD website, it states you can use $product_price - ($product_price*3/23) but I imagine that is only for tax at 15%?

like image 397
Hailwood Avatar asked Apr 03 '13 00:04

Hailwood


2 Answers

The formula is straight forward:

Inclusive = Exclusive * (1 + tax rate)

Where the tax rate is some decimal such as the 0.15 you posted. Via algebra then, the exclusive price would be:

Exclusive = Inclusive / (1 + tax rate)

like image 73
Chris Hayes Avatar answered Sep 24 '22 19:09

Chris Hayes


I know its an old question, but some how it may useful for others.

Suppose the item price is 20.00 (inclusive of tax)

Tax rate is 14.5

we need to calculate exclusive price the formula is as follows.

tax excluded price  = item price / ((tax rate /100) + 1 )

eg: 20 / ((14.5/100) + 1)) = 17.4672489.

The detailed documentation can be found here for calculating tax inclusive and exclusive in billing applications

hope it helps others.

like image 39
Jobin Avatar answered Sep 23 '22 19:09

Jobin