mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Passenger and seats reports updates
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user