Files
edr-platform/apps/edr-passenger-api/src/modules/reschedule/reschedule.dto.ts

78 lines
2.7 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
ArrayMinSize,
IsArray,
IsBoolean,
IsInt,
IsOptional,
IsString,
Max,
Min,
} from 'class-validator';
export class UpdateReschedulePolicyDto {
@ApiPropertyOptional({ example: 30, description: '% of the leg fare charged as a change fee' })
@IsOptional() @Type(() => Number) @IsInt() @Min(0) @Max(100)
feePercent?: number;
@ApiPropertyOptional({ example: 50000, description: 'Fee floor in ETB minor units (500 ETB = 50000)' })
@IsOptional() @Type(() => Number) @IsInt() @Min(0)
feeMinMinor?: number;
@ApiPropertyOptional({ example: false })
@IsOptional() @IsBoolean()
routeChangeAllowed?: boolean;
@ApiPropertyOptional({ example: false })
@IsOptional() @IsBoolean()
sameDayAllowed?: boolean;
@ApiPropertyOptional({ example: 15, description: 'Same-day change: % of the leg fare (replaces feePercent)' })
@IsOptional() @Type(() => Number) @IsInt() @Min(0) @Max(100)
sameDayFeePercent?: number;
@ApiPropertyOptional({ example: 25000, description: 'Same-day change: fee floor in ETB minor units' })
@IsOptional() @Type(() => Number) @IsInt() @Min(0)
sameDayFeeMinMinor?: number;
@ApiPropertyOptional({ example: 120, description: 'Changes are refused this many minutes before departure' })
@IsOptional() @Type(() => Number) @IsInt() @Min(0)
cutoffMinutes?: number;
@ApiPropertyOptional({ example: true })
@IsOptional() @IsBoolean()
isActive?: boolean;
}
/** Same fields as the update DTO, plus the fare class the new policy attaches to. */
export class CreateReschedulePolicyDto extends UpdateReschedulePolicyDto {
@ApiProperty({ example: 'coach-type-uuid', description: 'CoachType the policy applies to (one policy per fare class)' })
@IsString()
coachTypeId: string;
}
export class RescheduleQuoteDto {
@ApiPropertyOptional({ example: 1, description: '1 = outbound (default), 2 = return leg of a round trip' })
@IsOptional() @Type(() => Number) @IsInt() @Min(1) @Max(2)
leg?: number;
@ApiProperty({ example: 'schedule-uuid' })
@IsString() newScheduleId: string;
@ApiProperty({ example: 'station-uuid' })
@IsString() newOriginStationId: string;
@ApiProperty({ example: 'station-uuid' })
@IsString() newDestinationStationId: string;
@ApiProperty({ type: [String], description: 'One seat per seated passenger of the leg, in BookingSeat order' })
@IsArray() @ArrayMinSize(1) @IsString({ each: true })
newSeatIds: string[];
}
export class CreateRescheduleDto extends RescheduleQuoteDto {
@ApiProperty({ example: 'hold-uuid', description: 'SeatHold on the new schedule covering newSeatIds (POST /seats/hold)' })
@IsString() holdId: string;
}