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
Ensure order state handles with partial shipment #38679
base: 2.4-develop
Are you sure you want to change the base?
Ensure order state handles with partial shipment #38679
Conversation
…the order can be shipped
…the qtyToShip to take into account the item refund data
Hi @digitalrisedorset. Thank you for your contribution! Add the comment under your pull request to deploy test or vanilla Magento instance:
❗ Automated tests can be triggered manually with an appropriate comment:
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@digitalrisedorset Thanks for contribution.
As I see suggested logic provide non expected logic.
Refund works only with shipped items.
Cancelation works only with non shipped items.
For example,
ordered = 5
shipped = 3
refunded = 2 (refunded from shipped 3)
canceled = 1
I expect to see 1 to ship.
Suggested logic will cause negative value and max(round($qty, 8), 0)
return 0.
excellent feedback, I will investigate this further. I will try to bring all the scenarios we may have so that we can verify we have all the possible situations in mind to resolve this issue. Many thanks @Den4ik |
@Den4ik following your inputs, I was able to identify more use cases but unfortunately, it seems I have been focusing at the wrong end of the stick. To make sure we understand what we are trying to do, I may recall here the aim of the PR:
I am yet to ascertain how the refund data should be considered at this time:
I suggest not to review any further until I have more information with this part of the refund aspect |
…tems and other items are shipped or refunded
@Den4ik I have now found out a way to fix the problem and I have committed some changes today. However, I see my change has a conflict with the method The 2 lines change that have been made and conflict with my change are sufficient for this issue to be called close. I am more than happy to go with the change that have been provided and discard all my changes. In short, if we close my PR and the issue and ensure the lines that conflict with my changes get pushed further, then the issue is resolved |
The order flow will set the order to complete only once the order items are dealt with shipment, refund, cancellation. Yet, some edge case with virtual items and with partial shipment, partial refund, partial cancellation can make this flow faulty.
Description (*)
The change in this PR makes the
qty to ship
calculation to remove the qty refunded, qty cancelled and qty shipped alreadyRelated Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Test 1: place an order with only physical items
validate the order gets complete when the invoice and shipment are processed and all the items are shipped
Test 2: place an order with only physical items and partial refund
validate the order gets complete when the invoice, refund and shipment are processed and all the items are shipped or refund or cancelled
Test 3: place an order with a mix of configurable, physical items and virtual items
validate the order gets complete when the invoice, refund and shipment are processed and all the items are shipped or refund or cancelled
Questions or comments
This change is not backward compliant. However, like @digitalpianism mentions, the current behaviour is not consistent when the order has only physical items. The latest change in the model
\Magento\Sales\Model\ResourceModel\Order\Handler\State
is what makes the experience consistent as per the requirements of the issue we are dealing with.Currently, it is possible to refund an item that has not been shipped or just as well refund an item that has already been shipped without being able to trace either scenarios. Yet, the logic in the method
\Magento\Sales\Model\ResourceModel\Order\Handler\State::isPartiallyRefundedOrderShipped
assumes the refund and the shipping are separate information that can be cumulatedI have added some changes in the method
\Magento\Sales\Model\Order\Item::getSimpleQtyToShip
. These turn out to do the same as before. However, I would like to encourage to keep these changes (I am not precious but think they improve the readability of the logic in this method)Contribution checklist (*)