From 7e670ab5bbc26eccbfd9597e6c97f02c0b769cb7 Mon Sep 17 00:00:00 2001 From: Stephanos A Date: Wed, 22 Jul 2026 07:15:49 +0300 Subject: [PATCH] Passenger and seats reports updates --- .../src/modules/reports/reports.service.ts | 30 +- booking-checker.html | 530 ------------------ booking-extractor.html | 256 --------- booking-proxy.mjs | 53 -- ticket-extractor.html | 239 -------- 5 files changed, 19 insertions(+), 1089 deletions(-) delete mode 100644 booking-checker.html delete mode 100644 booking-extractor.html delete mode 100644 booking-proxy.mjs delete mode 100644 ticket-extractor.html 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 @@ - - - - - - EDR Booking Checker - - - - -

EDR Booking Checker

- -
- - -

No trailing slash. e.g. https://api.edrsc.com

-
- -
- - -

Supports any format: one per line, comma-separated, or {REF1,REF2} groups.

- -
- - - - -
-
-
-
-
- -
-
- -
- - - - - -
-
- - - - - - - -
- -
- - - - - - - - -
JourneyDuplicate Bookings
-
-
- - - - - diff --git a/booking-extractor.html b/booking-extractor.html deleted file mode 100644 index 844c98b2c..000000000 --- a/booking-extractor.html +++ /dev/null @@ -1,256 +0,0 @@ - - - - - - EDR Booking Extractor - - - - -

EDR Booking Extractor

- -
- -
- - Drop bookings.json here or click to browse -
-

Accepts a JSON array of bookings or an object with a bookings key.

-
- - - -
-
- -
-
-
- - - -
-
- - - - - - - - - - - - - - - - - - - - - -
#Booking RefStatusBooking TypePhoneEmailDepartureOriginDestinationPassenger(s)Coach - SeatPayment MethodPayment StatusTotal (DJF)Created At
-
-
- - - - - diff --git a/booking-proxy.mjs b/booking-proxy.mjs deleted file mode 100644 index 27f9248ee..000000000 --- a/booking-proxy.mjs +++ /dev/null @@ -1,53 +0,0 @@ -import http from 'http'; -import https from 'https'; -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; - -const PORT = 8080; -const __dir = path.dirname(fileURLToPath(import.meta.url)); - -const server = http.createServer((req, res) => { - res.setHeader('Access-Control-Allow-Origin', '*'); - res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); - - if (req.method === 'OPTIONS') { res.writeHead(204); res.end(); return; } - - // Serve any .html file in the same directory - if (req.url === '/' || req.url.endsWith('.html')) { - const filename = req.url === '/' ? 'booking-checker.html' : req.url.slice(1); - const filepath = path.join(__dir, filename); - if (fs.existsSync(filepath)) { - res.writeHead(200, { 'Content-Type': 'text/html' }); - fs.createReadStream(filepath).pipe(res); - } else { - res.writeHead(404); res.end('Not found'); - } - return; - } - - // Proxy /proxy?url= - if (req.url.startsWith('/proxy?url=')) { - const target = decodeURIComponent(req.url.slice('/proxy?url='.length)); - const parsed = new URL(target); - const mod = parsed.protocol === 'https:' ? https : http; - const options = { - hostname: parsed.hostname, - port: parsed.port || (parsed.protocol === 'https:' ? 443 : 80), - path: parsed.pathname + parsed.search, - method: req.method, - headers: { ...req.headers, host: parsed.hostname }, - }; - const proxy = mod.request(options, (apiRes) => { - res.writeHead(apiRes.statusCode, apiRes.headers); - apiRes.pipe(res); - }); - proxy.on('error', (e) => { res.writeHead(502); res.end(e.message); }); - req.pipe(proxy); - return; - } - - res.writeHead(404); res.end(); -}); - -server.listen(PORT, () => console.log(`Booking checker: http://localhost:${PORT}/booking-checker.html`)); diff --git a/ticket-extractor.html b/ticket-extractor.html deleted file mode 100644 index 17be60576..000000000 --- a/ticket-extractor.html +++ /dev/null @@ -1,239 +0,0 @@ - - - - - - EDR Ticket Extractor - - - - -

EDR Ticket Extractor

- -
- -
- - Drop tickets.json here or click to browse -
-

Accepts a JSON array of tickets or an object with a tickets key.

-
- - - -
-
- -
-
-
- - - - - - - - - - - - - - - - - - -
#Ticket No.Booking RefPassengerPhoneEmailJourney TypeOriginDestinationSeat ClassCoachSeat
-
-
- - - - -