Zen Cart custom software development, Zen Cart modules, Zen Cart Expert eCommerce Websites with Zen Cart!

Zen Cart Sales Tax for Quantity Discounts

I have separated this page out from the Quantity Discounts FAQ page for convenience and ease of reference.
This page only deals with sales tax issues.
Relevance: Zen Cart™ 1.3.0 - 1.3.9, 1.5.x
Cost: Free, but donation appreciated
This information will be of interest to shop owners who stock both tax free and taxable goods, or owners who wish to know more about sales tax calculations.

Consider the following example: Flat rate shipping for $10. Customer is in FL, FL sales tax is 7%. Two items, each $60. One is taxable, one non-taxable. Step 2 of the checkout screen would show:
     Sub-Total: $120.00
     Flat Rate (Best Way): $10.00
     FL TAX 7.0%: $8.40
     Total: $138.40
7% of $120 is $840, so it's obvious how this works. Now let's add some Quantity Discounting. We'll use the following settings: Discount Basis of Total By Item, Discount by Percentage, setting Level 1 to 1, and Discount 1 to 10 (i.e. 10% off for 1 or more of each type of item). This is an example, not a good discounting model! :)

First, we'll set Re-calculate tax to none, and include tax to false.
      Sub-Total: $120.00
      Flat Rate (Best Way): $10.00
      Quantity Discount: -$12.00
      FL TAX 7.0%: $8.40
      Total: $126.40
The only thing that changes is the introduction of the discount, and it's 10% of the subtotal. What if we switch Re-calculate tax to Standard:
     Sub-Total: $120.00
     Flat Rate (Best Way): $10.00
     Quantity Discount: -$12.00
     FL TAX 7.0%: $7.56
     Total: $125.56
Re-calculate tax Standard means take the subtotal, subtract the discount, and compute the tax on that. So 7% of $120-$12 is $7.56.

Now let's switch to Include Tax = true. This will gross the discount up by the amount that would be paid in tax on the discounted items. Countries that embed their taxes in the sales prices of goods would use this setting.
     Sub-Total: $120.00
     Flat Rate (Best Way): $10.00
     Quantity Discount: -$12.84
     FL TAX 7.0%: $7.50
     Total: $124.66
The base discount is $12 plus 7% of $12 which is $0.84. Since we used Re-calculate tax Standard, we tax 7% of $120-$12.84, which is $7.50.

So this is how it works with a cart full of taxable goods. The following text will only be of interest to shop owners who stock both tax free and taxable goods; it does not apply to shop owners who only sell taxable goods (or only tax free goods). This is unfortunately a lot more complicated.

The most predictable and precise sales tax behavior is provided by setting Re-calculate tax = none with include tax = false. This results in the original sale tax amount being charged, and the discount being exactly the percentage specified in the admin screen.
The other settings are an approximation, since the computations are applied across the board to the categorization you have selected, not item by item. These approximations will be exactly correct if you do not have a mixture of taxable and tax free items in your cart; if you do, they will result in a larger than expected discount and a smaller than expected sales tax amount. This is the same discounting computation that Group Discounts uses, so if you are comfortable with the results from Group Discounts, you will be satisfied with these results.

Again, consider the following example: Flat rate shipping for $10. Customer is in FL, FL sales tax is 7%. Two items, each $60. One is taxable, one non-taxable. Step 2 of the checkout screen would show:
     Sub-Total: $120.00
     Flat Rate (Best Way): $10.00
     FL TAX 7.0%: $4.20
     Total: $134.20
$4.20 is 7% of $60 (the taxable item). Now let's introduce Quantity Discounts. We'll use the same policies as above: Discount Basis of Total By Item, Discount by Percentage, setting Level 1 to 1, and Discount 1 to 10 (i.e. 10% off for 1 or more of each type of item). This is an example, not a good discounting model! :)

If we set include tax = false, re-calculate tax = none, the tax remains at $4.20 as it was in the first example:
     Sub-Total: $120.00
     Flat Rate (Best Way): $10.00
     Quantity Discount: -$12.00
     FL TAX 7.0%: $4.20
     Total: $122.20
Using include tax = false and re-calculate tax=Standard, we get
     Sub-Total: $120 
     Flat Rate (Best Way): $10.00
     Quantity Discount: -$12.00
     FL TAX 7.0%: $3.36
     Total: $121.36
So the $12 discount is 10% of $120 (both items are discountable at 10%), the tax is calculated on 7% of the discounted taxable value ($60-$12), which is $3.36. This is a little lower than it should be (7% of $60 - $6 is really $3.78) because of the across the board subtraction of the discount from the taxable amount. If we then try Include Tax=true, Re-calculate tax = Standard, we get
     Sub-Total: $120.00
     Flat Rate (Best Way): $10.00
     Quantity Discount: -$12.84
     FL TAX 7.0%: $3.30
     Total: $120.46
The Quantity Discount is $12 plus 7% of $12 (discount is grossed up for taxes); the tax is 7% of ($60 - $12.84), or $3.30. So again, the discount is higher than it should be (it should be $12 + 7% of $6, or $12.42), and the tax is lower than it should be (it should be 7% of $60 - $6.42, or $3.75).

So why not compute the tax only on the discounted prices of taxable items so the results are always perfect? Well, you could do that for percentage discounts (although not for dollars off discounts). However,

  1. The results already are perfect if you have only taxable items
  2. The extra complexity of the breaking down the discounting to ensure that only taxable items are taxed would be tremendous, and a great deal of debugging would be required, which might result in a slower, less stable and less reliable module.
  3. Making Quantity Discounts and Group Discounts compute the tax in different ways would lead to a great number of spurious bug reports.
In addition, such a calculation would only be possible for percentage based discounts; currency based discounts would continue to be arbitrarily taxed. As an example, if you specified a $10 discount on 10 items or more, and the customer bought 9 tax free items, how would you reduce the sales tax? It's difficult enough to explain sales tax calculations; I really didn't want the currency based discounts to have a different taxation policy than the percentage based discounts. So we are more or less stuck with the status quo. As I said early on, the most accurate, most easy to understand sales tax policy results from using re-calculate tax = none and include tax = false.

Q: What about a ratio?

A ratio based re-calculation has been discussed before and it may be the best short-term alternative for shops where this poses a serious problem. The ratio would do a calculation like
  $new_tax = $old_tax * ($new_subtotal_after_discount/$old_subtotal_before_discount);


Of course, this ratio would apply globally to all items in the cart. Unfortunately, I haven't had time to implement it in Quantity Discounts or Better Together, but you can see from Dr. Byte's posting in this thread on the forum how to do it.

The problem with a ratio is that it won't work well with exceptions (such as those provided by exclude_category, exclude_product, apply_special_category_discount, or apply_special_product_discount).

The ratio method was used in Group Pricing in Zen Cart 1.3.8, and is acceptably accurate for flat percentage based discounts on the entire cart with no exceptions.