AmpersandHQ / magento2-disable-stock-reservation

This module disables the inventory reservation logic introduced as part of MSI in Magento 2.3.3
GNU Lesser General Public License v3.0
215 stars 61 forks source link

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

Open ConradoSM opened 11 months ago

ConradoSM commented 11 months ago

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 commented 11 months ago

Hey @ConradoSM what version of magento please?

ConradoSM commented 11 months ago

2.4.6-p1

ConradoSM commented 11 months ago

Before order place:

image

After order place:

image

After create creditmemo:

image

robsoned commented 11 months ago

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 commented 7 months ago

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 commented 4 months ago

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.