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

Cross Border Trade kicks in even when no tax should be calculated #35592

Open
1 of 5 tasks
hostep opened this issue Jun 8, 2022 · 23 comments
Open
1 of 5 tasks

Cross Border Trade kicks in even when no tax should be calculated #35592

hostep opened this issue Jun 8, 2022 · 23 comments
Assignees
Labels
Area: Pricing Component: Tax feature request Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Triage: Need PO Confirmation Requirements should be clarified/approved/confirmed with Product Manager. Not ready for fix/delivery

Comments

@hostep
Copy link
Contributor

hostep commented Jun 8, 2022

Preconditions and environment

  • Magento version 2.3.7, 2.4.4, 2.4-develop, probably any Magento version that was ever released contains this bug
  • A good knowledge of the European tax system, including the cross border trade option that exists in Magento
  • Maybe pull in a product owner if you are in doubt about the validity of this ticket

Steps to reproduce

  1. Install a clean Magento
  2. After bin/magento setup:install ... was executed, further configure your instance like this:
bin/magento config:set   currency/options/allow                       EUR
bin/magento config:set   currency/options/base                        EUR
bin/magento config:set   currency/options/default                     EUR
bin/magento config:set   general/country/default                      BE
bin/magento config:set   general/locale/timezone                      Europe/Brussels
bin/magento config:set   general/single_store_mode/enabled            0
bin/magento config:set   shipping/origin/country_id                   BE
bin/magento config:set   shipping/origin/postcode                     9000
bin/magento config:set   shipping/origin/region_id                    628
bin/magento config:set   tax/calculation/cross_border_trade_enabled   1
bin/magento config:set   tax/calculation/discount_tax                 1
bin/magento config:set   tax/calculation/price_includes_tax           1
bin/magento config:set   tax/calculation/shipping_includes_tax        1
bin/magento config:set   tax/cart_display/full_summary                1
bin/magento config:set   tax/cart_display/grandtotal                  1
bin/magento config:set   tax/cart_display/price                       2
bin/magento config:set   tax/cart_display/shipping                    2
bin/magento config:set   tax/cart_display/subtotal                    2
bin/magento config:set   tax/cart_display/zero_tax                    1
bin/magento config:set   tax/classes/shipping_tax_class               2
bin/magento config:set   tax/defaults/country                         BE
bin/magento config:set   tax/display/shipping                         2
bin/magento config:set   tax/display/type                             2
bin/magento config:set   tax/notification/ignore_apply_discount       0
bin/magento config:set   tax/notification/ignore_discount             0
bin/magento config:set   tax/notification/ignore_price_display        0
bin/magento config:set   tax/sales_display/full_summary               1
bin/magento config:set   tax/sales_display/grandtotal                 1
bin/magento config:set   tax/sales_display/price                      2
bin/magento config:set   tax/sales_display/shipping                   2
bin/magento config:set   tax/sales_display/subtotal                   2
bin/magento config:set   tax/sales_display/zero_tax                   1
  1. Setup these tax rates
    tax-rates

  2. Setup this one tax rule - while setting it up, make sure to also create the Customer Tax Class 'Other Customer', but don't check it in this tax rule
    tax-rule

  3. Create a customer group 'Other Customer' and associate it with the 'Other Customer' Tax Class that you setup in the previous step

  4. In the backoffice, create these 2 customers with these addresses as default shipping & billing address:

Name Customer Group Country City Postal code Street
With Tax General Luxembourg City 1234 Street
Without Tax Other Customer Luxembourg City 1234 Street
  1. In the backoffice, create a category
  2. And also create a simple product to associate with the category and with these details:
Price Tax Class Quantity Stock Status
100 EUR Taxable Goods 9999 In Stock
  1. Use 2 different browsers to visit the frontend, login with the first customer in your first browser and with the second customer in your second browser (the customers you created in step 6)
  2. In both browsers, put the newly created product in your cart and navigate to the shopping cart page

Expected result

Following totals should be displayed:

Customer Subtotal Shipping Tax Order Incl Tax Order Excl Tax
With Tax 100 5 15.26 105 89.74
Without Tax 85.47 4.27 0 89.74 89.74

Actual result

Following totals are being displayed:

Customer Subtotal Shipping Tax Order Incl Tax Order Excl Tax
With Tax 100 5 15.26 105 89.74
Without Tax 100 5 0 105 105

Additional information

So the cross border trade option in Magento is used to show prices inclusive tax the same across all EU countries even if each EU member state has a different tax rate for a product (well, in Magento it's implemented for ALL countries, instead of only for EU countries, but that's another bug I still need to report => update: probably not really a bug but a config option for this would be nice). It does so by changing the prices excl tax so those are different between the EU member states.

However, when a customer doesn't have to pay taxes - in the case of a B2B order from one EU member state to another member state for example (which I'm simulating here with the different customer groups that are assigned to the 2 customers) - it makes little sense for the cross border trade option to kick in when no taxes should be calculated.

Possible solution that I found so far but it's maybe not accurate:

diff --git a/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php b/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php
index 8cfe3079424..95128d1d741 100644
--- a/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php
+++ b/app/code/Magento/Tax/Model/Calculation/AbstractCalculator.php
@@ -276,7 +276,7 @@ abstract class AbstractCalculator
      */
     protected function isSameRateAsStore($rate, $storeRate)
     {
-        if ((bool)$this->config->crossBorderTradeEnabled($this->storeId)) {
+        if ((bool)$this->config->crossBorderTradeEnabled($this->storeId) && $rate > 0.0) {
             return true;
         } else {
             return (abs($rate - $storeRate) < 0.00001);

The added check on the $rate to be higher than 0, means that the cross border trade option does not kick in when no taxes should be calculated. However, the end result is not correct, as it calculates the price excl tax based on the Belgium rate (21%) instead of the Luxembourg rate (17%). So the end result looks like this with this solution:

Customer Subtotal Shipping Tax Order Incl Tax Order Excl Tax
With Tax 100 5 15.26 105 89.74
Without Tax 82.64 4.13 0 86.77 86.77

Which is in my opinion still not correct.

So to have a full fix, we'll somehow need to calculate 17% tax instead of 21% for prices excl tax in this case when the tax rate is 0.

Update: I'm not longer convinced this is a correct assumption. The outcome with this fix might be correct because in the case when you sell to countries outside of the EU, it also subtracts 21% from the price incl tax. So maybe this is the correct outcome then for B2B sales to other EU member states after all... But I'm not an expert in international trade, so I'm not sure ...

Hope this makes sense, because it's quite complicated 🙂

Release note

When this issue gets fixed, release notes:

Fixes subtotal for orders with zero tax when cross border trade is enabled.

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Jun 8, 2022

Hi @hostep. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented Jul 14, 2022

Hi @engcom-Lima. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Lima
Copy link
Contributor

engcom-Lima commented Jul 18, 2022

@magento give me 2.4-develop instance

1 similar comment
@engcom-Lima
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Lima. Thank you for your request. I'm working on Magento instance for you.

@magento-deployment-service
Copy link

@engcom-Lima
Copy link
Contributor

✔️ Issue confirmed

Issue got reproduced in 2.4-develop branch.

Description: Cross Border Trade kicks in even when no tax should be calculated
Pre-requisite:

  • Install fresh Magento 2.4-develop.
  • Product should be created.

Steps to reproduce:

  1. After installation of magento, run below set of commands:
bin/magento config:set   currency/options/allow                       EUR
bin/magento config:set   currency/options/base                        EUR
bin/magento config:set   currency/options/default                     EUR
bin/magento config:set   general/country/default                      BE
bin/magento config:set   general/locale/timezone                      Europe/Brussels
bin/magento config:set   general/single_store_mode/enabled            0
bin/magento config:set   shipping/origin/country_id                   BE
bin/magento config:set   shipping/origin/postcode                     9000
bin/magento config:set   shipping/origin/region_id                    628
bin/magento config:set   tax/calculation/cross_border_trade_enabled   1
bin/magento config:set   tax/calculation/discount_tax                 1
bin/magento config:set   tax/calculation/price_includes_tax           1
bin/magento config:set   tax/calculation/shipping_includes_tax        1
bin/magento config:set   tax/cart_display/full_summary                1
bin/magento config:set   tax/cart_display/grandtotal                  1
bin/magento config:set   tax/cart_display/price                       2
bin/magento config:set   tax/cart_display/shipping                    2
bin/magento config:set   tax/cart_display/subtotal                    2
bin/magento config:set   tax/cart_display/zero_tax                    1
bin/magento config:set   tax/classes/shipping_tax_class               2
bin/magento config:set   tax/defaults/country                         BE
bin/magento config:set   tax/display/shipping                         2
bin/magento config:set   tax/display/type                             2
bin/magento config:set   tax/notification/ignore_apply_discount       0
bin/magento config:set   tax/notification/ignore_discount             0
bin/magento config:set   tax/notification/ignore_price_display        0
bin/magento config:set   tax/sales_display/full_summary               1
bin/magento config:set   tax/sales_display/grandtotal                 1
bin/magento config:set   tax/sales_display/price                      2
bin/magento config:set   tax/sales_display/shipping                   2
bin/magento config:set   tax/sales_display/subtotal                   2
bin/magento config:set   tax/sales_display/zero_tax                   1

  1. Setup tax rates
    image
  2. Setup this one tax rule - while setting it up, make sure to also create the Customer Tax Class 'Other Customer', but don't check it in this tax rule
    image
  3. Create a customer group 'Other Customer' and associate it with the 'Other Customer' Tax Class that you setup in the previous step.
  4. In the backoffice, create these 2 customers with these addresses as default shipping & billing address:
    image

6 In the backoffice, create a category.
7.And also create a simple product to associate with the category and with these details:
image
8. Login and place an order from both the customers.

Expected result:
image

Actual result:
Without Tax-
image
With Tax
image

@engcom-Lima engcom-Lima added Component: Tax Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Pricing Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jul 18, 2022
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-5982 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Jul 18, 2022

✅ Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@hostep
Copy link
Contributor Author

hostep commented Jul 18, 2022

@engcom-Lima: thank you very much for testing!

Could you also try to drag in the product owner of this part of Magento in this discussion and ask their opinion? To make sure this is a valid request?

@engcom-Lima
Copy link
Contributor

Hi @hostep

Thanks for your detailed information provided by you.

In order to involve product owner I will confirm with my internal team members. Then, I will update you further on this.

Thanks!!

@m2-community-project m2-community-project bot removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Jul 19, 2022
@engcom-Hotel
Copy link
Contributor

Hello @hostep,

We are putting this issue on hold to confirm the expected behavior with the PO.

Thanks

@engcom-Hotel engcom-Hotel added the Triage: Need PO Confirmation Requirements should be clarified/approved/confirmed with Product Manager. Not ready for fix/delivery label Jul 19, 2022
@engcom-Lima engcom-Lima self-assigned this Aug 1, 2022
@engcom-Lima
Copy link
Contributor

Mail has been sent to PO for his confirmation on the expected result. After his confirmation on the expected result we will proceed further.

Thanks

@github-jira-sync-bot github-jira-sync-bot added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Sep 30, 2022
@hostep
Copy link
Contributor Author

hostep commented Oct 6, 2022

@engcom-Lima, @engcom-Hotel: this makes no sense, why did the issue got closed? Never even got feedback from the PO so I don't understand why this got closed for no good reason?

Update: I just noticed those PR in progress and done labels, so I'm going to guess this is already fixed internally? Are there already some commits you can link to? Great communication here (again) ... 😛

@sidolov sidolov reopened this Oct 7, 2022
@m2-community-project m2-community-project bot removed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Progress: done Issue: On Hold labels Oct 7, 2022
@hostep
Copy link
Contributor Author

hostep commented Oct 31, 2022

Hey @engcom-Lima: is there already some feedback from the PO about this? And if not, how long is it still going to take? Thanks!

@tprocter-ldg
Copy link

Hello, is there any further update on this issue or the PR that is in progress please?

Also, thank you @hostep for writing this very detailed description of my biggest headache :)

@hostep
Copy link
Contributor Author

hostep commented Apr 12, 2023

@engcom-Lima, @engcom-Hotel: is there already feedback from the PO? You said a mail was send to him/her about 8 months ago, I'm assuming it got forgotten, maybe send a reminder (or even better: let the PO answer in public here, it will be much easier to discuss the options that way) ...

@engcom-Lima
Copy link
Contributor

engcom-Lima commented May 5, 2023

Hi @hostep,

Thanks for your patience.

As per jira PO had provided feedback as "This issue will be consider as Feature Request and Tax expert input would be needed to handle these complex scenarios" .

Thanks

@hostep
Copy link
Contributor Author

hostep commented May 5, 2023

Thanks @engcom-Lima, am I correct in understanding that you guys will try to involve a tax expert? Or am I considered to find a tax expert myself?

@engcom-Lima
Copy link
Contributor

Hi @crmccann ,

Need yours intervention here.

Thanks

@hostep
Copy link
Contributor Author

hostep commented Jul 24, 2023

Hey @crmccann: is there already an update around this? We keep running into clients of ours that run against this issue...

@engcom-Lima
Copy link
Contributor

Hi @hostep,

Thanks for your patience!

The internal team has recommended to leverage dedicated tax module e.g. Avalara, Vertex etc. to cover tax calculations.
Hope this helps.

Thanks

@hostep
Copy link
Contributor Author

hostep commented Aug 11, 2023

@engcom-Lima: I completely disagree. Magento has tax calculation support build in, so why not extend it to support more cases?
There is a PR with a suggestion for a solution, maybe if you disagree that this is a good idea to enable for everybody, we could only enable it with a new configuration flag?

What do you think?

We've been using this PR as a patch on a couple of the shops we maintain for a few months in production and our clients are happy with the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Pricing Component: Tax feature request Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: PR in progress Triage: Need PO Confirmation Requirements should be clarified/approved/confirmed with Product Manager. Not ready for fix/delivery
Projects
Status: Pull Request in Progress
Development

No branches or pull requests

6 participants