mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 19:00:55 +00:00
Intercity cargo is loaded at its origin yard and unloaded at its destination, but
only some yards have the equipment. EDR's facilities are Indode, Sebeta, Modjo,
Adama and Dire Dawa — and the set grows, so it has to be data.
- yards.has_facility marks a yard as a load/unload point; the new yard_facilities
record says what it can do. Only Indode stores cargo (has_warehouse), so only it
accrues storage/demurrage — the rest just move cargo on and off the train.
- facility_handling_events records each load/unload and carries its GRN.
warehouse_inventory cannot: its warehouse/yard/zone are NOT NULL, so a facility
without a warehouse could never have a row. inventory_id links to the storage
record when there is one.
- YardFacilitiesService.facilityForYard is the single resolver the handling flows
share, so they cannot drift on what a facility is.
- The seeder flags EXISTING yards and creates none. The codes are historical and
do not read like the facility names — Indode is KALITY ("Gelan Multi Purpose
Port (Indode)") and Sebeta is LEGACY_DEST — so it maps by code. Creating fresh
INDODE/SEBETA yards would have split data that routes and bookings already
reference.
Negad is deliberately absent: NAGAD ("DCT/SGDT") is in Djibouti while
NEGAD_FY_BCC is in Ethiopia and inactive, and which one is the intercity facility
is unsettled.
No behaviour change yet — nothing reads has_facility until the gate lands.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { BaseEntity } from '@edr/api-common';
|
|
import { Column, Entity, Index, JoinColumn, OneToOne } from 'typeorm';
|
|
|
|
import { Yard } from './yard.entity';
|
|
|
|
/**
|
|
* What a yard's load/unload facility can do. One record per yard flagged
|
|
* `has_facility`.
|
|
*
|
|
* `hasWarehouse` is the line that matters: a facility with a warehouse (Indode
|
|
* today) stores cargo and therefore accrues storage/demurrage through the normal
|
|
* warehouse flow; the rest only move cargo on and off the train, so they record
|
|
* the handling event and its GRN and nothing else.
|
|
*/
|
|
@Entity({ schema: 'freight', name: 'yard_facilities' })
|
|
@Index(['yardId'])
|
|
export class YardFacility extends BaseEntity {
|
|
@Column({ name: 'yard_id', type: 'uuid' })
|
|
yardId!: string;
|
|
|
|
@OneToOne(() => Yard, { nullable: false, onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'yard_id' })
|
|
yard?: Yard;
|
|
|
|
/** Cargo can be stored here — enables the warehouse flow (storage, demurrage). */
|
|
@Column({ name: 'has_warehouse', type: 'boolean', default: false })
|
|
hasWarehouse!: boolean;
|
|
|
|
@Column({ name: 'equipment_notes', type: 'text', nullable: true })
|
|
equipmentNotes?: string | null;
|
|
|
|
@Column({ name: 'is_active', type: 'boolean', default: true })
|
|
isActive!: boolean;
|
|
}
|