Finding Tax amount after fixed amount discount off

41 Views Asked by At

percent off

I'm trying write a function that calculates cart totals. I'm crosschecking above calculation which is correct. I have a cart total which is 115.32 dollar. I apply 20 dollar fixed discount off. The sale tax is 9%. What I'm trying to find is to find the tax which is 7.87. Currently what I do is to calculate 9% of 95.32 dollar as the tax and subtract it to find subtotal - which is wrong. I need the correct formula that finds the values in the above picture. What I know is the cart total which is 115.32 dollars, I know the fixed discount amount which is 20 dollar, I know the sales tax which is 9%. By using these I have to find the subtotal ot tax amount. Any help appreciated. Thank you.