magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

The vat rate is not applied correctly when the selected address is not in the same tax class as the customer's default address

Open nicolaspernot opened this issue 1 year ago • 10 comments

Preconditions and environment

  • Magento version : 2.4.5-p1

Steps to reproduce

  • Create a no-VAT Tax Rate for Belgium

    • BO > Stores > Tax Zones and Rates
      • Add new Tax Rate :
        • Tax Identifier : Exo TVA UE BE
        • Zip/Post is Range : not checked
        • Zip/Post Code : *
        • State : *
        • Country : Belgium
        • Rate Percent : 0.0000
        • Save Rate
  • Create a VAT Tax Rate for France and Belgium

    • BO > Stores > Tax Zones and Rates
      • Add new Tax Rate :
        • Tax Identifier : TVA France
        • Zip/Post is Range : not checked
        • Zip/Post Code : *
        • State : *
        • Country : France
        • Rate Percent : 20.0000
        • Save Rate
    • BO > Stores > Tax Zones and Rates
      • Add new Tax Rate :
        • Tax Identifier : TVA UE BE
        • Zip/Post is Range : not checked
        • Zip/Post Code : *
        • State : *
        • Country : Belgium
        • Rate Percent : 21.0000
        • Save Rate
  • Create a Tax Rule for no VAT :

    • BO > Stores > Tax Rules
      • Add new Tax Rule :
        • Name : Exo TVA
        • Tax Rate : Exo TVA UE BE
        • In additional Settings :
          • Customer Tax Class :
            • Add New Tax Class : Customer_UE_PRO
            • Select only Customer_UE_PRO, unselect other
        • Save Rule
  • Create a Tax Rule for VAT :

    • BO > Stores > Tax Rules
      • Add new Tax Rule :
        • Name : TVA
        • Tax Rate : TVA France, TVA UE BE
        • In additional Settings :
          • Customer Tax Class :
            • Add New Tax Class : Customer_TVA
            • Select only Customer_TVA
        • Save Rule
  • Create a Customer Group for no VAT Customers

    • BO > Customers > Customer Groups
      • Add New Customer Group
        • Group Name : EU_PRO
        • Tax Class : Customer_UE_PRO
        • Save Customer Group
  • Change Tax Class for General Group :

    • BO > Customers > Customer Groups
      • Edit "General" group
      • Change Tax Class : Customer_TVA
        • Save Customer Group
  • Configure to automatically change group based on VAT and shipping address

    • BO > Stores > Configuration > Customers > Customer Configuration > Create New Account Options :
      • Enable Automatic Assignment to Customer Group : Yes
      • Tax Calculation Based On : Shipping Address
      • Default Group : General
      • Group for Valid VAT ID - Domestic : General
      • Group for Valid VAT ID - Intra-Union : EU_PRO
      • Group for Invalid VAT ID : General
      • Validation Error Group : General
      • Validate on Each Transaction : Yes
      • Default Value for Disable Automatic Group Changes Based on VAT ID : No
      • Show VAT Number on Storefront : Yes
      • Save Config
  • Configure Store infos :

    • BO > Stores > Configuration > General > General > Store Information
    • Country : France
    • Region/State : Haute-Garonne
    • VAT Number : FR41487768616
    • Save Config
  • Set Tax configuration :

    • BO > Stores > Configuration > Sales > Tax > Tax Classes :
      • Tax Class for Shipping : Taxable Goods
      • Default Tax Class for Product : Taxable Goods
      • Default Tax Class for Customer : Customer TVA
    • BO > Stores > Configuration > Sales > Tax > Price Display Settings :
      • Display Product Prices In Catalog : Including and Excluding Tax
      • Display Shipping Prices : Including and Excluding Tax
      • Save Config
  • Create a new Product with perfect price for our tests :

    • BO > Catalog > Products
      • Add Product
        • Product Name : TVA Test
        • SKU : TVA Test
        • Price : 100
        • Tax Class : Taxable Goods
        • Quantity : 9999
        • Stock Status : In Stock
        • Visibility : Catalog, Search
        • Categories :
          • Click on New Cateogry
          • Category Name : Test
          • Parent Category : Default Category
        • Save
  • Create a new Customer :

    • FO > Create an account

    • Add a French Address :

      • FO > My Account > Address Book
      • This is the first address so the new address form is automatically displayed, fill it :
        • First Name : Nicolas
        • Last Name : Pernot FR
        • Phone Number : 0123456789
        • Street Address : 13 rue du Moulin
        • Vat Number : Nothing here, leave it empty
        • Country : France
        • State/Province : Haute-Garonne
        • City : Toulouse
        • Zip/Postal Code : 31000
        • Save Address
    • Add a Belgium Address :

      • FO > My Account > Address Book
      • Add new Address
        • First Name : Nicolas
        • Last Name : Pernot BE
        • Phone Number : 0123456789
        • Street Address : 13 rue du Moulin
        • Vat Number : BE0834968971 (or another valid VAT number)
        • Country : Belgium
        • State/Province : Brussels-Capital Region
        • City : Bruxelles
        • Zip/Postal Code : 1000
        • Don't check Use as my default billing address
        • Don't check Use as my shipping address
        • Save Address
  • Go on product page :

    • FO > Test (category in menu) > TVA Test
    • You should see the price :
      • Including Tax : 120$
      • Excluding Tax : 100$
      • These prices are totaly OK since it is applied a 20% TVA rate.
  • Add product to cart

  • Go on Cart Page

    • Here too, prices are correct because we are still under default address TVA rate ($100 of products + $5 of Flat Rate x 1.20 of French VAT = $126)
  • Click on proceed to checkout

    • Here we see that the Shipping Method selected (Flat Rate) is $5 (excl. tax), so $5 * 1.20 of French VAT = $6. We are OK.
  • Here we want to change the adress, so we choose the Belgium address, which should be VAT exempted.

    • When chosen, Flat Rate charges are updated and there is no more anything about VAT, which is good too. Let's continue.
  • Click on next

    • Order total is now $105 ($100 of products + $5 of Flat Rate, without VAT). Which is great !
  • Place Order. We are all good for this first Test

  • Now change default address to Belgium :

    • FO > My Account > Address Book
    • Edit Belgium address
      • Check Use as my default billing address
      • Check Use as my shipping address
      • Save Address
  • Add same product to cart again.

  • Go back to the cart.

    • Here everything is VAT-exempted which is absolutely right since its Belgium defaut address tax rate which applied : so no VAT.
  • Click on proceed to checkout.

    • Shipping methods is displayed without VAT too. That's great !
  • Here, select the French address

    • Shipping Method charges are updated with VAT. So cool !
  • Click on next.

    • And now the problem : the order summary display prices without VAT and the customer will be charge without VAT even if we selected the French address subject to VAT. Big Problem.
  • Place order. If you goes in BO to check the order, the Tax amount = $0 and Tax rate 0%. The Total due is $105.

