# Reverse Percentage Calculation of Two Different Taxes after Fixed Amount Off

I own a store and I'm trying to do tax calculations for accounting. I have two products. Product A has retail price of $18.31 including 9% tax. Product B has retail price of 99.68 including 12% tax. Discounts are being applied on item basis. When I try to do fixed amount discount off from the total, I cannot understand how to find the tax amounts for each items. I'm crosschecking it with a system that does what I'm trying to do. Check below: As you see when there is no discount the tax amounts are calculated and I understand that calculation. But when there is fixed 20 dollars discount off from the total I don't understand how two of the taxes (1.26 and 8.87) are calculated. I know they are item based but how they do it from a fixed amount off from the total? I would understand if it was a fixed percentage of from the total but I don't understand how does that system calculates when there is fixed$20 amount off from the total. I need the formula or example on how to do the reverse percentage calculation there. Thank you for any help.

The first thing to do is calculate the pre-tax cost of items. These are $$SP$$ for "Skinny Pop" and $$NH$$ for "Nabisco Honey", rounded to the nearest cent: $$SP = \frac{18.31}{1.09} = 16.80 \\ NH = \frac{99.68}{1.12} = 89.00.$$ Their subtotal, $$ST$$, is given in the first image: $$ST = 105.80.$$ If a fixed discount of $$20$$ is applied to the subtotal, but it is not specified how much of it is applied to each item, then we can try to backsolve for how it is applied. Let us say $$d$$ is the amount of discount applied to $$NH$$, thus $$20-d$$ is the amount applied to $$SP$$. Then while $$ST$$ after discount remains $$105.80 - 20 = 85.80$$, the different taxation rates on $$SP$$ and $$NH$$ mean that the after-tax total varies as a function of $$d$$. The total, after taxes, is $$T = (16.80 - (20-d))(1.09) + (89.00 - d)(1.12) = 96.192 - 0.03d.$$ But because $$0 \le d \le 20$$, it becomes clear that it is impossible to get the claimed total for any kind of apportionment of the discount across the items.
We can see that there is another issue: the subtotal in the discounted version is $$87.86$$, which does not match the value of $$ST$$ after discount. So indeed, something strange is going on in the system.
So let's take another approach. Let's assume the calculations by the system are correct, so $$87.86$$, $$1.26$$, and $$8.87$$ are the relevant subtotals and taxes. Backsolving again, this would suggest that the pre-tax discounted costs $$SP'$$, $$NH'$$, are $$SP' = \frac{1.26}{0.09} = 14.00, \\ NH' = \frac{8.87}{0.12} = 73.92.$$ But then their subtotals would be $$ST' = 87.92$$, which contradicts the stated subtotal $$87.86$$. Rounding error could explain the discrepancy due to division by small percentages, so let's work that angle. If $$SP'$$, $$NH'$$ add up to $$87.86$$, and their total tax is $$10.13$$, then we have the system $$SP' + NH' = 87.86 \\ (0.09)SP' + (0.12)NH' = 10.13,$$ which has the solution $$SP' = 13.77, \quad NH' = 74.09.$$ But again, this is inconsistent with the calculated taxes, since $$(0.09)SP' = 1.24, \quad (0.12)NH' = 8.89.$$ Again, rounding could explain this discrepancy, so we generalize the system to admit rounding values $$\epsilon, \delta \in (-0.005, 0.005)$$, yielding $$(0.09)SP' = 1.2696 - 3 \epsilon + 0.36 \delta, \\ (0.12)NH' = 8.8504 + 4 \epsilon - 0.36 \delta.$$ We want this to be $$1.26 \pm 0.005$$ and $$8.87 \pm 0.005$$. There are many admissible choices, but $$\epsilon \approx 0.00418$$ works for any $$\delta$$, so for example $$SP' = 13.97, \quad NH' = 73.89$$ works. But we still cannot explain how the discount results in these pre-tax costs.