MDVA-36572: New inventory reservation created after updating credit memo
Affected products and versions
The patch is created for Adobe Commerce version:
Adobe Commerce on cloud infrastructure 2.4.1
Compatible with Adobe Commerce versions:
Adobe Commerce (all deployment types) 2.3.5-2.4.2-p1
magento/quality-patches
package to the latest version and check the compatibility on the Quality Patches Tool: Search for patches page. Use the patch ID as a search keyword to locate the patch.Issue
Credit Memo reservation update observer is triggered every time the credit memo is updated. As per agreement with PO changed the logic of reservation update to only be triggered upon the credit memo created. The possibility of the credit memo edits over API will be reviewed by PO as well in the scope of separate tickets.
Steps to reproduce:
-
Create customer account.
-
Create simple product.
-
Create new order, invoice and credit memo for the order.
-
Create new Integration.
-
Check inventory_reservation table:
code language-sql select * from inventory_reservation; +----------------+----------+----------+----------+-------------------------------------------------------------------------------------------------------------+ | reservation_id | stock_id | sku | quantity | metadata | +----------------+----------+----------+----------+-------------------------------------------------------------------------------------------------------------+ | 1 | 1 | simple_1 | -1.0000 | {"event_type":"order_placed","object_type":"order","object_id":"","object_increment_id":"000000001"} | | 2 | 1 | simple_1 | 1.0000 | {"event_type":"creditmemo_created","object_type":"order","object_id":"1","object_increment_id":"000000001"} | +----------------+----------+----------+----------+-------------------------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)
-
Send GET request to:
../rest/default/V1/creditmemo/3
-
Copy response (example):
code language-json { "adjustment": 0, "adjustment_negative": 0, "adjustment_positive": 0, "base_adjustment": 0, "base_adjustment_negative": 0, "base_adjustment_positive": 0, "base_currency_code": "USD", "base_discount_amount": 0, "base_grand_total": 105, "base_discount_tax_compensation_amount": 0, "base_shipping_amount": 5, "base_shipping_incl_tax": 5, "base_shipping_tax_amount": 0, "base_subtotal": 100, "base_subtotal_incl_tax": 100, "base_tax_amount": 0, "base_to_global_rate": 1, "base_to_order_rate": 1, "billing_address_id": 2, "created_at": "2021-04-05 23:43:45", "discount_amount": 0, "entity_id": 1, "global_currency_code": "USD", "grand_total": 105, "discount_tax_compensation_amount": 0, "increment_id": "000000001", "order_currency_code": "USD", "order_id": 1, "shipping_address_id": 1, "shipping_amount": 5, "shipping_incl_tax": 5, "shipping_tax_amount": 0, "state": 2, "store_currency_code": "USD", "store_id": 1, "store_to_base_rate": 0, "store_to_order_rate": 0, "subtotal": 100, "subtotal_incl_tax": 100, "tax_amount": 0, "updated_at": "2021-04-05 23:43:45", "items": [ { "base_cost": null, "base_discount_tax_compensation_amount": 0, "base_price": 100, "base_price_incl_tax": 100, "base_row_total": 100, "base_row_total_incl_tax": 100, "base_tax_amount": 0, "base_weee_tax_row_disposition": 0, "entity_id": 1, "discount_tax_compensation_amount": 0, "name": "simple_1", "order_item_id": 1, "parent_id": 1, "price": 100, "price_incl_tax": 100, "product_id": 1, "qty": 1, "row_total": 100, "row_total_incl_tax": 100, "sku": "simple_1", "tax_amount": 0, "weee_tax_applied": "[]", "weee_tax_applied_row_amount": 0, "weee_tax_row_disposition": 0 } ], "comments": [] }
-
Send POST request to:
../rest/default/V1/creditmemo
code language-json { "entity": --paste full response from previous step here-- }
note note NOTE Such payload used only for simplifying reproducing - customer get the same issue after updating their custom attribute -
Check inventory_reservation table:
Actual results:
select * from inventory_reservation;
+----------------+----------+----------+----------+-------------------------------------------------------------------------------------------------------------+
| reservation_id | stock_id | sku | quantity | metadata |
+----------------+----------+----------+----------+-------------------------------------------------------------------------------------------------------------+
| 1 | 1 | simple_1 | -1.0000 | {"event_type":"order_placed","object_type":"order","object_id":"","object_increment_id":"000000001"} |
| 2 | 1 | simple_1 | 1.0000 | {"event_type":"creditmemo_created","object_type":"order","object_id":"1","object_increment_id":"000000001"} |
| 3 | 1 | simple_1 | 1.0000 | {"event_type":"creditmemo_created","object_type":"order","object_id":"1","object_increment_id":"000000001"} |
+----------------+----------+----------+----------+-------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
Expected results:
No second reservation for the same credit memo is created.
Apply the patch
To apply individual patches use the following links depending on your deployment type:
- Adobe Commerce or Magento Open Source on-premises: Software Update Guide > Apply Patches in our developer documentation.
- Adobe Commerce on cloud infrastructure: Upgrades and Patches > Apply Patches in our developer documentation.
Related reading
To learn more about Quality Patches Tool, refer to:
For info about other patches available in QPT, refer to the Patches available in QPT section.