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

Refund for bundle product without receiving product back #23440

Closed
simonmaass opened this issue Jun 27, 2019 · 11 comments · Fixed by #27455
Closed

Refund for bundle product without receiving product back #23440

simonmaass opened this issue Jun 27, 2019 · 11 comments · Fixed by #27455
Assignees
Labels
Component: Bundle Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S1 Affects critical data or functionality and forces users to employ a workaround. Triage: Done Has been reviewed and prioritized during Triage with Product Managers

Comments

@simonmaass
Copy link

Preconditions (*)

  1. 2.3.1
  2. php7.2

Steps to reproduce (*)

  1. Create bundle product with at least 2 products
  2. Create order with bundle product (eg. 50€)
  3. Invoice Order
  4. Shop Order
  5. Create Credit Memo without taking the product back in stock and only refund amount (eg. 10€)
    Unbenannt

Unbenannt2

Expected result (*)

  1. Credit Memo for amount 10€ created

Actual result (*)

  1. Error: "The most money available to refund is €xx.xx.
    Eventhou the refund was below the mentioned amount!!!

Unbenannt3

@m2-assistant
Copy link

m2-assistant bot commented Jun 27, 2019

Hi @simonmaass. 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.3-develop instance - upcoming 2.3.x release

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

@simonmaass do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jun 27, 2019
@simonmaass
Copy link
Author

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

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

@magento-engcom-team
Copy link
Contributor

Hi @simonmaass, here is your Magento instance.
Admin access: https://i-23440-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@engcom-Charlie engcom-Charlie self-assigned this Jun 27, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jun 27, 2019

Hi @engcom-Charlie. 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.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Charlie engcom-Charlie added Component: Bundle Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Jun 27, 2019
@ghost ghost unassigned engcom-Charlie Jun 27, 2019
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jun 27, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-17848, MC-17849 were created

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

@mwr
Copy link
Contributor

mwr commented Jun 28, 2019

The root cause of the Problem seems to be in \Magento\Sales\Model\Order\CreditmemoFactory::createByOrder.

public function createByOrder(\Magento\Sales\Model\Order $order, array $data = [])
    {
        $totalQty = 0;
        $creditmemo = $this->convertor->toCreditmemo($order);
        $qtyList = isset($data['qtys']) ? $data['qtys'] : [];

        foreach ($order->getAllItems() as $orderItem) {
            if (!$this->canRefundItem($orderItem, $qtyList)) {
                continue;
            }

            $item = $this->convertor->itemToCreditmemoItem($orderItem);
            $qty = $this->getQtyToRefund($orderItem, $qtyList);
            $totalQty += $qty;
            $item->setQty($qty);
            $creditmemo->addItem($item);
        }

        $creditmemo->setTotalQty($totalQty);

        $this->initData($creditmemo, $data);

        $creditmemo->collectTotals();
        return $creditmemo;
    }

Either canRefundItem should return false but does not or getQtyToRefund should return 0 but does not either.

I have tried fixing it with a check of the qtyList containing an empty array in this scenario (bundle with 0 items refunded).

            if (!array_key_exists($orderItem->getId(), $qtyList)) {
                $qty = 0;
            }

This works fine except when there is one product of a bundle being refunded. Then the Items are not rendered when viewing the creditmemo. Most likely because the parent product of the bundled item is missing.
At this point I am not sure how the intended workflow is for bundles on a creditmemo.

Additionaly the method \Magento\Sales\Model\Order\CreditmemoFactory::createByOrder seems to be used multiple times: when the form is generated, when the Update Qty Button is clicked and when the creditmemo is saved.

@simonmaass
Copy link
Author

any update on this? This is rather important for us because we are often refunding money but not taking the product back

@DavidLambauer
Copy link
Contributor

Ping

@magento-engcom-team magento-engcom-team added this to Ready for Dev in Community Backlog Mar 24, 2020
@KiuNguyen KiuNguyen self-assigned this Mar 25, 2020
@m2-assistant
Copy link

m2-assistant bot commented Mar 25, 2020

Hi @KiuNguyen. 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 Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. 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!

  • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


@ghost ghost moved this from Ready for Dev to Dev in Progress in Community Backlog Mar 25, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Mar 25, 2020
@ghost ghost moved this from Dev in Progress to PR In Progress in Community Backlog Mar 27, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Apr 7, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Apr 15, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Apr 15, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Apr 17, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Apr 17, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Apr 17, 2020
KiuNguyen pushed a commit to KiuNguyen/magento2 that referenced this issue Apr 17, 2020
@ghost ghost added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S1 Affects critical data or functionality and forces users to employ a workaround. labels Apr 29, 2020
@sdzhepa sdzhepa added the Triage: Done Has been reviewed and prioritized during Triage with Product Managers label May 8, 2020
@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label May 15, 2020
@ghost ghost moved this from PR In Progress to Done (last 30 days) in Community Backlog May 15, 2020
slavvka pushed a commit that referenced this issue May 15, 2020
…roduct back e… #27455

 - Merge Pull Request #27455 from KiuNguyen/magento2:fixbug-23440-Refund-bundle-product-without-receiving-product-back-error
 - Merged commits:
   1. d0ab2a3
   2. d03d133
   3. 4807ebb
   4. b88d88e
   5. 10d5f73
   6. b13b0ec
   7. 4b28ae3
   8. 9de9cf0
   9. a7ea256
   10. df1b766
   11. 84ff076
   12. a4d0b79
slavvka added a commit that referenced this issue May 15, 2020
@magento-engcom-team magento-engcom-team removed this from Done (last 30 days) in Community Backlog May 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Bundle Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Severity: S1 Affects critical data or functionality and forces users to employ a workaround. Triage: Done Has been reviewed and prioritized during Triage with Product Managers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants