Updated sms text

This commit is contained in:
Roba Boru
2026-07-14 09:03:10 +03:00
parent fe133e3d7f
commit 0e18df6ad9
3 changed files with 64 additions and 27 deletions

View File

@@ -386,7 +386,7 @@ export class TicketsService {
let booking = await this.prisma.booking.findUnique({
where: { bookingRef },
include: {
schedule: { include: { originStation: true, destinationStation: true, train: true } },
schedule: { include: { originStation: true, destinationStation: true, train: true, stopTimes: { include: { station: true } } } },
returnSchedule: { include: { originStation: true, destinationStation: true } },
tickets: true,
seats: { include: { seat: { include: { coach: true } } } },
@@ -400,7 +400,7 @@ export class TicketsService {
booking = await this.prisma.booking.findUnique({
where: { bookingRef: ticket.bookingRef },
include: {
schedule: { include: { originStation: true, destinationStation: true, train: true } },
schedule: { include: { originStation: true, destinationStation: true, train: true, stopTimes: { include: { station: true } } } },
returnSchedule: { include: { originStation: true, destinationStation: true } },
tickets: true,
seats: { include: { seat: { include: { coach: true } } } },
@@ -453,6 +453,18 @@ export class TicketsService {
// Send notifications after successful boarding
await this.sendBoardingNotifications(booking, ticket, result.leg || 'OUTBOUND');
// Resolve user-selected segment rather than the full schedule route
const _schedStops = (booking as any).schedule?.stopTimes ?? [];
const _resolveStation = (id: string | null | undefined, fallback: any) => {
if (id) {
const found = _schedStops.find((st: any) => st.stationId === id)?.station;
if (found) return found;
}
return fallback;
};
const boardingOrigin = _resolveStation((booking as any).originStationId, (booking as any).schedule?.originStation);
const boardingDest = _resolveStation((booking as any).destinationStationId, (booking as any).schedule?.destinationStation);
return {
success: true,
message: `Passenger boarded successfully (${result.leg || 'OUTBOUND'} leg)`,
@@ -461,7 +473,7 @@ export class TicketsService {
ticketNumber: ticket.barcodePayload,
bookingRef: booking.bookingRef,
passengerName: seatInfo?.passengerName || ticket.passengerName || 'N/A',
route: `${(booking as any).schedule?.originStation?.name || 'N/A'}${(booking as any).schedule?.destinationStation?.name || 'N/A'}`,
route: `${boardingOrigin?.name || 'N/A'}${boardingDest?.name || 'N/A'}`,
seat: seatNumber,
coach: coachNumber,
trainName: (booking as any).schedule?.train?.name || (booking as any).schedule?.train?.number || 'N/A',