contrat,booking,global logestic

This commit is contained in:
Marshal
2026-06-26 23:24:48 +00:00
parent f931342f31
commit 01d53c218c
105 changed files with 19573 additions and 909 deletions

View File

@@ -0,0 +1,37 @@
import { BaseEntity } from '@edr/api-common';
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
import { BookingContainer } from './booking-container.entity';
/**
* One physical container under a booking_container line — its number, seal, and
* per-unit VGM. Entered at booking time (by the customer in Path A or by GL ET
* in Path B). See §5.10.
*/
@Entity({ schema: 'freight', name: 'booking_container_units' })
@Index(['bookingContainerId'])
export class BookingContainerUnit extends BaseEntity {
@Column({ name: 'booking_container_id', type: 'uuid' })
bookingContainerId!: string;
@ManyToOne(() => BookingContainer, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'booking_container_id' })
bookingContainer?: BookingContainer;
@Column({ name: 'container_number', type: 'varchar', length: 64 })
containerNumber!: string;
@Column({ name: 'seal_number', type: 'varchar', length: 64, nullable: true })
sealNumber?: string | null;
@Column({ name: 'vgm_tons', type: 'numeric', precision: 10, scale: 3 })
vgmTons!: number;
@Column({ name: 'is_hazardous', type: 'boolean', default: false })
isHazardous!: boolean;
@Column({ name: 'is_reefer', type: 'boolean', default: false })
isReefer!: boolean;
@Column({ name: 'sort_order', type: 'smallint', default: 0 })
sortOrder!: number;
}

View File

@@ -25,9 +25,21 @@ export class BookingContainer extends BaseEntity {
@Column({ name: 'container_number', type: 'varchar', length: 64, nullable: true })
containerNumber?: string | null;
/** Contract container size this line covers (20ft | 40ft). Null for legacy rows. */
@Column({ name: 'container_size', type: 'varchar', length: 10, nullable: true })
containerSize?: string | null;
@Column({ name: 'quantity', type: 'smallint' })
quantity!: number;
/** How many units of this line are hazardous (≤ quantity). */
@Column({ name: 'hazardous_quantity', type: 'smallint', default: 0 })
hazardousQuantity!: number;
/** How many units of this line are refrigerated (≤ quantity). */
@Column({ name: 'reefer_quantity', type: 'smallint', default: 0 })
reeferQuantity!: number;
@Column({ name: 'vgm_per_unit_tons', type: 'numeric', precision: 10, scale: 3 })
vgmPerUnitTons!: number;

View File

@@ -144,13 +144,24 @@ export class Booking extends BaseEntity {
@Column({ name: 'status', type: 'varchar', length: 40, default: 'DRAFT' })
status!: string;
/**
* ONE_TIME for a normal single-shipment booking; GENERAL_CONTRACT for an
* umbrella contract that is signed/paid once and then drawn down by many
* orders (each order spawns its own ONE_TIME child booking).
*/
@Column({ name: 'booking_type', type: 'varchar', length: 20, default: 'ONE_TIME' })
bookingType!: string;
/** The contract this shipment booking was created under (contractbooking split). */
@Column({ name: 'contract_id', type: 'uuid', nullable: true })
contractId?: string | null;
/** The contract route (lane) this shipment uses. */
@Column({ name: 'contract_route_id', type: 'uuid', nullable: true })
contractRouteId?: string | null;
/** Denormalized contract kind (ONE_TIME | GENERAL) for the single-active-booking index. */
@Column({ name: 'contract_kind', type: 'varchar', length: 20, nullable: true })
contractKind?: string | null;
/** Who created this booking: CUSTOMER (Path A), GL_ET (Path B), or STAFF. */
@Column({ name: 'created_by_role', type: 'varchar', length: 20, default: 'CUSTOMER', nullable: true })
createdByRole?: string | null;
@Column({ name: 'created_by_user_id', type: 'uuid', nullable: true })
createdByUserId?: string | null;
/**
* Nullable: general contracts have no shipment date at creation — the date is
@@ -220,13 +231,6 @@ export class Booking extends BaseEntity {
@Column({ name: 'contract_type', type: 'varchar', length: 20 })
contractType!: string;
@Column({ name: 'previous_contract_id', type: 'uuid', nullable: true })
previousContractId?: string | null;
@ManyToOne(() => Booking, { nullable: true })
@JoinColumn({ name: 'previous_contract_id' })
previousContract?: Booking | null;
@Column({ name: 'service_type_id', type: 'uuid' })
serviceTypeId!: string;