cash shift

This commit is contained in:
2026-07-14 12:57:30 +03:30
parent f2da078c5a
commit 59e958e809
16 changed files with 627 additions and 5 deletions
@@ -29,6 +29,7 @@ import { AdminCreateOrderDto } from '../dto/admin-create-order.dto';
import { AdminUpdateOrderFeesDto } from '../dto/admin-update-order-fees.dto';
import { FoodOrderReportDto, FoodOrderReportSortBy } from '../dto/food-order-report.dto';
import { DailyOrderReportDto, DailyOrderReportSortBy } from '../dto/daily-order-report.dto';
import { CashShiftsService } from './cash-shifts.service';
type OrderItemData = { food: Food; quantity: number; unitPrice: number; discount: number };
type ValidatedCartForOrder = {
@@ -63,6 +64,7 @@ export class OrdersService {
private readonly paymentsService: PaymentsService,
private readonly inventoryService: InventoryService,
private readonly eventEmitter: EventEmitter2,
private readonly cashShiftsService: CashShiftsService,
) { }
async checkout(userId: string, restaurantId: string) {
@@ -133,6 +135,7 @@ export class OrdersService {
})),
};
await this.inventoryService.deductFromInventory(em, bulkReserveFoodDto);
await this.cashShiftsService.assignOrderToOpenShift(order, em);
await em.flush();
this.logger.debug(`Order ${order.id} created for user ${userId} (restaurant ${restaurantId})`);
return order;
@@ -230,6 +233,7 @@ export class OrdersService {
items: orderItemsData.map(item => ({ foodId: item.food.id, quantity: item.quantity })),
};
await this.inventoryService.deductFromInventory(em, bulkReserveFoodDto);
await this.cashShiftsService.assignOrderToOpenShift(order, em);
await em.flush();
this.logger.debug(`Admin created order ${order.id} for user ${user?.id || 'anonymous'} (restaurant: ${restaurantId})`);
@@ -347,6 +351,7 @@ export class OrdersService {
orderBy: dto.orderBy,
order: dto.order,
excludeOnlinePendingPayment: true,
cashShiftId: dto.cashShiftId,
});
return result;
@@ -363,6 +368,7 @@ export class OrdersService {
'userAddress',
'carAddress',
'paymentMethod',
'cashShift',
'payments',
'items',
'items.food',