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

Cart Price Rules not applying on shipping VAT when rule applied on whole cart #32468

Open
1 of 5 tasks
Romz opened this issue Mar 12, 2021 · 27 comments
Open
1 of 5 tasks
Labels
Area: Tax Component: Tax Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@Romz
Copy link

Romz commented Mar 12, 2021

Preconditions (*)

Magento 2.4.2
2.4-develop having EE and B2B Modules

Steps to reproduce (*)

Using Fresh magento installation with samples datas.

  1. Create a tax rate (20%) applied on both products and shipping.
  2. In Sales > Tax configuration Panel:
    1. Tax Class for Shipping : Taxable Goods
    2. Catalog Prices: Including Tax
    3. Shipping Prices: Including Tax
    4. Apply Discount On Prices: Including Tax
    5. Enable Cross BorderTrade : Yes
  3. Create a new cart rule
    1. Coupon: Specific Coupon
    2. Apply: Fixed amount discount for whole cart
    3. Discount Amount: 56
  4. Add a product in shopping cart (51$)
  5. Go to checkout and use a shipping methods: Flat Rate 5$
  6. Apply the cart rule using the coupon code

Expected result (*)

  1. -56$ dicount applied
  2. 0$ on Order total

Actual result (*)

  1. -55.17$ discount applied
  2. 0.83$ on order total

The discount seems to be only applied on Shipping amount excluding tax. In that case 4.17$.
That's explain the -55.17$ discount amount on shopping cart (51 + 4.17)

For more details about the issue and configuration, please check this link


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • 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 Mar 12, 2021

Hi @Romz. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

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

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

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

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ 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, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ 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 Mar 15, 2021

Hi @engcom-Oscar. 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-Oscar
Copy link

Hi @Romz ! Thank you for your report.

Unfortunately, we are not able to reproduce the issue on a fresh 2.4-develop by following steps from this ticket.

Steps to reproduce (*)

  1. Create a tax rate (20%) applied on both products and shipping.
  2. In Sales > Tax configuration Panel:
    1. Tax Class for Shipping : Taxable Goods
    2. Catalog Prices: Including Tax
    3. Shipping Prices: Including Tax
    4. Apply Discount On Prices: Including Tax
    5. Enable Cross BorderTrade : Yes
  3. Create a new cart rule
    1. Coupon: Specific Coupon
    2. Apply: Fixed amount discount for whole cart
    3. Discount Amount: 56
  4. Add a product in shopping cart (51$)
  5. Go to checkout and use a shipping methods: Flat Rate 5$
  6. Apply the cart rule using the coupon code

Actual Result: ✔️
Order summary before applying coupon:
Screenshot from 2021-03-16 10-37-53
Order summary with discount after applying coupon:
Screenshot from 2021-03-16 10-25-42

Please recheck - may be you missed some details in issue description.

@engcom-Oscar engcom-Oscar added the Issue: needs update Additional information is require, waiting for response label Mar 16, 2021
@Romz
Copy link
Author

Romz commented Mar 17, 2021

I found out that the issue is before the checkout step.

Here the steps to reproduce.

  • Clear all cookies
  • Add product in shopping cart ($22 in my case)
  • Estimate shipping price (it show $10)
  • Apply the coupon

Result:

Subtotal: $22
Dicount: $30.33
Shipping (Flat Rate - Fixed): $10
Tax: $0.28

Order Total: 1.67

The when I do the checkout process and set my address, the problem gone.

@Romz
Copy link
Author

Romz commented Mar 24, 2021

Hi @engcom-Oscar engcom-Oscar

I tried to use my $100 coupon on $102 subtotal + $15 shipping and I have an odd result. Discount applied: $101.58 which is more than the amount on my coupon rule.

@engcom-Oscar engcom-Oscar removed their assignment May 31, 2021
@engcom-Oscar engcom-Oscar removed the Issue: needs update Additional information is require, waiting for response label May 31, 2021
@engcom-Echo engcom-Echo self-assigned this May 31, 2021
@m2-assistant
Copy link

m2-assistant bot commented May 31, 2021

Hi @engcom-Echo. 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-Echo engcom-Echo added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label May 31, 2021
@engcom-Echo
Copy link
Contributor

Hi Romz ,

The issue is not getting re-produced as per the steps provided . Requested you to kindly test the issue on latest version i.e. 2.4-develop, or provide further clarification to help us reproduce the issue.

Thanks

@engcom-Echo engcom-Echo added the Issue: needs update Additional information is require, waiting for response label May 31, 2021
@m2-community-project m2-community-project bot removed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: ready for confirmation labels May 31, 2021
@4ctobias
Copy link
Contributor

4ctobias commented Jun 2, 2021

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@4ctobias
Copy link
Contributor

4ctobias commented Jun 2, 2021

@magento give me 2.4.2-p1 instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@4ctobias
Copy link
Contributor

4ctobias commented Jun 2, 2021

Hi,

