This commit is contained in:
Marshal
2026-07-17 13:57:59 +00:00
parent 3a697e12f2
commit 6467173c76
12 changed files with 642 additions and 46 deletions

View File

@@ -2,6 +2,7 @@ import { BaseEntity } from '@edr/api-common';
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
import { CargoType } from './cargo-type.entity';
import { ContainerType } from './container-type.entity';
import { Yard } from './yard.entity';
export const RATE_TYPES = [
'CONTAINER_IMPORT',
@@ -91,6 +92,8 @@ export type RateTrigger = typeof RATE_TRIGGERS[number];
@Index(['status'])
@Index(['containerTypeId'])
@Index(['trigger'])
@Index(['originYardId'])
@Index(['destinationYardId'])
export class Rate extends BaseEntity {
@Column({ name: 'rate_type', type: 'varchar', length: 50 })
rateType!: RateType;
@@ -118,6 +121,26 @@ export class Rate extends BaseEntity {
@Column({ name: 'trade_direction', type: 'varchar', length: 10, nullable: true })
tradeDirection?: string | null;
/**
* The leg this rate prices. Base freight (trigger = ALWAYS) is quoted per
* route — "container import, Djibouti → Dire Dawa" — so both yards are
* required for BULK/CONTAINER/INTERCITY and NULL for everything else. The
* `CK_rates_yard_scope` DB constraint enforces both halves of that.
*/
@Column({ name: 'origin_yard_id', type: 'uuid', nullable: true })
originYardId?: string | null;
@ManyToOne(() => Yard, { nullable: true, eager: false })
@JoinColumn({ name: 'origin_yard_id' })
originYard?: Yard | null;
@Column({ name: 'destination_yard_id', type: 'uuid', nullable: true })
destinationYardId?: string | null;
@ManyToOne(() => Yard, { nullable: true, eager: false })
@JoinColumn({ name: 'destination_yard_id' })
destinationYard?: Yard | null;
@Column({ name: 'currency', type: 'varchar', length: 5 })
currency!: string;