Here is a routine a very smart programmer showed me a long time ago, and
I have used it many times since for all kinds of situations like this:
TOT.TAX is the total you need to divide up
TAX.PCT.ARR is the multi-valued array of various tax percents
TAX.AMT.ARR is the returned multi-valued array of tax amounts for each
tax percent
Code to process and make sure the total of the individual taxes matches
the TOT.TAX. You need to adjust where needed for decimals, etc:
TAX.AMT.ARR = ''
TOT.TAX.PCT = SUM(TAX.PCT.ARR)
MAX = DCOUNT(TAX.PCT.ARR<1>,@VM)
FOR K = 1 TO MAX
TAX.AMT.ARR<1,K> = TOT.TAX * (TAX.PCT.ARR<1,K> / TOT.TAX.PCT)
TOT.TAX -= TAX.AMT.ARR<1,K>
TOT.TAX.PCT -= TAX.PCT.ARR<1,K>
NEXT K
The reason this works is the two lines of subtractions. In the last
iteration, you are multiplying the remaining tax amount by 1.
-----Original Message-----
Any idea's! Does anyone think the current calculation is ok.
Dick Kryka
Director of Applications
Paragon Financial Services
a Division of Money Management International
303-632-2226
[EMAIL PROTECTED]
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/