Merge remote changes: Add SeatClass model and seat-classes module while preserving local IAM integration and enhancements

This commit is contained in:
Stephanos A
2026-05-21 14:06:05 +03:00
21 changed files with 307 additions and 43 deletions

View File

@@ -92,7 +92,7 @@ export class BookingsService {
}
// Calculate fare with age-based pricing
const baseFareMinor = await this.getBaseFare(dto.tripId, dto.serviceClass);
const baseFareMinor = await this.getBaseFare(dto.tripId, dto.serviceClass, dto.seatClassId);
const adultFareMinor = baseFareMinor * adultCount;
const paidChildrenCount = Math.max(0, childCount - 1);
const childFareMinor = baseFareMinor * paidChildrenCount;
@@ -176,7 +176,13 @@ export class BookingsService {
};
}
private async getBaseFare(tripId: string, serviceClass: string): Promise<number> {
private async getBaseFare(tripId: string, serviceClass: string, seatClassId?: string): Promise<number> {
if (seatClassId) {
const fareRule = await this.prisma.fareRule.findFirst({
where: { tripId, seatClassId },
});
if (fareRule) return fareRule.baseFareMinor;
}
const fareRule = await this.prisma.fareRule.findFirst({
where: { tripId, serviceClass: serviceClass as any },
});
@@ -208,7 +214,7 @@ export class BookingsService {
fullName: bs.passengerName,
category: bs.passengerCategory,
verifaydaVerified: bs.verifaydaVerified,
seat: { number: bs.seat.label, coach: bs.seat.coach.label, class: bs.seat.coach.serviceClass },
seat: { number: bs.seat.label, coach: bs.seat.coach.label, class: bs.seat.coach.serviceClass, seatClassId: bs.seat.coach.seatClassId },
})),
payment: booking.paymentIntent ? { method: booking.paymentIntent.method, status: booking.paymentIntent.status } : undefined,
};