mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 16:28:12 +00:00
149 lines
5.5 KiB
TypeScript
149 lines
5.5 KiB
TypeScript
import { BaseEntity } from "@edr/api-common";
|
|
import { Column, Entity, OneToMany } from "typeorm";
|
|
import { FileRecord } from "../../files/entities/file.entity";
|
|
|
|
@Entity({ schema:"freight",name: "bookings" })
|
|
export class Booking extends BaseEntity {
|
|
// ── core ───────────────────────────────────────────────────────────────
|
|
@Column({ name: "reference", type: "varchar", length: 64, unique: true })
|
|
reference!: string;
|
|
|
|
@Column({ name: "customer_id", type: "uuid" })
|
|
customerId!: string;
|
|
|
|
@Column({ name: "train_id", type: "uuid", nullable: true })
|
|
trainId?: string | null;
|
|
|
|
@Column({ name: "status", type: "varchar", length: 40, default: "DRAFT" })
|
|
status!: string;
|
|
|
|
@Column({ name: "scheduled_date", type: "timestamptz" })
|
|
scheduledDate!: Date;
|
|
|
|
@Column({
|
|
name: "total_amount",
|
|
type: "numeric",
|
|
precision: 14,
|
|
scale: 2,
|
|
default: 0,
|
|
})
|
|
totalAmount!: number;
|
|
|
|
@Column({
|
|
name: "payment_status",
|
|
type: "varchar",
|
|
length: 20,
|
|
default: "PENDING",
|
|
})
|
|
paymentStatus!: string;
|
|
|
|
// ── contract ───────────────────────────────────────────────────────────
|
|
@Column({ name: "contract_type", type: "varchar", length: 20 })
|
|
contractType!: string;
|
|
|
|
@Column({ name: "previous_contract_id", type: "uuid", nullable: true })
|
|
previousContractId?: string | null;
|
|
|
|
@Column({ name: "service_type", type: "varchar", length: 30 })
|
|
serviceType!: string;
|
|
|
|
@Column({ name: "first_mile_enabled", type: "boolean", default: false })
|
|
firstMileEnabled!: boolean;
|
|
|
|
@Column({ name: "first_mile_pickup_address", type: "text", nullable: true })
|
|
firstMilePickupAddress?: string | null;
|
|
|
|
@Column({ name: "last_mile_enabled", type: "boolean", default: false })
|
|
lastMileEnabled!: boolean;
|
|
|
|
@Column({ name: "last_mile_delivery_address", type: "text", nullable: true })
|
|
lastMileDeliveryAddress?: string | null;
|
|
|
|
@Column({ name: "equipment_return", type: "varchar", length: 20 })
|
|
equipmentReturn!: string;
|
|
|
|
@Column({ name: "origin_station", type: "varchar", length: 255 })
|
|
originStation!: string;
|
|
|
|
@Column({ name: "destination_station", type: "varchar", length: 255 })
|
|
destinationStation!: string;
|
|
|
|
@Column({
|
|
name: "cargo_total_weight_vgm",
|
|
type: "numeric",
|
|
precision: 12,
|
|
scale: 3,
|
|
})
|
|
cargoTotalWeightVgm!: number;
|
|
|
|
@Column({ name: "freight_type", type: "varchar", length: 20 })
|
|
freightType!: string;
|
|
|
|
@Column({ name: "freight_subtype", type: "varchar", length: 100, nullable: true })
|
|
freightSubtype?: string | null;
|
|
|
|
@Column({ name: "is_hazardous", type: "boolean", default: false })
|
|
isHazardous!: boolean;
|
|
|
|
@Column({ name: "is_refrigerated", type: "boolean", default: false })
|
|
isRefrigerated!: boolean;
|
|
|
|
@Column({ name: "trade_direction", type: "varchar", length: 10 })
|
|
tradeDirection!: string;
|
|
|
|
@Column({ name: "payment_currency", type: "varchar", length: 5 })
|
|
paymentCurrency!: string;
|
|
|
|
@Column({ name: "start_date", type: "date", nullable: true })
|
|
startDate?: Date | null;
|
|
|
|
@Column({ name: "end_date", type: "date", nullable: true })
|
|
endDate?: Date | null;
|
|
|
|
@Column({ name: "financial_terms", type: "text", nullable: true })
|
|
financialTerms?: string | null;
|
|
|
|
@Column({ name: "version_number", type: "int", default: 1 })
|
|
versionNumber!: number;
|
|
|
|
// ── containers ─────────────────────────────────────────────────────────
|
|
@Column({ name: "containers", type: "jsonb", nullable: true })
|
|
containers!: Array<{ type: string; qty: number; vgm: number }> | null;
|
|
|
|
// ── approval ───────────────────────────────────────────────────────────
|
|
@Column({ name: "approved_by_staff_id", type: "uuid", nullable: true })
|
|
approvedByStaffId?: string | null;
|
|
|
|
@Column({ name: "approved_by_staff_at", type: "timestamptz", nullable: true })
|
|
approvedByStaffAt?: Date | null;
|
|
|
|
@Column({ name: "signed_by_director_id", type: "uuid", nullable: true })
|
|
signedByDirectorId?: string | null;
|
|
|
|
@Column({ name: "signed_by_director_at", type: "timestamptz", nullable: true })
|
|
signedByDirectorAt?: Date | null;
|
|
|
|
@Column({ name: "signed_by_ceo_id", type: "uuid", nullable: true })
|
|
signedByCeoId?: string | null;
|
|
|
|
@Column({ name: "signed_by_ceo_at", type: "timestamptz", nullable: true })
|
|
signedByCeoAt?: Date | null;
|
|
|
|
@Column({ name: "priority_score", type: "int", default: 0 })
|
|
priorityScore!: number;
|
|
|
|
// ── consolidation ──────────────────────────────────────────────────────
|
|
@Column({ name: "allow_consolidation", type: "boolean", default: false })
|
|
allowConsolidation!: boolean;
|
|
|
|
@Column({ name: "consolidation_partner_id", type: "uuid", nullable: true })
|
|
consolidationPartnerId?: string | null;
|
|
|
|
// ── files ────────────────────────────────────────────────────────────
|
|
@OneToMany(() => FileRecord, (file) => file.resourceId, {
|
|
createForeignKeyConstraints: false,
|
|
})
|
|
files?: FileRecord[];
|
|
|
|
}
|