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

Order is not complete when mixing virtual, refunded and shipped items #38547

Open
1 of 5 tasks
digitalpianism opened this issue Mar 22, 2024 · 21 comments · May be fixed by #38679
Open
1 of 5 tasks

Order is not complete when mixing virtual, refunded and shipped items #38547

digitalpianism opened this issue Mar 22, 2024 · 21 comments · May be fixed by #38679
Assignees
Labels
Area: Order Component: order status 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: PR in progress Reported on 2.4.4-p7 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

@digitalpianism
Copy link
Contributor

digitalpianism commented Mar 22, 2024

Preconditions and environment

  • Magento 2.4.4-p7

Steps to reproduce

  1. Create an order containing: 1 physical item of quantity = 2 and 1 virtual item of quantity = 5
  2. Invoice the order
  3. Refund 1 quantity of the physical item
  4. Ship 1 quantity of the physical item

image

Expected result

Order state should be complete.

Actual result

Order state is still processing.
image

Additional information

Problem comes from magento/module-sales/Model/ResourceModel/Order/Handler/State.php

In the isPartiallyRefundedOrderShipped, the code compares the total qty ordered with the sum of total qty shipped and total qty refunded.

However, virtual items are not considered when retrieving the total qty shipped, preventing the method from returning true.

Here's the fix that I have used to resolve the issue:

diff --git a/src/vendor/magento/module-sales/Model/ResourceModel/Order/Handler/State.php b/src/vendor/magento/module-sales/Model/ResourceModel/Order/Handler/State.php
index 51c45ed5e5..8d97ce01cb 100644
--- module-sales/Model/ResourceModel/Order/Handler/State.php
+++ module-sales/Model/ResourceModel/Order/Handler/State.php
@@ -97,1 +97,3 @@ class State
-            $numOfShippedItems += (int)$item->getQtyShipped();
+            $numOfShippedItems += $item->getIsVirtual()
+                ? (int)$item->getQtyOrdered()
+                : (int)$item->getQtyShipped();

Release note

No response

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”.
Copy link

m2-assistant bot commented Mar 22, 2024

Hi @digitalpianism. 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.
⚠️ 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.

@digitalpianism
Copy link
Contributor Author

@magento give me 2.4-develop instance

Copy link

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

Copy link

@digitalpianism
Copy link
Contributor Author

Confirming the issue is present in 2.4-develop, screenshots below from the instance above:
image
image

@engcom-Bravo engcom-Bravo self-assigned this Mar 23, 2024
Copy link

m2-assistant bot commented Mar 23, 2024

Hi @engcom-Bravo. 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).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas 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-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

Copy link

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

@engcom-Bravo engcom-Bravo added the Reported on 2.4.4-p7 Indicates original Magento version for the Issue report. label Mar 25, 2024
Copy link

@engcom-Bravo
Copy link
Contributor

Hi @digitalpianism,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

  • Create an order containing: 1 physical item of quantity = 2 and 1 virtual item of quantity = 5
  • Invoice the order
  • Refund 1 quantity of the physical item
  • Ship 1 quantity of the physical item
Screenshot 2024-03-25 at 11 16 09 Screenshot 2024-03-25 at 11 16 17

The order is still in Processing because we have one more quantity for the physical product to ship.

Could you please let us know if we are missing anything.

Thanks.

@engcom-Bravo engcom-Bravo added the Issue: needs update Additional information is require, waiting for response label Mar 25, 2024
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Mar 25, 2024
@digitalpianism
Copy link
Contributor Author

digitalpianism commented Mar 25, 2024

@engcom-Bravo it's not consistent with the rest of Magento behavior then.

Let's take the case below:

  • Create an order containing: 1 physical item of quantity = 2 (NO VIRTUAL ITEM)
  • Invoice the order
  • Refund 1 quantity of the physical item
  • Ship 1 quantity of the physical item

image

In that case, the order becomes Complete:

image

On top of that if you create another order like this:

  • Create an order containing: 1 virtual item of quantity = 5 (NO PHYSICAL ITEM)
  • Invoice the order

image

The order is complete as well.

image

Knowing that, combination of both should be complete too.

@engcom-Bravo
Copy link
Contributor

@magento give me 2.4-develop instance

Copy link

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

Copy link

@engcom-Bravo
Copy link
Contributor

Hi @digitalpianism,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.

The Order is still in Processing state when we have combination of both physical products and virtual products.

Hence Confirming the issue.

Thanks.

@engcom-Bravo engcom-Bravo added the Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch label Mar 26, 2024
@engcom-Bravo engcom-Bravo added 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. labels Mar 26, 2024
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Confirmed in Issue Confirmation and Triage Board Mar 26, 2024
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Mar 26, 2024
@engcom-Bravo engcom-Bravo added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Mar 26, 2024
@github-jira-sync-bot
Copy link

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

Copy link

m2-assistant bot commented Mar 26, 2024

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

@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-11691

@digitalrisedorset
Copy link

@magento I am working on this

@m2-community-project m2-community-project bot moved this from Ready for Development to Dev In Progress in High Priority Backlog Apr 29, 2024
@digitalrisedorset digitalrisedorset linked a pull request Apr 30, 2024 that will close this issue
5 tasks
@m2-community-project m2-community-project bot moved this from Dev In Progress to Pull Request In Progress in High Priority Backlog Apr 30, 2024
@digitalrisedorset
Copy link

@magento run all tests

@digitalrisedorset
Copy link

I have started to have some feedbacks for this issue and I will put a report on where we are at this point.

  • it is possible to refund an item before it has been shipped
  • it is also possible to refund an item after it has been shipped
    These 2 operations can be performed from the backend using the credit memo backend screen.

As a consequence, when a product has been refunded, it can overlap with the shipment data (in which case, using the tests to reproduce the issue, the order is expected to remain to processing)
it can be separate from the shipment data, we refund an item that was not sent yet (the credit memo is expected to adjust the shipping fees to 0 in this case) and the order status would be expected to be set to complete

--> the conclusion of this finding is that unless we can flag is a refund is for a shipped item or not, then we can't change the order status to complete.
--> the focus with this issue was to verify virtual items did not prevent the order to be set to complete if all the physical items in the order were handled by shipment or refund. But the fact we are not able to separate refund and shipment data leads us to be still at the original place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Order Component: order status 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: PR in progress Reported on 2.4.4-p7 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
High Priority Backlog
  
Pull Request In Progress
Development

Successfully merging a pull request may close this issue.

4 participants