mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 13:28:11 +00:00
update joins in repository services to use entity classes and enhance booking form with hazardous/reefer toggles
This commit is contained in:
@@ -21,6 +21,14 @@ export class CreateCargoTypeDto {
|
||||
@IsUUID()
|
||||
parentGroupId?: string;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'Wagon type used to carry this (bulk) cargo. Drives train scheduling wagon-type resolution; required for bulk commodities that are scheduled.',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsUUID('4')
|
||||
wagonTypeId?: string | null;
|
||||
|
||||
@ApiPropertyOptional({ default: false })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
|
||||
@@ -30,6 +30,14 @@ export class CreateContainerTypeDto {
|
||||
@IsBoolean()
|
||||
isOpenTop?: boolean;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description:
|
||||
'Wagon type used to carry this container. Drives train scheduling wagon-type resolution; required when this container type is scheduled.',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsUUID('4')
|
||||
wagonTypeId?: string | null;
|
||||
|
||||
@ApiPropertyOptional({ default: true })
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { BaseEntity } from '@edr/api-common';
|
||||
import { CargoUnitOfMeasure } from '@edr/types';
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { WagonType } from '../../wagon-types/entities/wagon-type.entity';
|
||||
|
||||
@Entity({ schema: 'freight', name: 'cargo_types' })
|
||||
@Index(['isActive'])
|
||||
@Index(['displayOrder'])
|
||||
@Index(['parentGroupId'])
|
||||
@Index(['wagonTypeId'])
|
||||
@Index(['code'])
|
||||
export class CargoType extends BaseEntity {
|
||||
@Column({ name: 'code', type: 'varchar', length: 50, unique: true, default: '' })
|
||||
@@ -25,6 +27,19 @@ export class CargoType extends BaseEntity {
|
||||
@Column({ name: 'unit_of_measure', type: 'varchar', length: 16, nullable: true })
|
||||
unitOfMeasure?: CargoUnitOfMeasure | null;
|
||||
|
||||
/**
|
||||
* Wagon type that carries this (bulk) cargo. Replaces the former hardcoded
|
||||
* cargo-code → wagon-code map: train scheduling resolves the bulk wagon type
|
||||
* through this FK. Nullable — grouping rows and container/legacy cargo never
|
||||
* carry it; scheduling throws if a scheduled bulk cargo type leaves it unset.
|
||||
*/
|
||||
@Column({ name: 'wagon_type_id', type: 'uuid', nullable: true })
|
||||
wagonTypeId?: string | null;
|
||||
|
||||
@ManyToOne(() => WagonType, { nullable: true, onDelete: 'RESTRICT' })
|
||||
@JoinColumn({ name: 'wagon_type_id' })
|
||||
wagonType?: WagonType | null;
|
||||
|
||||
@Column({ name: 'requires_director_approval', type: 'boolean', default: false })
|
||||
requiresDirectorApproval!: boolean;
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { BaseEntity } from '@edr/api-common';
|
||||
import { Column, Entity, Index, OneToMany } from 'typeorm';
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne, OneToMany } from 'typeorm';
|
||||
import { WeightLimitRule } from './weight-limit-rule.entity';
|
||||
import { WagonType } from '../../wagon-types/entities/wagon-type.entity';
|
||||
|
||||
@Entity({ schema: 'freight', name: 'container_types' })
|
||||
@Index(['code'])
|
||||
@Index(['isActive'])
|
||||
@Index(['wagonTypeId'])
|
||||
export class ContainerType extends BaseEntity {
|
||||
@Column({ name: 'code', type: 'varchar', length: 20, unique: true })
|
||||
code!: string;
|
||||
@@ -24,6 +26,19 @@ export class ContainerType extends BaseEntity {
|
||||
@Column({ name: 'is_open_top', type: 'boolean', default: false, nullable: true })
|
||||
isOpenTop!: boolean;
|
||||
|
||||
/**
|
||||
* Wagon type that carries this container. Replaces the former hardcoded
|
||||
* container wagon-code default (NW5): train scheduling resolves the container
|
||||
* wagon type through this FK. Nullable; scheduling throws if a scheduled
|
||||
* container type leaves it unset.
|
||||
*/
|
||||
@Column({ name: 'wagon_type_id', type: 'uuid', nullable: true })
|
||||
wagonTypeId?: string | null;
|
||||
|
||||
@ManyToOne(() => WagonType, { nullable: true, onDelete: 'RESTRICT' })
|
||||
@JoinColumn({ name: 'wagon_type_id' })
|
||||
wagonType?: WagonType | null;
|
||||
|
||||
@Column({ name: 'is_active', type: 'boolean', default: true })
|
||||
isActive!: boolean;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ export class CargoTypesRepository implements ICargoTypesRepository {
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<CargoType>): Promise<CargoType | null> {
|
||||
await this.repo.update(id, data);
|
||||
await this.repo.update(id, data as never);
|
||||
return this.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ export class ContainerTypesRepository implements IContainerTypesRepository {
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<ContainerType>): Promise<ContainerType | null> {
|
||||
await this.repo.update(id, data);
|
||||
await this.repo.update(id, data as never);
|
||||
return this.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ export class RatesRepository implements IRatesRepository {
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<Rate>): Promise<Rate | null> {
|
||||
await this.repo.update(id, data);
|
||||
await this.repo.update(id, data as never);
|
||||
return this.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ export class WeightLimitRulesRepository implements IWeightLimitRulesRepository {
|
||||
}
|
||||
|
||||
async update(id: string, data: Partial<WeightLimitRule>): Promise<WeightLimitRule | null> {
|
||||
await this.repo.update(id, data);
|
||||
await this.repo.update(id, data as never);
|
||||
return this.findById(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ export class CargoTypesService {
|
||||
requiresDirectorApproval: dto.requiresDirectorApproval ?? false,
|
||||
isActive: dto.isActive ?? true,
|
||||
unitOfMeasure: dto.unitOfMeasure ?? null,
|
||||
wagonTypeId: dto.wagonTypeId ?? null,
|
||||
displayOrder,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ export class ContainerTypesService {
|
||||
isReefer: dto.isReefer ?? false,
|
||||
isOpenTop: dto.isOpenTop ?? false,
|
||||
isActive: dto.isActive ?? true,
|
||||
wagonTypeId: dto.wagonTypeId ?? null,
|
||||
displayOrder,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user