This commit is contained in:
2025-12-15 09:11:00 +03:30
parent 0ac1b39100
commit 28f8fb01a2
+15 -1
View File
@@ -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<Reservation[]> {
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;
}
}