> Hi Steve
>
[quoted text clipped - 26 lines]
>> Regards
>> Steve
Guys,
Something has gone screwy here!
Divide by 11 is correct.
The total = net * (1 + tax%/100)
thus
net=total/(1 + tax%/100)
But - be warned, you simply cannot do sales tax this way. Each country
as strict laws which set the amount of decimal places the calculation
has to be correct to (in the UK is it 7). Then there is another set of
rules has to how to round a fractional result, in the UK that is halve
even if memory serves.
So your steps are this:
1) Make sure everything is in double precision - or use a big decimal class
2) Make sure you know the rounding rules
3) Make the calculation in three steps
Kind of like this - but must be tailored to your local laws
const oneHundred as double = 100.0
const one as double = 1.0
const rounder as double = 7.0
function GetTaxFromGross(taxPercent as double, gross as double)
dim tmpd as double
dim tmpl as long
tmpd=gross/(one + taxPercent/oneHundred )
tmpl=clng(tmpd * (rounder + one))
' Better check this - done from memory!
if tmpl mod 20 > 10 then
if tmpl mod 10 > 5 then
tmpl=tmpl + 10 -(tmpl mod 10)
else
tmpl=tmpl -(tmpl mod 10)
end if
else
if tmpl mod 10 > 5 then
tmpl=tmpl -(tmpl mod 10)
else
tmpl=tmpl + 10 -(tmpl mod 10)
end if
end if
return tmpl/rounder
end function
Please pleas please - note this code is a raw translation of the Java
version I wrote a couple of years ago - it is a guideline only - you
must spin your own!
Best wishes
AJ
www.deployview.com
www.nerds-central.com
www.project-network.com
Cor Ligthert [MVP] - 31 Aug 2006 14:35 GMT
Alex,
Those Britain's are so clever, the Dutch tax rules are more like: Round at
xx and than always in your own benefit.
However probably are the taxes in Britain proud they still have pennies and
no cents, therefore they can still be penny wise and pound foolish.
Please don't see this a serious reply. I could not resist to sent it.
Cor
>> Hi Steve
>>
[quoted text clipped - 89 lines]
> www.nerds-central.com
> www.project-network.com
steve - 31 Aug 2006 21:46 GMT
Hi AJ
Thanks for the reply
Just what I wanted
Regards
Steve
>> Hi Steve
>>
[quoted text clipped - 89 lines]
> www.nerds-central.com
> www.project-network.com
GhostInAK - 31 Aug 2006 22:54 GMT
Hello Alex,
Other tax laws may apply as well. Like In Homer, AK (where I used to live)
there is a 5.5% sales tax.. but you can only be taxed on the first $500.00
of any single invoice. 3 miles down the road (literally) the tax drops to
2.0%, but the same upper limit applies (so you can't hard-code the max tax,
it has to be the max taxable).
I prefer to enter taxes as a decimal instead of a percentage.. so instead
of entering (or passing) 5.5, I would pass .055.
The formula then becomes..
Gross = Net + (Net * TaxDecimal)
Or in the case of Homer:
Gross = Net + ((Math.Min(MaxTaxable, Net) * TaxDecimal) + Math.Max(Net -
MaxTaxable, 0))
Enjoy,
-Boo
>> Hi Steve
>>
[quoted text clipped - 84 lines]
> www.nerds-central.com
> www.project-network.com