feat(freight): offer built-train wagons per boarding yard on multi-yard consists

This commit is contained in:
Marshal
2026-08-18 08:27:18 +00:00
parent 1ca7776143
commit c723b660e2
33 changed files with 1234 additions and 231 deletions

View File

@@ -342,8 +342,8 @@ export class WagonsService {
async assignToTrain(wagonId: string, dto: AssignWagonToTrainDto): Promise<Wagon> {
const wagon = await this.findById(wagonId);
// Mirror train-builder attachWagons: only a truly free, available wagon in
// the train's own yard can be coupled, and never onto a dispatched train.
// Mirror train-builder attachWagons: only a truly free, available wagon
// (any yard) can be coupled, and never onto a dispatched train.
if (wagon.trainId != null) {
throw new ConflictException(`Wagon ${wagon.wagonNumber} is already on another train`);
}
@@ -358,11 +358,6 @@ export class WagonsService {
`Train ${train.code} is out on a dispatched run; its composition is frozen until arrival`,
);
}
if (wagon.currentYardId !== train.currentYardId) {
throw new BadRequestException(
`Wagon ${wagon.wagonNumber} is not in the train's yard; only wagons in the same yard can be attached`,
);
}
const maxSeq = await this.wagonRepo
.createQueryBuilder('w')