feat(medusa): Remove reservations for all line items when an order edit is accepted (#3544)

**What**
- Remove all allocations to line items once an order edit is confirmed

**Why**
- Since all line items of an order are discarded once an order edit is confirmed it will orphan the reservations causing inconsistencies with the stock
This commit is contained in:
Philip Korsholm
2023-03-30 09:56:10 +00:00
committed by GitHub
parent 999aeb116c
commit 5e405be02c
6 changed files with 167 additions and 41 deletions
@@ -242,9 +242,10 @@ export default class ReservationItemService {
context
)
const ops: Promise<unknown>[] = []
const ops: Promise<unknown>[] = [
itemRepository.softDelete({ line_item_id: lineItemId })
]
for (const item of items) {
ops.push(itemRepository.softRemove({ line_item_id: lineItemId }))
ops.push(
this.inventoryLevelService_.adjustReservedQuantity(
item.inventory_item_id,