feat(medusa, medusa-plugin-brightpearl): Inventory management for Brightpearl (#3192)
This commit is contained in:
@@ -132,18 +132,19 @@ export default class ReservationItemService {
|
||||
@MedusaContext() context: SharedContext = {}
|
||||
): Promise<ReservationItem> {
|
||||
const manager = context.transactionManager!
|
||||
const itemRepository = manager.getRepository(ReservationItem)
|
||||
const reservationItemRepository = manager.getRepository(ReservationItem)
|
||||
|
||||
const inventoryItem = itemRepository.create({
|
||||
const reservationItem = reservationItemRepository.create({
|
||||
inventory_item_id: data.inventory_item_id,
|
||||
line_item_id: data.line_item_id,
|
||||
location_id: data.location_id,
|
||||
quantity: data.quantity,
|
||||
metadata: data.metadata,
|
||||
external_id: data.external_id,
|
||||
})
|
||||
|
||||
const [newInventoryItem] = await Promise.all([
|
||||
itemRepository.save(inventoryItem),
|
||||
const [newReservationItem] = await Promise.all([
|
||||
reservationItemRepository.save(reservationItem),
|
||||
this.inventoryLevelService_.adjustReservedQuantity(
|
||||
data.inventory_item_id,
|
||||
data.location_id,
|
||||
@@ -153,10 +154,10 @@ export default class ReservationItemService {
|
||||
])
|
||||
|
||||
await this.eventBusService_?.emit?.(ReservationItemService.Events.CREATED, {
|
||||
id: newInventoryItem.id,
|
||||
id: newReservationItem.id,
|
||||
})
|
||||
|
||||
return newInventoryItem
|
||||
return newReservationItem
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user