mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
"Auto Load Ready Items" now opens a train picker (pre-dispatch trains with these bookings assigned, via the existing loadable-trains flow). No train available -> no auto-loading, with a clear notice. Loading goes through the existing per-wagon load path, so items without an allocated wagon are skipped with a reason. The train association is stored on the existing warehouse_loadings table (no new table needed): new train_schedule_id column + a note recording train number, origin -> destination, and departure time; wagon_id becomes nullable. The trainless load-passed-export endpoint, its frontend wiring, and the unused useLoadPassedExport hook are removed. Migration 2100000000000 (idempotent) also applied to the dev database. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import { BaseEntity } from '@edr/api-common';
|
|
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
|
|
|
|
import { Booking } from '../../bookings/entities/booking.entity';
|
|
import { WarehouseInventory } from './warehouse-inventory.entity';
|
|
|
|
/**
|
|
* Batch 3 — a record that a warehouse inventory item was physically loaded onto a wagon.
|
|
* The warehouse OWNS this record. It only READS wagon/schedule data from the scheduling
|
|
* domain (via SchedulingReadFacade); it never writes to wagons or train schedules.
|
|
*/
|
|
@Entity({ schema: 'freight', name: 'warehouse_loadings' })
|
|
@Index(['warehouseInventoryId'])
|
|
@Index(['bookingId'])
|
|
@Index(['wagonId'])
|
|
export class WarehouseLoading extends BaseEntity {
|
|
@Column({ name: 'warehouse_inventory_id', type: 'uuid' })
|
|
warehouseInventoryId!: string;
|
|
|
|
@ManyToOne(() => WarehouseInventory)
|
|
@JoinColumn({ name: 'warehouse_inventory_id' })
|
|
inventory?: WarehouseInventory;
|
|
|
|
@Column({ name: 'booking_id', type: 'uuid', nullable: true })
|
|
bookingId?: string | null;
|
|
|
|
@ManyToOne(() => Booking, { nullable: true })
|
|
@JoinColumn({ name: 'booking_id' })
|
|
booking?: Booking | null;
|
|
|
|
/**
|
|
* Physical wagon the item was loaded onto. References freight.wagons
|
|
* (read-only link). Nullable: a schedule-level auto-load may not resolve to
|
|
* one wagon — the train association then lives in trainScheduleId.
|
|
*/
|
|
@Column({ name: 'wagon_id', type: 'uuid', nullable: true })
|
|
wagonId?: string | null;
|
|
|
|
/** Train schedule the item was loaded onto (read-only link to scheduling). */
|
|
@Column({ name: 'train_schedule_id', type: 'uuid', nullable: true })
|
|
trainScheduleId?: string | null;
|
|
|
|
@Column({ name: 'loaded_at', type: 'timestamptz' })
|
|
loadedAt!: Date;
|
|
|
|
@Column({ name: 'loaded_by', type: 'varchar', length: 120, nullable: true })
|
|
loadedBy?: string | null;
|
|
|
|
@Column({ name: 'loaded_weight', type: 'numeric', precision: 14, scale: 3, nullable: true })
|
|
loadedWeight?: number | null;
|
|
|
|
@Column({ name: 'notes', type: 'text', nullable: true })
|
|
notes?: string | null;
|
|
}
|