|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
formula for calculating sales tax (GST)Not sure if this is the right forum, but I need the formula for calculating the amount of Sales tax (GST) from the tax included price In Australia GST is 10% and the standard formula is to divide the total by 11 to get the gst amount This is great until the GST % changes one day So I need a formula to calculate the amount of GST using the gst% as an input I am using VB.net 2005 Any ideas Regards Steve Hi Steve
I'm assuming you meant "Divide by 1.1" and not "divide by 11" as that would appear to make no sense. If that's the case then something along the following will do the job: GST = TotalPrice/(1+(GSTPercentage/100)) Hope that helps Martin steve wrote: Show quoteHide quote > Hi All > > Not sure if this is the right forum, but I need the formula for calculating > the amount of Sales tax (GST) from the tax included price > > In Australia GST is 10% and the standard formula is to divide the total by > 11 to get the gst amount > > This is great until the GST % changes one day > > So I need a formula to calculate the amount of GST using the gst% as an > input > > I am using VB.net 2005 > > Any ideas > > > Regards > Steve Pritcham wrote:
Show quoteHide quote > Hi Steve Something has gone screwy here!> > I'm assuming you meant "Divide by 1.1" and not "divide by 11" as that > would appear to make no sense. > > If that's the case then something along the following will do the job: > GST = TotalPrice/(1+(GSTPercentage/100)) > > Hope that helps > Martin > > steve wrote: >> Hi All >> >> Not sure if this is the right forum, but I need the formula for calculating >> the amount of Sales tax (GST) from the tax included price >> >> In Australia GST is 10% and the standard formula is to divide the total by >> 11 to get the gst amount >> >> This is great until the GST % changes one day >> >> So I need a formula to calculate the amount of GST using the gst% as an >> input >> >> I am using VB.net 2005 >> >> Any ideas >> >> >> Regards >> Steve > Guys, 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 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 Show quoteHide quote "Alex Turmer" <atur***@project-network.com> schreef in bericht news:e19eyCPzGHA.2636@TK2MSFTNGP06.phx.gbl... > Pritcham wrote: >> Hi Steve >> >> I'm assuming you meant "Divide by 1.1" and not "divide by 11" as that >> would appear to make no sense. >> >> If that's the case then something along the following will do the job: >> GST = TotalPrice/(1+(GSTPercentage/100)) >> >> Hope that helps >> Martin >> >> steve wrote: >>> Hi All >>> >>> Not sure if this is the right forum, but I need the formula for >>> calculating >>> the amount of Sales tax (GST) from the tax included price >>> >>> In Australia GST is 10% and the standard formula is to divide the total >>> by >>> 11 to get the gst amount >>> >>> This is great until the GST % changes one day >>> >>> So I need a formula to calculate the amount of GST using the gst% as an >>> input >>> >>> I am using VB.net 2005 >>> >>> Any ideas >>> >>> >>> 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 Hi AJ
Thanks for the reply Just what I wanted Regards Steve Show quoteHide quote "Alex Turmer" <atur***@project-network.com> wrote in message news:e19eyCPzGHA.2636@TK2MSFTNGP06.phx.gbl... > Pritcham wrote: >> Hi Steve >> >> I'm assuming you meant "Divide by 1.1" and not "divide by 11" as that >> would appear to make no sense. >> >> If that's the case then something along the following will do the job: >> GST = TotalPrice/(1+(GSTPercentage/100)) >> >> Hope that helps >> Martin >> >> steve wrote: >>> Hi All >>> >>> Not sure if this is the right forum, but I need the formula for >>> calculating >>> the amount of Sales tax (GST) from the tax included price >>> >>> In Australia GST is 10% and the standard formula is to divide the total >>> by >>> 11 to get the gst amount >>> >>> This is great until the GST % changes one day >>> >>> So I need a formula to calculate the amount of GST using the gst% as an >>> input >>> >>> I am using VB.net 2005 >>> >>> Any ideas >>> >>> >>> 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 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 Show quoteHide quote > Pritcham wrote: > >> Hi Steve >> >> I'm assuming you meant "Divide by 1.1" and not "divide by 11" as that >> would appear to make no sense. >> >> If that's the case then something along the following will do the >> job: GST = TotalPrice/(1+(GSTPercentage/100)) >> >> Hope that helps >> Martin >> steve wrote: >> >>> Hi All >>> >>> Not sure if this is the right forum, but I need the formula for >>> calculating the amount of Sales tax (GST) from the tax included >>> price >>> >>> In Australia GST is 10% and the standard formula is to divide the >>> total by 11 to get the gst amount >>> >>> This is great until the GST % changes one day >>> >>> So I need a formula to calculate the amount of GST using the gst% as >>> an input >>> >>> I am using VB.net 2005 >>> >>> Any ideas >>> >>> 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 |
|||||||||||||||||||||||