magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

Subtotal Cart Price Rule excludes product tax for fixed amount #29740

Closed bckpff closed 3 years ago

bckpff commented 4 years ago

Preconditions (*)

Reproducing on 2.4-develop Magento ver. 2.3.5-p2 - upgraded from 2.3.5-p1 using composer

Steps to reproduce (*)

Expected result (*)

Actual result (*)

This pobably relates to: https://github.com/magento/magento2/issues/28472 The related PR did not fix my issue.

Edit: I could reproduce this behaviour on a fresh 2.4-develop instance.

m2-assistant[bot] commented 4 years ago

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

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


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

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

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

bckpff commented 4 years ago

@magento give me 2.4-develop instance

magento-engcom-team commented 4 years ago

Hi @madhippieqq. Thank you for your request. I'm working on Magento 2.4-develop instance for you

magento-engcom-team commented 4 years ago

Hi @madhippieqq, here is your Magento instance. Admin access: https://i-29740-2-4-develop.instances.magento-community.engineering/admin_75c5 Login: a749cc0b Password: 070b466cba2a Instance will be terminated in up to 3 hours.

bckpff commented 4 years ago

Could reproduce this issue on 2.4-develop

albsa commented 4 years ago

We commited patch https://github.com/pixelhed/magento2/commit/25ea6caf9f64c9ad55e951c54bbb633b84f3dcc2 thanks to @pixelhed

This fixed the issue for us temporarily untill core fix is released.

bckpff commented 4 years ago

I applied the same patch. This didn't work for me.

albsa commented 4 years ago

@madhippieqq how did you apply the patch? we had to make some addjustments to the patch file. Did you follow the instructions how to apply a patch in Magento 2? Then you would have to edit the patch file because the original file contains path of local core code. You have to adjust to composer vendor modules file path.

Note: this is a .diff file

diff --git a/Model/Sales/Total/Quote/CommonTaxCollector.php b/Model/Sales/Total/Quote/CommonTaxCollector.php
index c7cc4ded1bf0..cc37cba69ffe 100644
--- a/Model/Sales/Total/Quote/CommonTaxCollector.php
+++ b/Model/Sales/Total/Quote/CommonTaxCollector.php
@@ -596,8 +596,8 @@ protected function processProductItems(
         $address = $shippingAssignment->getShipping()->getAddress();
         $address->setBaseTaxAmount($baseTax);
         $address->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
-        $address->setSubtotal($total->getSubtotal());
-        $address->setBaseSubtotal($total->getBaseSubtotal());
+        //$address->setSubtotal($total->getSubtotal());
+        //$address->setBaseSubtotal($total->getBaseSubtotal());

         return $this;
     }

https://devdocs.magento.com/guides/v2.4/comp-mgr/patching.html

bckpff commented 4 years ago

@albsa Since it were only two changed lines , I just applied the changes to Model/Sales/Total/Quote/CommonTaxCollector.php on my local machine manually, cleared cache and generation folder and retried. The error still occurs on magento 2.3.5-p2.

m2-assistant[bot] commented 4 years ago

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: :point_down:

magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Oscar Thank you for verifying the issue. Based on the provided information internal tickets MC-37729 were created

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

voleye commented 3 years ago

@magento I am working on this

m2-assistant[bot] commented 3 years ago

Hi @voleye! :wave: Thank you for collaboration. Only members of Community Contributors Team are allowed to be assigned to the issue. Please use @magento add to contributors team command to join Contributors team.

voleye commented 3 years ago

@magento add to contributors team

m2-assistant[bot] commented 3 years ago

Hi @voleye! :wave: Thank you for joining. Please accept team invitation :point_right: here :point_left: and add your comment one more time.

voleye commented 3 years ago

@magento I am working on this

voleye commented 3 years ago

@magento-engcom-team seems it is not a bug. Magento has an appropriate settings in Store->Configuration->Sales->Tax->Calculation Settings Apply Discount On Prices (Excluding Tax|Including Tax) and description: " Warning: To apply the discount on prices including tax and apply the tax after discount, set Catalog Prices to “Including Tax”. " So, if you would like to apply discount on a price value including tax then you have to make appropriate configuration in particular set Catalog Prices to “Including Tax”

bernieu2 commented 3 years ago

@voleye but this issue is relating to a cart price rule for a fixed amount on order. Not related to specific product prices? I definitely think this is a bug. A few issues have raised now. https://github.com/magento/magento2/issues/28472 perhaps this one is related too? https://github.com/magento/magento2/issues/13392 I think it is difficult to evaluate the issue as tax has many variables dependent on user country. This is especially true when a merchant sells taxable and non-taxable goods in the same transaction; we cannot apply a simple 'workaround' by changing the discount gate amount to exclusive of tax.

For example - I have the following settings in Tax Configuration. My tax rate is 10%. Screenshot from 2020-10-27 11-55-32 Screenshot from 2020-10-27 11-55-45

Now, I have created a cart price rule that gives $15.95 discount (the relevant shipping cost) to the cart when a customers cart totals $199 or more. Screenshot from 2020-10-27 11-57-16 Screenshot from 2020-10-27 11-57-34

I think its important to note here that there is option for Subtotal Excl Tax or Subtotal. One would assume the latter is inclusive of tax. Screenshot from 2020-10-27 12-07-33

Now, for simplicity sake I have added a taxable item to cart worth $10 (which is actually $9.09 excl tax + $0.91 tax). With a quantity of 20 of this item so the cart total is now $200. I then select the relevant shipping method as per cart price rule. NO DISCOUNT APPLIED: Screenshot from 2020-10-27 11-53-15 Now, I add two more of this product to the cart. Now my total is $220 (which includes $20.02 tax; $199.98 exclusive of tax). DISCOUNT IS APPLIED: Screenshot from 2020-10-27 11-55-08

It seems Magento is using the price exclusive of tax to calculate whether the sales price rule applies. This is not consistent with the tax settings or the cart price rule settings. To the customer, it seems like we are lying or duping them with our cart price offer.

After applying the patch linked above: https://github.com/pixelhed/magento2/commit/25ea6caf9f64c9ad55e951c54bbb633b84f3dcc2

Now, I re-add the same product, quantity and select the relevant shipping method and the discount is applied correctly: Screenshot from 2020-10-27 11-59-43

Perhaps this patch causes other issues for other users who don't include tax in catalog prices etc... I don't know. But for merchants that do, it is a problem. Thoughts?

voleye commented 3 years ago

@bernieu2 thank you for so detailed description, I will try to reproduce the issue again making all these settings!

sdzhepa commented 3 years ago

The related internal Jira ticket MC-38939 was closed as Fixed.

Fix for 2.4.x will be delivered soon in the scope of MC-37729