-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Creditmemo creation error - Forgotten shipping discount tax compensation in creditmemo calculation ? #38088
Comments
Hi @Nuranto. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Hi @engcom-Bravo. Thank you for working on this issue.
|
Hi @engcom-Dash. Thank you for working on this issue.
|
@magento give me 2.4-develop instance |
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Dash, here is your Magento Instance: https://553a183d014e02ad841c505fd4fefbce.instances-prod.magento-community.engineering |
Hi @Nuranto |
As I said, it is a very rare issue (we got 1 case for thousands of orders). It happened on a big order (douzens of products), with a cart discount. However, I don't know how to reproduce for sure I'm afraid. |
Hi @Nuranto |
We're running on docker Note : If you refunded Shipping fees on first creditmemo, why do you have |
@magento give me 2.4-develop instance |
Hi @engcom-Dash. Thank you for your request. I'm working on Magento instance for you. |
Hi @engcom-Dash, here is your Magento Instance: https://553a183d014e02ad841c505fd4fefbce.instances-prod.magento-community.engineering |
Hi @Nuranto Thanks for reporting and collaboration. we can divide the shipping fee into two creditmemos We followed the steps to reproduce but not able to reproduce the issue. 1.Place an order*, with a discount (not sure if the discount is mandatory) Please let us know the detailed steps to reproduce the issue. |
Hi @Nuranto We have noticed that this issue has not been updated since long time. Hence we assume that this issue is fixed now, so we are closing it. Please feel to raise a fresh ticket or reopen this ticket if you need more assistance on this. Thanks. |
(related to #38134) |
Workaround Fix proposal, for those who have the issue, or if the issue is reopened one day : Replace :
With
This doesn't fix the underlaying issue that I did not identified yet. But that will prevent the exception to be thrown without damaging creditmemo data. |
Preconditions and environment
Steps to reproduce
It's kind hard to say how to reproduce step by step because it's a very very rare rounding issue on shipping amounts. But I'll try anyway, and then give the order details :
(*) Here is some order detail that might be relevant :
Expected result
We can create another creditmemo
Actual result
We can not create another creditmemo, and have an error message :
Maximum shipping amount allowed to refund is: 0,00 €
Additional information
desiredAmount
is0.01
inmagento2/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Shipping.php
Lines 71 to 98 in 2b3ad2e
So
$desiredAmount < [..]$allowedAmount
gives0.01 < 0
which causes the exception. That 0.01 seems to correspond toshipping_discount_tax_compensation_amount
field.DesiredAmount is set previously here :
magento2/app/code/Magento/Sales/Model/Order/CreditmemoFactory.php
Lines 151 to 154 in 2b3ad2e
and calculated here :
magento2/app/code/Magento/Sales/Model/Order/CreditmemoFactory.php
Lines 326 to 340 in 2b3ad2e
As you can see, if we apply my order numbers in that code, it gives :
$amount = 125 - 113.63 - 11.36 = 0.01
=> So I guess the calculation is forgetting aboutshipping_discount_tax_compensation_amount
And a fix would be :
However, tax calculation is so complex in Magento 2 that I won't try to make a PR for this. It would be safer if someone used to such calculations can have a look. However, this fix seems to fix the issue.
EDIT : This fix was not OK, and it seems unrelated from
shipping_discount_tax_compensation_amount
after all.Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: