I think it depends if there are items which are NOT taxable at one layer but are taxable at the others.
IF all items are taxable at each layer then Richards routine will work for you. But you need the answer to the first question to make that leap. Russ -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brenda Price Sent: Friday, May 18, 2007 12:34 PM To: u2-users@listserver.u2ug.org Subject: RE: [U2] Reverse calculating taxes 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: u2-users@listserver.u2ug.org 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 u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ ------- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/