This looks to be exactly what we need. Many thanks! Brenda
-----Original Message----- From: Kryka, Richard [mailto:[EMAIL PROTECTED] Sent: Friday, May 18, 2007 10:51 AM To: [email protected] Subject: RE: [U2] Reverse calculating taxes 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. ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/
