Need a formula for calculating the tax portion of a total amount [closed]
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 y开发者_Python百科ears ago.
Improve this questionIn Australia we have to advertise products with tax already added, so rather than say a product is $10 + $1 GST = $11, we normally work backwards and say "ok, total is $10, how much of that is GST ?"
For example, for a $10 total, you do 10 * (1 /11) = 0.91, which is the tax component of the $10 total. My problem is I need calculate a formula for working out the taxable component when the tax rate is a variable. So far I've made this calculation although I'm not sure how correct an assertion it is:
10 * (1 / x) = 0.09 * (1 / y)
where y = 10, x = 11
Basically i want to work out x on the left hand side when I know that the tax rate is 0.05 for example, which will give me a formula that I can use to calculate the taxable component of an total figure. I want a function into which I can plug in the total price and the tax rate, and get back the taxable component of the total price.
I'd really appreciate the help with this as it really makes my head hurt ! :")
You are approaching this the wrong way:
totalPrice = taxablePrice * ( 1 + tax )
taxablePrice = totalPrice / ( 1 + tax )
If your taxrate is say x%, and your total amount is $y.
GST = y - y/(1+x/100)
Of course, if your taxrate is not in percent but is a fraction between 0 and 1, the formula gets
GST = y - y/(1+x)
精彩评论