Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A common tax scenario
Message
From
23/05/2012 15:49:23
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
 
 
To
23/05/2012 15:03:25
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01544104
Message ID:
01544189
Views:
39
>>OK, I didn't realize that.
>>
>>After a little bit of algebra, I get the formula, using same variables as above plus:
>>
>>X = total dollar amount of taxes
>>
>>I = X / ( P + ( P * F ) + F )
>>
>>If you plug in X = 74.88, you get I = 500.03339, which is the problem you saw earlier.
>>
>>If you plug in X = 74.875, you get exactly 500.00, but you have no way of knowing that's the exact value for X.
>>
>>However, you do know the true value of X must be between 74.875 and 74.885 if it was rounded to 74.88. So, plugging in those two values:
>>
>>X = 74.875, I = 500.00
>>X = 74.885, I = 500.06678
>>
>>Any original price I in the range of 500.00 to 500.06 inclusive will give you a tax value, when rounded, of $74.88. The value 500.07 is too high, it results in $74.89 when rounded.
>>
>>So, you cannot determine the exact value, only the range it belongs to. The reason you can't get the exact price value is that the tax amount is only 14.975% of the price, so you have only that percentage of the precision, if both the price and the tax have been rounded to two decimals.
>
>Yes, that seems to be a resume of the explanations I got from Gregory. But, thanks for the additional details
>
>The most important part for us is to extract both taxes from this total amount of taxes. So, that would be exact. I still have more tests to do. But, so far, it seems to be a perfect match. I explained them that it would be impossible to get the exact amount before taxes with just a tax total, if this is in a province dealing with two taxes. To precise all that, they are looking right now at seeing the possibility of having access to another field which would provide the base amount.

UPDATED:

That's correct, if you calculate the range of possible original prices I using the information above, any price in that range yields the same values for the two tax components.

That's correct. If you use the formula above to calculate the original price I, you can use the unrounded value to calculate the two tax components exactly.

There are exceptions for very small values of tax. For a compound tax, the total tax amount X will be rounded down to zero where I is less than:

I = 0.005 / MAX( F, P [, other compound taxes] )

In your case the maximum tax value is provincial tax P of 0.095, so the largest price I that attracts no tax is 0.005 / 0.095 = 0.052632, or 5 cents. Six cents starts to attract provincial tax (but not federal, which is less).

If you use my formula above, a tax value of 1 cent means the price range must be from

Min: T = 0.005, I = 0.03339
Max: T = 0.015, I = 0.10017

This implies the price range is from 4 to 10 cents. In fact, anything less than 6 attracts no tax so the range is actually 6 to 10.

If the total tax value is 2 cents or more, the main calculation works fine. Using any calculated original price, even one based on the exact value of the tax, will yield federal and provincial tax values accurate to the penny. So, you just need some special handling for the case where the total tax value is exactly $0.01.


Even down to a total tax value of $0.01, you can use the formula to get an unrounded price value I, and from that calculate accurate federal and provincial taxes. If you're interested in calculating the range of possible values for original price I, you need special handling at X = $0.01 to recognize that the minimum value that attracts any tax is higher (at $0.06 in your case) that would be calculated by the formula ($0.03339, rounded up to 4 cents).
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform