From 28f8fb01a2e8a97e10b148c17704f5b5af8c72d3 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Mon, 15 Dec 2025 09:11:00 +0330 Subject: [PATCH] up --- src/modules/inventory/inventory.service.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/inventory/inventory.service.ts b/src/modules/inventory/inventory.service.ts index c9943e3..86ba5bf 100644 --- a/src/modules/inventory/inventory.service.ts +++ b/src/modules/inventory/inventory.service.ts @@ -8,6 +8,7 @@ import { Reservation } from './entities/reservation.entity'; import { Food } from '../foods/entities/food.entity'; import { Restaurant } from '../restaurants/entities/restaurant.entity'; import { Order } from '../orders/entities/order.entity'; +import { ReservationStatus } from './inteface/reservation'; @Injectable() export class InventoryService { @@ -136,7 +137,7 @@ export class InventoryService { return results; } - async bulkReserveFood( + async tempBulkReserveFood( restaurantId: string, orderId: string, bulkReserveFoodDto: BulkReserveFoodDto, @@ -205,6 +206,7 @@ export class InventoryService { order, quantity: item.quantity, expiresAt: item.expiresAt, + status: ReservationStatus.ACTIVE, }); reservations.push(reservation); @@ -218,4 +220,16 @@ export class InventoryService { return reservations; } + + async confirmReservationByOrderId(orderId: string): Promise { + const reservations = await this.em.find(Reservation, { order: { id: orderId } }); + if (!reservations) { + throw new NotFoundException(`Reservations with order ID ${orderId} not found`); + } + for (const reservation of reservations) { + reservation.status = ReservationStatus.CONFIRMED; + } + await this.em.flush(); + return reservations; + } }