import { ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsInt, IsNumber, IsOptional, Max, Min } from 'class-validator'; export class UpdateTrainSchedulingGlobalRulesDto { @ApiPropertyOptional({ example: 53 }) @IsOptional() @Type(() => Number) @IsInt() @Min(1) maxWagonsPerTrain?: number; @ApiPropertyOptional({ example: 3, description: 'Days before departure the import booking-window day falls on' }) @IsOptional() @Type(() => Number) @IsInt() @Min(0) importWindowLeadDays?: number; @ApiPropertyOptional({ example: 24, description: 'Hours before departure an export booking becomes acceptable' }) @IsOptional() @Type(() => Number) @IsInt() @Min(1) exportBookingLeadHours?: number; @ApiPropertyOptional({ example: 8, description: 'Local EAT hour the import window opens each day' }) @IsOptional() @Type(() => Number) @IsInt() @Min(0) @Max(23) windowOpenHour?: number; @ApiPropertyOptional({ example: 17, description: 'Local EAT hour the booking desk shuts each day; a not-yet-full window resumes next morning at windowOpenHour. Equal to windowOpenHour = 24-hour desk', }) @IsOptional() @Type(() => Number) @IsInt() @Min(0) @Max(23) windowCloseHour?: number; // Stored in hours. The UI enters this in minutes/hours/days and converts to // hours before sending, so the floor is 1 minute (0.0166h) — not 15 min. @ApiPropertyOptional({ example: 3 }) @IsOptional() @Type(() => Number) @IsNumber() @Min(0.0166) @Max(12) windowDurationHours?: number; @ApiPropertyOptional({ example: 30 }) @IsOptional() @Type(() => Number) @IsInt() @Min(0) docReviewMinutes?: number; @ApiPropertyOptional({ example: 60 }) @IsOptional() @Type(() => Number) @IsInt() @Min(1) paymentWindowMinutes?: number; // Booking-close offsets: minutes before departure the window shuts. The UI // enters days/hours/minutes and converts to minutes. 0 or null clears the // offset (close at departure). Nullable so it can be explicitly cleared. @ApiPropertyOptional({ example: 180, nullable: true, description: 'Minutes before departure the IMPORT booking window closes; 0/null = close at departure', }) @IsOptional() @Type(() => Number) @IsInt() @Min(0) importCloseOffsetMinutes?: number | null; @ApiPropertyOptional({ example: 1440, nullable: true, description: 'Minutes before departure the EXPORT booking window closes; 0/null = close at departure', }) @IsOptional() @Type(() => Number) @IsInt() @Min(0) exportCloseOffsetMinutes?: number | null; }