fix(medusa): Order edit missing transaction when consuming the inventory module (#4211)
* fix(medusa): Order edit missing transaction when consuming the inventory module * Create hot-cougars-speak.md * fix missing types
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
TaxProviderService,
|
||||
TotalsService,
|
||||
} from "./index"
|
||||
import { MedusaError, isDefined } from "medusa-core-utils"
|
||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||
import { buildQuery, isString } from "../utils"
|
||||
|
||||
import EventBusService from "./event-bus"
|
||||
@@ -767,13 +767,12 @@ export default class OrderEditService extends TransactionBaseService {
|
||||
orderEdit = await orderEditRepository.save(orderEdit)
|
||||
|
||||
if (this.inventoryService_) {
|
||||
await Promise.all(
|
||||
lineItems.map(
|
||||
async (lineItem) =>
|
||||
await this.inventoryService_!.deleteReservationItemsByLineItem(
|
||||
lineItem.id
|
||||
)
|
||||
)
|
||||
const itemsIds = lineItems.map((i) => i.id)
|
||||
await this.inventoryService_!.deleteReservationItemsByLineItem(
|
||||
itemsIds,
|
||||
{
|
||||
transactionManager: manager,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ import {
|
||||
ICacheService,
|
||||
IEventBusService,
|
||||
IInventoryService,
|
||||
IStockLocationService,
|
||||
InventoryItemDTO,
|
||||
InventoryLevelDTO,
|
||||
IStockLocationService,
|
||||
ReservationItemDTO,
|
||||
ReserveQuantityContext,
|
||||
} from "@medusajs/types"
|
||||
import { LineItem, Product, ProductVariant } from "../models"
|
||||
import { MedusaError, isDefined } from "@medusajs/utils"
|
||||
import { isDefined, MedusaError } from "@medusajs/utils"
|
||||
import { PricedProduct, PricedVariant } from "../types/pricing"
|
||||
import { TransactionBaseService } from "../interfaces"
|
||||
|
||||
@@ -584,7 +584,7 @@ class ProductVariantInventoryService extends TransactionBaseService {
|
||||
* @param quantity quantity to release
|
||||
*/
|
||||
async deleteReservationsByLineItem(
|
||||
lineItemId: string,
|
||||
lineItemId: string | string[],
|
||||
variantId: string,
|
||||
quantity: number
|
||||
): Promise<void> {
|
||||
@@ -606,7 +606,10 @@ class ProductVariantInventoryService extends TransactionBaseService {
|
||||
})
|
||||
}
|
||||
|
||||
await this.inventoryService_.deleteReservationItemsByLineItem(lineItemId)
|
||||
const itemIds = Array.isArray(lineItemId) ? lineItemId : [lineItemId]
|
||||
await this.inventoryService_.deleteReservationItemsByLineItem(itemIds, {
|
||||
transactionManager: this.activeManager_,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user