Passengers report updates

This commit is contained in:
Stephanos A
2026-07-18 18:21:15 +03:00
parent aac162ca3c
commit 3fc36b358f
3 changed files with 282 additions and 157 deletions

View File

@@ -24,6 +24,12 @@ export class ReportsController {
return this.service.listSchedulesForPicker();
}
@Get('passengers/list')
@ApiOperation({ summary: 'Flat passenger list for a specific schedule' })
getPassengerList(@Query('scheduleId') scheduleId: string) {
return this.service.getPassengerList(scheduleId);
}
@Get('passengers')
@ApiOperation({ summary: 'Passengers report for a specific schedule' })
getOccupancyReport(@Query('scheduleId') scheduleId: string) {

View File

@@ -286,6 +286,35 @@ export class ReportsService {
};
}
async getPassengerList(scheduleId: string) {
const seats = await this.prisma.bookingSeat.findMany({
where: {
scheduleId,
booking: { status: { in: ['CONFIRMED', 'BOARDED'] } },
},
include: {
booking: { select: { bookingRef: true, status: true, originStationId: true, destinationStationId: true } },
seat: { include: { coach: { select: { number: true, coachType: { select: { name: true } } } } } },
},
orderBy: [{ seat: { coach: { number: 'asc' } } }],
});
return seats.map(bs => ({
bookingRef: bs.booking.bookingRef,
bookingStatus: bs.booking.status,
passengerName: bs.passengerName,
dateOfBirth: bs.dateOfBirth,
passengerCategory: bs.passengerCategory,
idDocumentType: bs.idDocumentType,
idDocumentNumber: bs.idDocumentNumber,
passportNumber: bs.passportNumber,
passportCountry: bs.passportCountry,
seatLabel: bs.seatLabelSnapshot,
coachNumber: bs.seat?.coach?.number ?? null,
coachType: (bs.seat?.coach as any)?.coachType?.name ?? null,
}));
}
async listSchedulesForPicker() {
const schedules = await this.prisma.trainSchedule.findMany({
select: {