magento2-disable-stock-reservation icon indicating copy to clipboard operation
magento2-disable-stock-reservation copied to clipboard

When the creditmemo is created, the stock quantity decreases

Open ConradoSM opened this issue 1 year ago • 6 comments

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

ConradoSM avatar Oct 12 '23 20:10 ConradoSM

Hey @ConradoSM what version of magento please?

convenient avatar Oct 12 '23 20:10 convenient

2.4.6-p1

ConradoSM avatar Oct 12 '23 20:10 ConradoSM

Before order place:

image

After order place:

image

After create creditmemo:

image

ConradoSM avatar Oct 12 '23 20:10 ConradoSM

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

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

robsoned avatar Oct 30 '23 20:10 robsoned

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

tr33m4n avatar Feb 09 '24 21:02 tr33m4n

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.

wbartonvb avatar May 31 '24 00:05 wbartonvb