Expected result

If the customer's default address is VAT-exempt, but he chooses to be billed and/or delivered to another address that is subject to VAT, VAT should be applied to the delivery charges and to the cart.

Note : the choice to apply or not the VAT should be based on the address type selected in BO configuration here : BO > Stores > Configuration > Customers > Customer Configuration > Tax Calculation Based On

Actual result

The VAT is not applied in the example below :

  • A Belgium address with valid VAT number is VAT-exempted.
  • A French address is always subject to VAT.
  • But if a customer has the Belgium address as default address, VAT will not be applied to his cart or delivery charges even if he choose the French address.

Additional information

I originally met this issue on 2.4.5-p1 but I test the procedure with 2.4-develop instance gave by magento-deployement service and I was able to reproduce.

Release note

No response

Triage and priority

  • [X] 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”.

nicolaspernot avatar Nov 29 '23 00:11 nicolaspernot

Hi @nicolaspernot. Thank you for your report. To speed up processing of this issue, 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:


Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: 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.

m2-assistant[bot] avatar Nov 29 '23 00:11 m2-assistant[bot]

@magento give me 2.4-develop instance

nicolaspernot avatar Nov 29 '23 00:11 nicolaspernot

Hi @nicolaspernot. Thank you for your request. I'm working on Magento instance for you.

Hi @nicolaspernot, here is your Magento Instance: https://72a0cbb64654ec3bc7524fabc98b0935.instances-prod.magento-community.engineering Admin access: https://72a0cbb64654ec3bc7524fabc98b0935.instances-prod.magento-community.engineering/admin_ed2f Login: e0566037 Password: d0d2359f0502

Ok, I did some test on the Magento instance gave by the bot and I updated the original description of this issue to be more accurate. Let me know if something still remains unclear.

nicolaspernot avatar Nov 29 '23 02:11 nicolaspernot

Hi @engcom-Dash. 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: :point_down:

    1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    1. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    1. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    1. 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!

m2-assistant[bot] avatar Nov 29 '23 05:11 m2-assistant[bot]

Hi @nicolaspernot Thanks for reporting and collaboration. Verified the issue on mangento 2.4 developer instance and the issue is reproducible. When the customer has VAT exempted Belgium address as default address but chooses france address which is VAT subjected , VAT rate is not getting applied to the order. Please refer the screenshots.

VAT

engcom-Dash avatar Nov 29 '23 12:11 engcom-Dash

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-10623 is successfully created for this GitHub issue.

github-jira-sync-bot avatar Nov 29 '23 12:11 github-jira-sync-bot

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

m2-assistant[bot] avatar Nov 29 '23 12:11 m2-assistant[bot]

@nicolaspernot: we discovered a very similar sounding problem. Does the patch mentioned in this last comment fix your issue? We had success with this fix so far.

Also, in my opinion you should use these config settings for EU sales:

  • Customers > Customer Configuration > Create New Account Options > Tax Calculation Based On => Billing Address
  • Sales > Tax > Calculation Settings > Tax Calculation Based On => Shipping Address

Reason being:

  • To assign a customer to the correct group, his billing address should be used to determine if this is a B2C or B2B sale (has to pay tax or has not to pay tax based on vat number & country of billing address)
  • To calculate the correct tax amount, the shipping address should be used (if tax has to be paid, at which tax rate)

hostep avatar Jan 03 '24 13:01 hostep