Files
edr-platform/apps/edr-freight-api/src/modules/train-scheduling/dto/assign-bookings.dto.ts
Marshal eb819d66a1 Enhance wagon capacity handling and validation in booking service
- Added default capacities for container and bulk wagons.
- Updated wagonsFor method to consider weight and length for wagon calculations.
- Improved handling of overweight bookings with appropriate warnings.
- Adjusted tests to reflect changes in wagon capacity and validation logic.
2026-07-09 13:10:32 +00:00

87 lines
1.8 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
ArrayMinSize,
IsArray,
IsBoolean,
IsInt,
IsNumber,
IsOptional,
IsString,
IsUUID,
Min,
ValidateNested,
} from 'class-validator';
export class ContainerPlacementDto {
@ApiProperty({ format: 'uuid' })
@IsUUID()
bookingContainerId!: string;
@ApiProperty({ minimum: 0 })
@IsInt()
@Min(0)
unitIndex!: number;
@ApiProperty({ minimum: 1 })
@IsInt()
@Min(1)
sequenceNo!: number;
@ApiPropertyOptional({ format: 'uuid' })
@IsOptional()
@IsUUID()
containerId?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
containerNumber?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
sealNumber?: string;
}
export class AssignBookingsDto {
@ApiProperty({ type: [String] })
@IsArray()
@ArrayMinSize(1)
@IsUUID('4', { each: true })
bookingIds!: string[];
@ApiPropertyOptional({ description: 'Suppress soft hold and overweight warnings' })
@IsOptional()
@IsBoolean()
forceAssign?: boolean;
@ApiPropertyOptional({ type: [ContainerPlacementDto] })
@IsOptional()
@IsArray()
@ValidateNested({ each: true })
@Type(() => ContainerPlacementDto)
containerPlacements?: ContainerPlacementDto[];
@ApiPropertyOptional({ description: 'Maximum total booking weight allowed on this train' })
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(1)
maxTrainWeightTons?: number;
@ApiPropertyOptional({ description: 'Maximum total wagon length allowed on this train' })
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(1)
maxTrainLengthMeters?: number;
@ApiPropertyOptional({ description: 'Maximum wagons allowed on this train' })
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
maxWagonsPerTrain?: number;
}