mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 23:28:11 +00:00
Refactored the whole app based on the requirements shared
This commit is contained in:
@@ -11,7 +11,11 @@ export class SearchTripsDto {
|
||||
|
||||
export class FareQuoteDto {
|
||||
@ApiProperty() @IsString() tripId: string;
|
||||
@ApiProperty({ example: 'ECONOMY' }) @IsString() serviceClass: string;
|
||||
@ApiProperty({
|
||||
example: 'ECONOMY_REGULAR',
|
||||
enum: ['ECONOMY_REGULAR', 'ECONOMY_BED_LOWER', 'ECONOMY_BED_MIDDLE', 'ECONOMY_BED_UPPER', 'VIP_BED_LOWER', 'VIP_BED_UPPER']
|
||||
})
|
||||
@IsString() serviceClass: string;
|
||||
@ApiPropertyOptional({ example: 1 }) @IsOptional() @Type(() => Number) @IsInt() @Min(1) passengerCount?: number;
|
||||
@ApiPropertyOptional({ example: 'WEEKEND15' }) @IsOptional() @IsString() promoCode?: string;
|
||||
@ApiPropertyOptional({ example: 450 }) @IsOptional() @Type(() => Number) @IsInt() loyaltyRedemptionPoints?: number;
|
||||
|
||||
@@ -23,8 +23,22 @@ export class SearchService {
|
||||
origin: { id: trip.originStation.id, code: trip.originStation.code, name: trip.originStation.name, city: trip.originStation.city },
|
||||
destination: { id: trip.destinationStation.id, code: trip.destinationStation.code, name: trip.destinationStation.name, city: trip.destinationStation.city },
|
||||
departureAt: trip.departureAt, arrivalAt: trip.arrivalAt, status: trip.status,
|
||||
availability: { ECONOMY: avail('ECONOMY'), BUSINESS: avail('BUSINESS'), FIRST: avail('FIRST') },
|
||||
fares: { ECONOMY: this.defaultFare('ECONOMY') / 100, BUSINESS: this.defaultFare('BUSINESS') / 100, FIRST: this.defaultFare('FIRST') / 100 },
|
||||
availability: {
|
||||
ECONOMY_REGULAR: avail('ECONOMY_REGULAR'),
|
||||
ECONOMY_BED_LOWER: avail('ECONOMY_BED_LOWER'),
|
||||
ECONOMY_BED_MIDDLE: avail('ECONOMY_BED_MIDDLE'),
|
||||
ECONOMY_BED_UPPER: avail('ECONOMY_BED_UPPER'),
|
||||
VIP_BED_LOWER: avail('VIP_BED_LOWER'),
|
||||
VIP_BED_UPPER: avail('VIP_BED_UPPER')
|
||||
},
|
||||
fares: {
|
||||
ECONOMY_REGULAR: this.defaultFare('ECONOMY_REGULAR') / 100,
|
||||
ECONOMY_BED_LOWER: this.defaultFare('ECONOMY_BED_LOWER') / 100,
|
||||
ECONOMY_BED_MIDDLE: this.defaultFare('ECONOMY_BED_MIDDLE') / 100,
|
||||
ECONOMY_BED_UPPER: this.defaultFare('ECONOMY_BED_UPPER') / 100,
|
||||
VIP_BED_LOWER: this.defaultFare('VIP_BED_LOWER') / 100,
|
||||
VIP_BED_UPPER: this.defaultFare('VIP_BED_UPPER') / 100
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -45,6 +59,14 @@ export class SearchService {
|
||||
}
|
||||
|
||||
private defaultFare(serviceClass: string): number {
|
||||
return ({ ECONOMY: 45000, BUSINESS: 90000, FIRST: 135000 } as any)[serviceClass] ?? 45000;
|
||||
const fares: Record<string, number> = {
|
||||
ECONOMY_REGULAR: 35000, // 350 ETB
|
||||
ECONOMY_BED_LOWER: 55000, // 550 ETB
|
||||
ECONOMY_BED_MIDDLE: 50000, // 500 ETB
|
||||
ECONOMY_BED_UPPER: 45000, // 450 ETB
|
||||
VIP_BED_LOWER: 85000, // 850 ETB
|
||||
VIP_BED_UPPER: 80000 // 800 ETB
|
||||
};
|
||||
return fares[serviceClass] ?? 35000;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user