The more I think about this the more I question the validity of applying the taxes and discounts like this.
For example, lets say you have a single item in your cart that should be taxed and that items amount is $5. Lets also assume that you have another $40 product that does not have tax applied and the user has a coupon that is giving them $20 off, what value would you apply your tax rate to?
If you applied tax on the $5 this would be the amount before the discount. You could not subtract the discount amount from this $5 so you would need some way to determine the discounted item price for the taxable items. Since the discount is not applied on a per item basis you would not be able to do this without an equation to determine how to get the new discounted price for the taxable items. Tax will be charged based on the items price, either discounted or whole. Taking the discount into consideration with the tax does not fit the scenario you are working with.