This commit is contained in:
Roba Boru
2026-07-20 00:19:31 +03:00
5 changed files with 582 additions and 196 deletions

View File

@@ -18,12 +18,11 @@
* parseEthiopianTime('2026-06-15') // Treats as midnight EAT
*/
export function parseEthiopianTime(dateInput: string | Date): Date {
if (dateInput instanceof Date) {
return dateInput;
}
// Parse as local time (EAT) since TZ is set to Africa/Addis_Ababa
return new Date(dateInput);
if (dateInput instanceof Date) return dateInput;
// Already has timezone info (Z or +HH:MM) — parse directly as UTC
if (/Z$|[+-]\d{2}:\d{2}$/.test(dateInput)) return new Date(dateInput);
// Bare local string (e.g. "2026-07-23T21:00") — treat explicitly as EAT (UTC+3)
return new Date(dateInput + '+03:00');
}
/**

View File

@@ -447,7 +447,7 @@ export class ReportsService {
_count: { select: { seats: true } },
},
},
seat: { include: { coach: { select: { number: true, coachType: { select: { name: true } } } } } },
seat: { select: { seatNumber: true, bedPosition: true, coach: { select: { number: true, coachType: { select: { name: true, seatClasses: { select: { name: true, bedPosition: true } } } } } } } },
},
orderBy: [{ seat: { coach: { number: "asc" } } }, { seat: { seatNumber: "asc" } }],
});
@@ -474,13 +474,25 @@ export class ReportsService {
passportNumber: bs.passportNumber,
passportCountry: bs.passportCountry,
seatLabel: bs.seatLabelSnapshot,
seatNumber: bs.seat?.seatNumber ?? null,
seatClassName: (() => {
const classes = bs.seat?.coach?.coachType?.seatClasses ?? [];
const matched = bs.seat?.bedPosition
? classes.find((sc: any) => sc.bedPosition?.toLowerCase() === bs.seat!.bedPosition!.toLowerCase())
: null;
return (matched ?? classes[0])?.name ?? bs.seat?.coach?.coachType?.name ?? null;
})(),
coachNumber: bs.seat?.coach?.number ?? null,
coachType: (bs.seat?.coach as any)?.coachType?.name ?? null,
coachType: bs.seat?.coach?.coachType?.name ?? null,
nationality: bs.passportCountry
? (bs.passportCountry === 'Djibouti' ? 'Djiboutian' : bs.passportCountry)
: bs.idDocumentType === 'NATIONAL_ID' ? 'Ethiopian' : null,
origin: bs.booking.originStationId ? (stationName.get(bs.booking.originStationId) ?? null) : null,
destination: bs.booking.destinationStationId ? (stationName.get(bs.booking.destinationStationId) ?? null) : null,
amountPaidMinor: bs.booking.totalMinor,
currency: bs.booking.currency ?? 'ETB',
isGroupBooking: (bs.booking._count?.seats ?? 0) > 1,
bookingStatus: bs.booking.status,
}));
}

File diff suppressed because it is too large Load Diff