Files
edr-platform/apps/edr-freight-api/src/modules/warehouses/entities/warehouse-loading.entity.ts
Hagernesh 95c6a71438 feat(warehouse): batch 3 — loading, dispatch & train-departure visibility
- WarehouseLoading entity + Batch3 migration (wagon loading records)
- wagon-aware load() with validation; dispatch moved to PATCH
- read-only SchedulingReadFacade (schedule/wagon/departure) — never writes scheduling
- new endpoints: GET /warehouse-loadings, loadable-wagons, booking schedule
- Loading Queue / Loaded Inventory / Dispatch Queue pages + routes + sidebar
- FreightVisual illustrations (page heroes + empty states)
- booking detail: loaded/dispatched/wagon + read-only train schedule

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 12:44:40 +00:00

47 lines
1.7 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). */
@Column({ name: 'wagon_id', type: 'uuid' })
wagonId!: string;
@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;
}