mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 08:25:43 +00:00
Coaches, seats, schedules, and pricing related updates
This commit is contained in:
@@ -70,17 +70,34 @@ enum Currency {
|
||||
@@schema("passenger")
|
||||
}
|
||||
|
||||
model SeatClass {
|
||||
model CoachType {
|
||||
id String @id @default(uuid())
|
||||
name String @unique
|
||||
description String?
|
||||
basePrice Int
|
||||
isActive Boolean @default(true)
|
||||
code String
|
||||
name String
|
||||
type String @default("passenger") // 'passenger', 'sleeper', 'dining', 'baggage'
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
coaches Coach[]
|
||||
seatClasses SeatClass[]
|
||||
|
||||
@@schema("passenger")
|
||||
}
|
||||
|
||||
model SeatClass {
|
||||
id String @id @default(uuid())
|
||||
coachTypeId String
|
||||
name String
|
||||
description String?
|
||||
baseFareMinor Int
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
coachType CoachType @relation(fields: [coachTypeId], references: [id])
|
||||
fareRules FareRule[]
|
||||
routeFareRules RouteFareRule[]
|
||||
segmentFares SegmentFareRule[]
|
||||
@@unique([coachTypeId, name])
|
||||
@@index([coachTypeId])
|
||||
|
||||
@@schema("passenger")
|
||||
}
|
||||
@@ -385,21 +402,17 @@ model TripLiveStatus {
|
||||
|
||||
model Coach {
|
||||
id String @id @default(uuid())
|
||||
coachNumber String @unique
|
||||
label String
|
||||
seatClassId String
|
||||
coachType String?
|
||||
mode String @default("seat") // 'seat', 'bed', 'convertible'
|
||||
seatArrangement String?
|
||||
bedArrangement String?
|
||||
amenities Json?
|
||||
totalUnits Int @default(0)
|
||||
isActive Boolean @default(true)
|
||||
coachTypeId String
|
||||
number String @unique
|
||||
arrangement String @default("2+2") // e.g., '2+2', '3+2', '2+2+2'
|
||||
capacity Int @default(0) // Total seats/beds
|
||||
status String @default("ACTIVE") // 'ACTIVE', 'MAINTENANCE', 'INACTIVE'
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
seatClass SeatClass @relation(fields: [seatClassId], references: [id])
|
||||
coachType CoachType @relation(fields: [coachTypeId], references: [id])
|
||||
seats Seat[]
|
||||
assignments CoachAssignment[]
|
||||
@@index([coachTypeId])
|
||||
|
||||
@@schema("passenger")
|
||||
}
|
||||
@@ -422,10 +435,9 @@ model CoachAssignment {
|
||||
model Seat {
|
||||
id String @id @default(uuid())
|
||||
coachId String
|
||||
seatNumber String // Auto-generated: e.g., '1', '2', '3' (unique per coach)
|
||||
row Int
|
||||
col String
|
||||
label String
|
||||
seatNumber String?
|
||||
kind SeatKind @default(STANDARD)
|
||||
status SeatStatus @default(AVAILABLE)
|
||||
heldUntil DateTime?
|
||||
@@ -433,13 +445,13 @@ model Seat {
|
||||
isAisle Boolean @default(false)
|
||||
bedPosition String? // 'lower', 'middle', 'upper'
|
||||
premiumFeeMinor Int @default(0)
|
||||
eligibility String?
|
||||
coach Coach @relation(fields: [coachId], references: [id])
|
||||
bookingSeats BookingSeat[]
|
||||
blocks SeatBlock[]
|
||||
ticketSeats TicketSeat[]
|
||||
@@unique([coachId, row, col])
|
||||
@@unique([coachId, seatNumber])
|
||||
@@unique([coachId, row, col])
|
||||
@@index([coachId])
|
||||
|
||||
@@schema("passenger")
|
||||
}
|
||||
@@ -978,6 +990,7 @@ model Route {
|
||||
createdAt DateTime @default(now())
|
||||
stops RouteStop[]
|
||||
fareRules RouteFareRule[]
|
||||
segmentFares SegmentFareRule[]
|
||||
schedules TrainSchedule[]
|
||||
|
||||
@@schema("passenger")
|
||||
@@ -1017,6 +1030,26 @@ model RouteFareRule {
|
||||
@@schema("passenger")
|
||||
}
|
||||
|
||||
model SegmentFareRule {
|
||||
id String @id @default(uuid())
|
||||
routeId String
|
||||
originStopSequence Int
|
||||
destinationStopSequence Int
|
||||
seatClassId String
|
||||
baseFareMinor Int
|
||||
nationality String? // Optional: Ethiopian, Djiboutian, Other
|
||||
currency String @default("ETB")
|
||||
validFrom DateTime
|
||||
validUntil DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
route Route @relation(fields: [routeId], references: [id], onDelete: Cascade)
|
||||
seatClass SeatClass @relation(fields: [seatClassId], references: [id])
|
||||
@@unique([routeId, originStopSequence, destinationStopSequence, seatClassId, nationality])
|
||||
@@index([routeId, seatClassId])
|
||||
|
||||
@@schema("passenger")
|
||||
}
|
||||
|
||||
model Agent {
|
||||
id String @id @default(uuid())
|
||||
userId String @unique
|
||||
|
||||
Reference in New Issue
Block a user