| Project: | Drupal Commerce |
| Version: | 7.x-1.3 |
| Component: | Tax |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
Hi,
we're are using the commerce tax module for calculating the VAT tax. The tax rate is configured with 0.16666666667 and it works fine if people completely go through the checkout process.
Nevertheless we found a few orders on our system where the tax was just wrong. For those the admin has changed the price for whatever reason.
When debugging the system, we found out that there are two different processes in the tax module and different formulas are used.
First, if it's a normal checkout, the function commerce_tax_rate_calculate() will be invoked, where the tax is calculated with:
$amount = $line_item_wrapper->commerce_unit_price->amount->value() * $tax_rate['rate'];which works if you use 0.16 for the VAT.
If the price of an line item is changed afterwards, commerce_tax_commerce_line_item_rebase_unit_price() is invoked, using:
$tax_amount = $price['data']['components'][0]['price']['amount'] - $price['data']['components'][0]['price']['amount'] / (1 + $tax_rate['rate']);which is of course different to the one above (you would have to use 0.2 for the VAT).
The tax system is quite complex, in the meanwhile we just changed the last formula to $tax_amount = $price['data']['components'][0]['price']['amount'] * $tax_rate['rate'];, but I can't tell if that applies for all kind of taxes.
Comments
#1
Attached the patch that I'm currently using. Maybe it's better to fix the formula in commerce_tax_rate_calculate(), but actually I have no idea how it is intended to be.
#2
The last submitted patch, 1784468-commerce_tax_vat_manual_edit_fix-1.patch, failed testing.