diff --git a/apps/edr-passenger-api/src/modules/reports/reports.service.ts b/apps/edr-passenger-api/src/modules/reports/reports.service.ts index bd70a0a92..2d41c6bda 100644 --- a/apps/edr-passenger-api/src/modules/reports/reports.service.ts +++ b/apps/edr-passenger-api/src/modules/reports/reports.service.ts @@ -272,13 +272,17 @@ export class ReportsService { if (!schedule) return null; - // Fetch booking seats directly by scheduleId — avoids deserializing legacy - // BookingSeat rows with null scheduleId that crash Prisma when loaded via relation. + // Fetch booking seats for this schedule — covers: + // • outbound seats (leg=1, scheduleId=scheduleId) + // • return seats (leg=2, booking.returnScheduleId=scheduleId) + // • legacy rows where scheduleId is null but booking.scheduleId matches const allBookingSeats = await this.prisma.bookingSeat.findMany({ where: { - scheduleId, - leg: 1, - booking: { status: { in: ['CONFIRMED', 'BOARDED'] } }, + OR: [ + { scheduleId, booking: { status: { in: ['CONFIRMED', 'BOARDED'] } } }, + { leg: 2, booking: { returnScheduleId: scheduleId, status: { in: ['CONFIRMED', 'BOARDED'] } } }, + { scheduleId: null, leg: 1, booking: { scheduleId, status: { in: ['CONFIRMED', 'BOARDED'] } } }, + ], }, select: { bookingId: true, @@ -379,9 +383,11 @@ export class ReportsService { async getPassengerList(scheduleId: string) { const seats = await this.prisma.bookingSeat.findMany({ where: { - scheduleId, - leg: 1, - booking: { status: { in: ["CONFIRMED", "BOARDED"] } }, + OR: [ + { scheduleId, booking: { status: { in: ['CONFIRMED', 'BOARDED'] } } }, + { leg: 2, booking: { returnScheduleId: scheduleId, status: { in: ['CONFIRMED', 'BOARDED'] } } }, + { scheduleId: null, leg: 1, booking: { scheduleId, status: { in: ['CONFIRMED', 'BOARDED'] } } }, + ], }, include: { booking: { @@ -448,9 +454,11 @@ export class ReportsService { // Confirmed/boarded seats — exclude dining coaches const bookingSeats = await this.prisma.bookingSeat.findMany({ where: { - scheduleId, - leg: 1, - booking: { status: { in: ['CONFIRMED', 'BOARDED', 'PENDING_PAYMENT'] } }, + OR: [ + { scheduleId, booking: { status: { in: ['CONFIRMED', 'BOARDED', 'PENDING_PAYMENT'] } } }, + { leg: 2, booking: { returnScheduleId: scheduleId, status: { in: ['CONFIRMED', 'BOARDED', 'PENDING_PAYMENT'] } } }, + { scheduleId: null, leg: 1, booking: { scheduleId, status: { in: ['CONFIRMED', 'BOARDED', 'PENDING_PAYMENT'] } } }, + ], seat: { coach: { coachType: { type: { not: 'dining' } } } }, }, include: { diff --git a/booking-checker.html b/booking-checker.html deleted file mode 100644 index 9d2b7ded4..000000000 --- a/booking-checker.html +++ /dev/null @@ -1,530 +0,0 @@ - - -
- - -No trailing slash. e.g. https://api.edrsc.com
-Supports any format: one per line, comma-separated, or {REF1,REF2} groups.
| Journey | -Duplicate Bookings | -
|---|
bookings.json here or click to browse
- Accepts a JSON array of bookings or an object with a bookings key.
| # | -Booking Ref | -Status | -Booking Type | -Phone | -Departure | -Origin | -Destination | -Passenger(s) | -Coach - Seat | -Payment Method | -Payment Status | -Total (DJF) | -Created At | -
|---|
tickets.json here or click to browse
- Accepts a JSON array of tickets or an object with a tickets key.
| # | -Ticket No. | -Booking Ref | -Passenger | -Phone | -Journey Type | -Origin | -Destination | -Seat Class | -Coach | -Seat | -
|---|