Commerce over taxes orders when a discount is applied. The sales tax is calculated on the undercounted prices of the order. This issue is easily reporducable:

1. Install Commerce Kickstart 2.12 with default install options + example tax rate option "US - Sales taxes displayed in checkout".
2. Add a discount (admin/commerce/store/discounts/add). I used options, Order discount - % off = 0.10.
3. Add a product to your shopping cart.
4. Checkout and enter Michigan (MI) as address because there is already a Michigan sales tax setup.

BUG: The site calculates sales tax based on the full price of the product and does not take into account the discount, i.e.
Coffee Mug 1 $8.00

Subtotal $8.00
Sample Michigan Sales Tax 6% $0.48
10% discount -$0.80
Express shipping: 1 business day $15.00
Order total $22.68

The sales tax should be 0.06 * (8.00 - 0.80) = $0.432

I have seen many other discussions of this issue with some people reporting that changing the weight of the rules for discount/taxes fixes it.

https://drupal.org/node/1403498

Rules weights DO NOT fix the issue, at least not in this version of Kickstart it seems because the rules react on different events. The discount is triggered by "Apply a discount to a given order" event. The tax is triggered by "Calculating the sell price of a product" event.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz’s picture

Project: Commerce Kickstart » Commerce Discount
Version: 7.x-2.12 » 7.x-1.x-dev

Moving to Commerce Discount, Jonathan might find the report useful.
Tax support in Commerce in general is every uneven.

jkuma’s picture

Assigned: Unassigned » jkuma
Status: Active » Patch (to be ported)

Thank you bojan to have moved the issue to the right place.

Hello happyloman, first thank you for your well explained issue, we are spent quality time working on a patch to solve this long time issue. The patch is located here. May you check this patch and tell me if it solves your issue ?

Best, jo

discipolo’s picture

Order and product discounts seem to behave differently in respect to what they react to

AdamGerthel’s picture

geek-merlin’s picture

See #2276227: [META] Use order discount with VAT and child issues for a potential fix.

joelpittet’s picture

Assigned: jkuma » Unassigned
Status: Patch (to be ported) » Active

Been thinking about this some...

Here are my assumptions:

  1. Taxes need to come after discounts (always, is there any case where this is not true?)
  2. Calculating line item sale price is where taxes get applied. (not order level)
  3. There are no discount line items or discounted line items that shouldn't have applicable taxes applied.

Proposal:

  1. After applying a discount components to existing line items, check if it has a tax component, remove taxes and re-apply taxes.
  2. Apply taxes to discount line items on creation.

Alternatively, get commerce 1.x to have an order level event, and have it move the tax apply to that instead of sell price calculation.

stephenevans’s picture

tried #66-#68 here: https://www.drupal.org/node/1612662#comment-10154372
Worked very well (for USA taxes)

mglaman’s picture

Issue tags: -tax discount +commerce-sprint
Parent issue: » #2575505: Plan for Commerce Discount 7.x-1.0 release

Tagging for Commerce Sprint, and focus on tax items for 1.0 release

Scott Robertson’s picture

Status: Active » Closed (duplicate)
Related issues: +#2429595: Order discounts are not taken into account during tax calculation

Seems like the most recent discussion on this topic is happening in #2429595: Order discounts are not taken into account during tax calculation; going to mark as a duplicate.

tewdin’s picture

I wrote temporary fix for this. This is not a patch.

<?php
$q = explode('/', $_GET['q']);
$order = commerce_order_load($q[1]);
$subtotal = $order->commerce_order_total['und'][0]['data']['components'][0]['price']['amount'];
$subtotal = ($subtotal / 100) * 1.24;
$discount = $order->commerce_order_total['und'][0]['data']['components'][2]['price']['amount'];
$discount = ($discount / 100) * -1;
$total = $subtotal - $discount;
$without_vat = $total / 1.24;
$vat = $total - $without_vat;
?>

You can read more here.