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

When the creditmemo is created, the stock quantity decreases #129

Open
ConradoSM opened this issue Oct 12, 2023 · 6 comments
Open

When the creditmemo is created, the stock quantity decreases #129

ConradoSM opened this issue Oct 12, 2023 · 6 comments

Comments

@ConradoSM
Copy link

ConradoSM commented Oct 12, 2023

Proposed fix:

diff --git a/vendor/ampersand/magento2-disable-stock-reservation/src/Model/SourceDeductionService/PatchedSourceDeductionService.php b/vendor/ampersand/magento2-disable-stock-reservation/src/Model/SourceDeductionService/PatchedSourceDeductionService.php
--- a/vendor/ampersand/magento2-disable-stock-reservation/src/Model/SourceDeductionService/PatchedSourceDeductionService.php	
+++ b/vendor/ampersand/magento2-disable-stock-reservation/src/Model/SourceDeductionService/PatchedSourceDeductionService.php
@@ -99,6 +99,21 @@
                     $sourceItem->setStatus($stockStatus);
                     continue;
                 }
+            } else if ($salesEvent->getType() ==
+                \Magento\InventorySalesApi\Api\Data\SalesEventInterface::EVENT_CREDITMEMO_CREATED) {
+                if ($qty < 0) {
+                    $sourceItem->setQuantity($sourceItem->getQuantity() - $qty);
+                    $stockStatus = $this->getSourceStockStatus(
+                        $stockItemConfiguration,
+                        $sourceItem
+                    );
+                    $sourceItem->setStatus($stockStatus);
+                    $sourceItemDecrementData[] = [
+                        'source_item' => $sourceItem,
+                        'qty_to_decrement' => $qty
+                    ];
+                }
+                continue;
             }
             /*
              * Ampersand change finish
@convenient
Copy link
Contributor

Hey @ConradoSM what version of magento please?

@ConradoSM
Copy link
Author

2.4.6-p1

@ConradoSM
Copy link
Author

Before order place:

image

After order place:

image

After create creditmemo:

image

@robsoned
Copy link
Contributor

I'm having the same issue that @ConradoSM mentioned.

Tested on magento 2.4.5-p2, ampersand/magento2-disable-stock-reservation 1.3.0

@tr33m4n
Copy link
Contributor

tr33m4n commented Feb 9, 2024

Hi all, just doing due diligence and confirming this is still an issue? It feels recent enough to consider it so. @ConradoSM any chance you may be able to fork this repository and make a pull request back in with your patch for approval? Thanks

@wbartonvb
Copy link

I am having same issue on 2.4.4-p8, ampersand/magento2-disable-stock-reservation 1.3.2

Applying patch from @ConradoSM prevented inventory from being reduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants