Passengers list report updates

This commit is contained in:
Stephanos A
2026-07-21 14:06:46 +03:00
parent 7f65bf1409
commit 79629d1819
3 changed files with 47 additions and 109 deletions

View File

@@ -18,10 +18,10 @@ export class ReportsController {
return this.service.generateReport(dto);
}
@Get("schedules")
@ApiOperation({ summary: "List schedules for the passengers report picker" })
listSchedulesForPicker() {
return this.service.listSchedulesForPicker();
@Get('schedules')
@ApiOperation({ summary: 'List schedules for the passengers report picker' })
listSchedulesForPicker(@Query('all') all?: string) {
return this.service.listSchedulesForPicker(all === 'true');
}
@Get("passengers/list")

View File

@@ -411,10 +411,10 @@ export class ReportsService {
};
}
async listSchedulesForPicker() {
async listSchedulesForPicker(all = false) {
const now = new Date();
const schedules = await this.prisma.trainSchedule.findMany({
where: { departureAt: { gte: now } },
where: all ? undefined : { departureAt: { gte: now } },
select: {
id: true,
departureAt: true,
@@ -423,7 +423,7 @@ export class ReportsService {
originStation: { select: { name: true } },
destinationStation: { select: { name: true } },
},
orderBy: { departureAt: 'asc' },
orderBy: { departureAt: all ? 'desc' : 'asc' },
take: 200,
});
return schedules.map((s) => ({
@@ -439,8 +439,9 @@ export class ReportsService {
async getPassengerList(scheduleId: string) {
const seats = await this.prisma.bookingSeat.findMany({
where: {
scheduleId,
leg: 1,
booking: { scheduleId, status: { in: ["CONFIRMED", "BOARDED"] } },
booking: { status: { in: ["CONFIRMED", "BOARDED"] } },
},
include: {
booking: {
@@ -507,8 +508,9 @@ export class ReportsService {
// Booked seats — exclude dining coaches
const bookingSeats = await this.prisma.bookingSeat.findMany({
where: {
scheduleId,
leg: 1,
booking: { scheduleId, status: { in: ['CONFIRMED', 'BOARDED', 'PENDING_PAYMENT'] } },
booking: { status: { in: ['CONFIRMED', 'BOARDED', 'PENDING_PAYMENT'] } },
seat: { coach: { coachType: { type: { not: 'dining' } } } },
},
include: {