Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x]: Tax removal on order level broken #3386

Open
WHITE-developer opened this issue Feb 21, 2024 · 3 comments
Open

[4.x]: Tax removal on order level broken #3386

WHITE-developer opened this issue Feb 21, 2024 · 3 comments
Assignees
Labels
bug commerce4 Issues related to Commerce v4

Comments

@WHITE-developer
Copy link

What happened?

Description

On an order when you have a valid EU vat-id the tax doesn't get removed on order level because it gets removed by the discount logic.

Steps to reproduce

  1. Tax zone "EU"
  • Country: Belgium
  1. Tax Rates "Eu"
  • Taxable subject: Order total taxable price
  • Tax Zone: EU
  • Disqualify with valid business tax ID?: EU VAT ID checked
  • Rate: 21%
  • Included in price?: checked
  • Adjust price when included rate is disqualified?: false
  • Remove the included tax when a valid EU VAT ID is present?: true
  1. Create an order with Belgium as country and have a valid "Organization Tax ID"

Expected behavior

Negative tax applied on order level

Actual behavior

Tax line just removed https://github.com/craftcms/commerce/blob/develop/src/adjusters/Discount.php#L139

Solution?

  1. Why isn't it a negative "tax" adjustment instead of a "discount"? Makes also the getTotalTax() / getTotalTaxIncluded() and getTotalDiscount() more logical in its values.
  2. Actually all discount adjusters on order level are broken

Craft CMS version

4.7.3

Craft Commerce version

4.4.1.1

PHP version

8.3.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

@WHITE-developer WHITE-developer added commerce4 Issues related to Commerce v4 bug labels Feb 21, 2024
@d--j
Copy link

d--j commented Feb 21, 2024

Related to this: The EU Tax rate handling here

private function organizationTaxId(): bool
{
if (!$this->_address) {
return false;
}
if (!$this->_address->organizationTaxId) {
return false;
}
if (!$this->_address->getCountryCode()) {
return false;
}
$validOrganizationTaxId = Craft::$app->getCache()->exists('commerce:validVatId:' . $this->_address->organizationTaxId);
// If we do not have a valid VAT ID in cache, see if we can get one from the API
if (!$validOrganizationTaxId) {
$validOrganizationTaxId = $this->validateVatNumber($this->_address->organizationTaxId);
}
if ($validOrganizationTaxId) {
Craft::$app->getCache()->set('commerce:validVatId:' . $this->_address->organizationTaxId, '1');
return true;
}
Craft::$app->getCache()->delete('commerce:validVatId:' . $this->_address->organizationTaxId);
return false;
}

is incomplete. You are only allowed to remove the VAT when the customer is in another EU country. E.g. When the shop country is Belgium and the customer country is France and the customer provided a valid EU Vat ID then the VAT can be removed.
When the customer's country is Belgium, too, the VAT cannot be removed.

Anyway, it would also be good to know if Commerce has removed the VAT because then we are required to notify the customer that it is her/his responsibility to pay the VAT with the reverse charge mechanism ( see https://taxation-customs.ec.europa.eu/vat-invoicing-rules_en#:~:text=Customer%20liable%20for%20the%20tax%20(i.e.%20under%20the%20reverse%2Dcharge%20procedure)%20%E2%80%93%20the%20words%20%E2%80%98Reverse%20charge%E2%80%99. )

@lukeholder
Copy link
Member

Thanks for reporting this. Apologies for not responding.

We are looking into deprecating the use of order level and shipping level taxes, due to the complexity it adds to the tax calulation. It also makes sense as we also look to move shipping costs to be a taxable line item cost. Order level taxes should dont make sense since they don't have a tax category, and nearly all jurisdictions have a tax rate per product type anyway. Why do you use order level taxes if the same rate can be applied to all items?

We recommend you cease using order level tax rates if this is causing you issues for your jurisdictions/markets. As of Commerce 3.1, discounts now only apply at an item level so it would also fix any disconnect with discounts you mentioned.

In the meantime since Commerce 5.3 you can also create your own tax ID validator (or extend ours) which would let you conditionally validate the tax ID depending on the context.

@d--j I have also added a discussion item here for your input on options for removing tax:

#3876

This would allow you to set the rate to zero so that the tax adjustment shows up with a zero amount if certain conditions are met.

@WHITE-developer could you please send your current DB backup, composer.json and composer.lock with steps to reproduce your issue (with reference to the Order/Cart number affected) and also reference this issue. We will try to look into if there is a simple fix while still using order level taxes.

@lukeholder lukeholder self-assigned this Feb 2, 2025
Copy link

linear bot commented Feb 3, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4
Projects
None yet
Development

No branches or pull requests

3 participants