I am fully able to reproduce this with the upcoming 2.4-develop as well. It depends on the following settings (its a typical European set up - as we have to provide gross prices for products, services and shipping for customers B2C):

  • Shop-Configuration, Tax, Tax Classes => Tax Class for Shipping set to "Taxable Goods"
  • Shop-Configuration, Tax, Tax Classes => Set "Catalog Prices","Shipping Prices", "Apply Discount on Prices" to "Including Tax"
  • Shop-Configuration, Tax, Tax Classes => Set "Apply Customer Tax" to "Before Discount"
  • Shop-Configuration, Tax, Tax Classes => Set Enable Cross Border Trade to "Yes"
  • Add Tax Zone/Rate for Germany with 19 % (all ZIP Codes)
  • Add this Tax Zone to the current Tax rule
  • Add a Cart Price Rule with no conditions, with a coupon code and a fixed amount for the whole cart for the value of 50, and apply this coupon to Shipping Amount
  • Change the Flat rate shipping rate from "Per Item" to "Per Order"

Now I added a product for 28$ and go to the cart page ("Edit and review cart")

  • When the coupon is not applied we have a subtotal of 23,53 $, the shipping of 4.20 $ is applied, the order total is 33, tax: 5,27)
  • If I apply my coupon (limited to 50 $) I get the error: Subtotal is still 23.53 $, the discount amount is -32,20 $, the shipping flat rate is 4.20 $, the tax is still 5.27 $, the order total is 0.80 $

I expect a order total value of 0.00 $.

As I have a Tax rate of 19 % the 0.80 order total is exactly the tax of the shipping rate (5 $ gross, 4.20 net).

If I apply this 50 $ coupon to a cart with a value more than 50 $ all works fine and is correct - so it seems that the tax of the shipping is not used correctly when using a fixed coupon if the cart value is less than this maximum discount value.

Best,

Tobias

@4ctobias
Copy link
Contributor

4ctobias commented Jun 4, 2021

For a quick/hot fix I have overriden the Magento\SalesRule\Model\Validator (with a preference-for in a di.xml). Within the processShippingAmount() I changed the processing within the \Magento\SalesRule\Model\Rule::CART_FIXED_ACTION-handling in the switch. I changed from

if ($cartRules[$rule->getId()] > 0) {
    $shippingAmount = $address->getShippingAmount() - $address->getShippingDiscountAmount();
...

to

if ($cartRules[$rule->getId()] > 0) {
    // Fix: Manual fix to respect shipping VAT if the possible fixed coupon value is > subtotal + shipping
    if ($rule->getDiscountAmount() + $shippingAmount-$address->getShippingAmount() < $address->getSubtotalInclTax() + $shippingAmount) {
        $shippingAmount = $address->getShippingAmount() - $address->getShippingDiscountAmount();
    }
...

Its not a clean solution:

  • Doing a preference for replacement for a Magento-Base-class is bad
  • The code above does not check if the shipping has an assigned tax class in the current store view - it just assumes that this is fact
  • Same applies to the fact that the code assumes that all prices are incl. tax.
  • The better solution would be to fix the $shippingAmount-assignment directly instead if checking the rules discount amount plus the shipping tax versus the subtotal incl. tax and the shipping amount

But as a short and quick solution (until the issue is solved by itself) this will work.

@engcom-Echo engcom-Echo added Issue: ready for confirmation and removed Issue: needs update Additional information is require, waiting for response labels Jun 4, 2021
@engcom-November engcom-November self-assigned this Jul 6, 2021
@engcom-November engcom-November added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch labels Jul 15, 2021
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-November
Thank you for verifying the issue. Based on the provided information internal tickets MC-42852 were created

Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@sdzhepa sdzhepa added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Aug 12, 2021
@Thundar
Copy link
Contributor

Thundar commented Oct 15, 2021

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

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

@magento-deployment-service
Copy link

@ABC-Chefkoch
Copy link

Hello,

facing same problem on 2.4.4 on catalog inc taxes (same configuration as start topic)
Discount code configuration (50€ fixed values for whole cart with "Apply to Shipping Amount")

Warenkorb

please provide fix or any hints for fixing

@timbaltissen
Copy link

Exact same issue in 2.4.3-p2, please provide the fix. Thanks a lot.

@anvanza
Copy link

anvanza commented May 25, 2023

@timbaltissen @4ctobias ,

Have you found a solution for 2.4.5?

Copy link

m2-assistant bot commented Feb 28, 2025

Hi @engcom-Delta. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

    1. Add/Edit 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- 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!
    1. If the issue is not relevant or is not reproducible any more, feel free to close it.

@engcom-Delta
Copy link
Contributor

Hi @Romz ,

Thanks for your reporting and collaboration.
We have verified the issue in latest 2.4-develop instance and the issue is reproducible.
Kindly refer the screenshots.

Steps to reproduce :

  1. Create a tax rate (20%) applied on both products and shipping.
  2. In Sales > Tax configuration Panel:
    Tax Class for Shipping : Taxable Goods
    Catalog Prices: Including Tax
    Shipping Prices: Including Tax
    Apply Discount On Prices: Including Tax
    Enable Cross BorderTrade : Yes
  3. Create a new cart rule
    Coupon: Specific Coupon
    Apply: Fixed amount discount for whole cart
    Discount Amount: 56
    Add a product in shopping cart (51$)
  4. Go to checkout and use a shipping methods: Flat Rate 5$
  5. Apply the cart rule using the coupon code

Observe , cart price rule is not applying on shipping VAT when rule applied on whole cart.

Image

Thanks.

@engcom-Delta engcom-Delta added Component: Tax Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Tax and removed Component: Tax Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Tax labels Feb 28, 2025
@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-834

@engcom-Delta engcom-Delta removed their assignment Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Tax Component: Tax Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reported on 2.4.2 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
None yet
Development

No branches or pull requests