mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 23:00:57 +00:00
fix rate edit
This commit is contained in:
@@ -3,20 +3,6 @@ import { Type } from 'class-transformer';
|
||||
import { IsInt, IsNumber, IsOptional, Max, Min } from 'class-validator';
|
||||
|
||||
export class UpdateTrainSchedulingGlobalRulesDto {
|
||||
@ApiPropertyOptional({ example: 760 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
maxTrainLengthMeters?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: 3500 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(1)
|
||||
maxTrainWeightTons?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: 53 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@@ -24,20 +10,6 @@ export class UpdateTrainSchedulingGlobalRulesDto {
|
||||
@Min(1)
|
||||
maxWagonsPerTrain?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: 30 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(0.001)
|
||||
max20ftContainerWeightTons?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: 10 })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
max20ftPairWeightDiffTons?: number;
|
||||
|
||||
@ApiPropertyOptional({ example: 3, description: 'Days before departure the import booking-window day falls on' })
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
|
||||
@@ -600,7 +600,24 @@ export class TrainSchedulingService {
|
||||
}
|
||||
|
||||
async getTrainSchedulingGlobalRules() {
|
||||
return this.loadGlobalRulesRow();
|
||||
return this.toPublicGlobalRules(await this.loadGlobalRulesRow());
|
||||
}
|
||||
|
||||
/**
|
||||
* Train length/weight and 20ft weight caps are engine-internal (wagon
|
||||
* planning still reads them off the row); they are no longer exposed or
|
||||
* editable through the global-rules endpoints.
|
||||
*/
|
||||
private toPublicGlobalRules(row: TrainSchedulingGlobalRules | null) {
|
||||
if (!row) return row;
|
||||
const {
|
||||
maxTrainLengthMeters: _len,
|
||||
maxTrainWeightTons: _wt,
|
||||
max20ftContainerWeightTons: _cw,
|
||||
max20ftPairWeightDiffTons: _pd,
|
||||
...pub
|
||||
} = row;
|
||||
return pub;
|
||||
}
|
||||
|
||||
async updateTrainSchedulingGlobalRules(dto: UpdateTrainSchedulingGlobalRulesDto) {
|
||||
@@ -608,15 +625,7 @@ export class TrainSchedulingService {
|
||||
if (!row) {
|
||||
throw new NotFoundException('Train scheduling global rules not configured');
|
||||
}
|
||||
if (dto.maxTrainLengthMeters != null) row.maxTrainLengthMeters = dto.maxTrainLengthMeters;
|
||||
if (dto.maxTrainWeightTons != null) row.maxTrainWeightTons = dto.maxTrainWeightTons;
|
||||
if (dto.maxWagonsPerTrain != null) row.maxWagonsPerTrain = dto.maxWagonsPerTrain;
|
||||
if (dto.max20ftContainerWeightTons != null) {
|
||||
row.max20ftContainerWeightTons = dto.max20ftContainerWeightTons;
|
||||
}
|
||||
if (dto.max20ftPairWeightDiffTons != null) {
|
||||
row.max20ftPairWeightDiffTons = dto.max20ftPairWeightDiffTons;
|
||||
}
|
||||
if (dto.importWindowLeadDays != null) row.importWindowLeadDays = dto.importWindowLeadDays;
|
||||
if (dto.exportBookingLeadHours != null) row.exportBookingLeadHours = dto.exportBookingLeadHours;
|
||||
if (dto.windowOpenHour != null) row.windowOpenHour = dto.windowOpenHour;
|
||||
@@ -654,7 +663,7 @@ export class TrainSchedulingService {
|
||||
await this.restampPendingWindows();
|
||||
}
|
||||
|
||||
return saved;
|
||||
return this.toPublicGlobalRules(saved);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user