TransWikia.com

Backorder quantity wrong when unshipped reservations

Magento Asked by Nathan on December 27, 2020

Magento version: 2.3.5-p1

(magento/module-inventory-sales) version: 1.0.8

The backorder quantity shown in checkout and stored in sales_order_item.qty_backordered can be wrong when there are reservations for the product. The backorder quantity is calculated using the current stock count, not the salable count which considers reservations.

Example:

  • Global config: Decrease Stock When Order is Placed = Yes.
  • Product config: stock qty = 2, no reservations, manage stock = Yes, out of stock threshold = 0, backorders = Allow Qty Below 0 and Notify.
  • Add to cart 1 qty (no backorder shown). Place order.
  • Add to cart 2 qty (no backorder shown, but should be 1 qty).
  • Add to cart 1 qty (3 total). (1 qty backorder shown, but should be 2 qty).
  • Place order. (1 qty backorder stored in sales_order_item.qty_backordered, but should be 2 qty).

The culprit is here:

vendor/magento/module-inventory-sales/Model/IsProductSalableCondition/BackOrderNotifyCustomerCondition.php

Line: $backOrderQty = $requestedQty - $stockItemData[GetStockItemDataInterface::QUANTITY];

The stock qty is being used to calculate the backorder qty, so reservations are not considered.

It’s not even consistent in ignoring reservations though, as they are correctly considered when checking if add to cart should be allowed here:

vendor/magento/module-inventory-sales/Model/IsProductSalableCondition/IsSalableWithReservationsCondition.php

I know that this is due to the order not being shipped yet, so the stock isn’t being decreased yet. But still, surely this isn’t intentional? You cannot sell the same salable qty multiple times to different customers. I haven’t found an answer for this, which makes me think I’m missing something. Thanks in advance.

One Answer

I found this: https://github.com/magento/inventory/pull/2452

This is a known bug that will be fixed in 2.4 They say you can pull the fix into 2.3.5 if necessary.

Answered by Nathan on December 27, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP