up
This commit is contained in:
@@ -8,6 +8,7 @@ import { Reservation } from './entities/reservation.entity';
|
|||||||
import { Food } from '../foods/entities/food.entity';
|
import { Food } from '../foods/entities/food.entity';
|
||||||
import { Restaurant } from '../restaurants/entities/restaurant.entity';
|
import { Restaurant } from '../restaurants/entities/restaurant.entity';
|
||||||
import { Order } from '../orders/entities/order.entity';
|
import { Order } from '../orders/entities/order.entity';
|
||||||
|
import { ReservationStatus } from './inteface/reservation';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class InventoryService {
|
export class InventoryService {
|
||||||
@@ -136,7 +137,7 @@ export class InventoryService {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
async bulkReserveFood(
|
async tempBulkReserveFood(
|
||||||
restaurantId: string,
|
restaurantId: string,
|
||||||
orderId: string,
|
orderId: string,
|
||||||
bulkReserveFoodDto: BulkReserveFoodDto,
|
bulkReserveFoodDto: BulkReserveFoodDto,
|
||||||
@@ -205,6 +206,7 @@ export class InventoryService {
|
|||||||
order,
|
order,
|
||||||
quantity: item.quantity,
|
quantity: item.quantity,
|
||||||
expiresAt: item.expiresAt,
|
expiresAt: item.expiresAt,
|
||||||
|
status: ReservationStatus.ACTIVE,
|
||||||
});
|
});
|
||||||
|
|
||||||
reservations.push(reservation);
|
reservations.push(reservation);
|
||||||
@@ -218,4 +220,16 @@ export class InventoryService {
|
|||||||
|
|
||||||
return reservations;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user