mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 06:00:55 +00:00
api
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import { BaseEntity } from '@edr/api-common';
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
|
||||
|
||||
import { Booking } from '../../bookings/entities/booking.entity';
|
||||
import { InterchangeDocument } from './interchange-document.entity';
|
||||
|
||||
export const INTERCHANGE_ITEM_TYPES = ['CONTAINER', 'CARGO'] as const;
|
||||
export type InterchangeItemType = (typeof INTERCHANGE_ITEM_TYPES)[number];
|
||||
|
||||
export const INTERCHANGE_CONDITION_STATUSES = [
|
||||
'GOOD',
|
||||
'DAMAGED',
|
||||
'SHORTAGE',
|
||||
'EXCESS',
|
||||
'HOLD',
|
||||
'UNKNOWN',
|
||||
] as const;
|
||||
export type InterchangeConditionStatus = (typeof INTERCHANGE_CONDITION_STATUSES)[number];
|
||||
|
||||
@Entity({ schema: 'freight', name: 'interchange_document_items' })
|
||||
@Index(['interchangeDocumentId'])
|
||||
@Index(['bookingId'])
|
||||
export class InterchangeDocumentItem extends BaseEntity {
|
||||
@Column({ name: 'interchange_document_id', type: 'uuid' })
|
||||
interchangeDocumentId!: string;
|
||||
|
||||
@ManyToOne(() => InterchangeDocument, (document) => document.items, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'interchange_document_id' })
|
||||
document?: InterchangeDocument;
|
||||
|
||||
@Column({ name: 'booking_id', type: 'uuid', nullable: true })
|
||||
bookingId?: string | null;
|
||||
|
||||
@ManyToOne(() => Booking, { nullable: true, onDelete: 'SET NULL' })
|
||||
@JoinColumn({ name: 'booking_id' })
|
||||
booking?: Booking | null;
|
||||
|
||||
@Column({ name: 'booking_reference', type: 'varchar', length: 64, nullable: true })
|
||||
bookingReference?: string | null;
|
||||
|
||||
@Column({ name: 'item_type', type: 'varchar', length: 20 })
|
||||
itemType!: InterchangeItemType;
|
||||
|
||||
@Column({ name: 'booking_container_id', type: 'uuid', nullable: true })
|
||||
bookingContainerId?: string | null;
|
||||
|
||||
@Column({ name: 'booking_cargo_id', type: 'uuid', nullable: true })
|
||||
bookingCargoId?: string | null;
|
||||
|
||||
@Column({ name: 'container_number', type: 'varchar', length: 64, nullable: true })
|
||||
containerNumber?: string | null;
|
||||
|
||||
@Column({ name: 'seal_number', type: 'varchar', length: 100, nullable: true })
|
||||
sealNumber?: string | null;
|
||||
|
||||
@Column({ name: 'cargo_id', type: 'uuid', nullable: true })
|
||||
cargoId?: string | null;
|
||||
|
||||
@Column({ name: 'cargo_type', type: 'varchar', length: 255, nullable: true })
|
||||
cargoType?: string | null;
|
||||
|
||||
@Column({ name: 'cargo_description', type: 'text', nullable: true })
|
||||
cargoDescription?: string | null;
|
||||
|
||||
@Column({ name: 'weight', type: 'numeric', precision: 14, scale: 3, nullable: true })
|
||||
weight?: number | null;
|
||||
|
||||
@Column({ name: 'quantity', type: 'numeric', precision: 12, scale: 3, nullable: true })
|
||||
quantity?: number | null;
|
||||
|
||||
@Column({ name: 'package_count', type: 'int', nullable: true })
|
||||
packageCount?: number | null;
|
||||
|
||||
@Column({ name: 'wagon_number', type: 'varchar', length: 80, nullable: true })
|
||||
wagonNumber?: string | null;
|
||||
|
||||
@Column({ name: 'condition_status', type: 'varchar', length: 20, default: 'GOOD' })
|
||||
conditionStatus!: InterchangeConditionStatus;
|
||||
|
||||
@Column({ name: 'damage_description', type: 'text', nullable: true })
|
||||
damageDescription?: string | null;
|
||||
|
||||
@Column({ name: 'remarks', type: 'text', nullable: true })
|
||||
remarks?: string | null;
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { BaseEntity } from '@edr/api-common';
|
||||
import { Column, Entity, Index, OneToMany } from 'typeorm';
|
||||
|
||||
import { InterchangeDocumentItem } from './interchange-document-item.entity';
|
||||
|
||||
export const INTERCHANGE_DIRECTIONS = ['IMPORT', 'EXPORT'] as const;
|
||||
export type InterchangeDirection = (typeof INTERCHANGE_DIRECTIONS)[number];
|
||||
|
||||
export const INTERCHANGE_DOCUMENT_STATUSES = [
|
||||
'DRAFT',
|
||||
'GENERATED',
|
||||
'ACKNOWLEDGED',
|
||||
'DISPUTED',
|
||||
'CANCELLED',
|
||||
] as const;
|
||||
export type InterchangeDocumentStatus = (typeof INTERCHANGE_DOCUMENT_STATUSES)[number];
|
||||
|
||||
@Entity({ schema: 'freight', name: 'interchange_documents' })
|
||||
@Index(['documentNo'], { unique: true })
|
||||
@Index(['direction'])
|
||||
@Index(['status'])
|
||||
@Index(['scheduleId'])
|
||||
export class InterchangeDocument extends BaseEntity {
|
||||
@Column({ name: 'document_no', type: 'varchar', length: 40, unique: true })
|
||||
documentNo!: string;
|
||||
|
||||
@Column({ name: 'direction', type: 'varchar', length: 10 })
|
||||
direction!: InterchangeDirection;
|
||||
|
||||
@Column({ name: 'schedule_id', type: 'uuid', nullable: true })
|
||||
scheduleId?: string | null;
|
||||
|
||||
@Column({ name: 'train_no', type: 'varchar', length: 40, nullable: true })
|
||||
trainNo?: string | null;
|
||||
|
||||
@Column({ name: 'route_id', type: 'uuid', nullable: true })
|
||||
routeId?: string | null;
|
||||
|
||||
@Column({ name: 'origin_facility_id', type: 'uuid', nullable: true })
|
||||
originFacilityId?: string | null;
|
||||
|
||||
@Column({ name: 'destination_facility_id', type: 'uuid', nullable: true })
|
||||
destinationFacilityId?: string | null;
|
||||
|
||||
@Column({ name: 'handover_location', type: 'varchar', length: 255 })
|
||||
handoverLocation!: string;
|
||||
|
||||
@Column({ name: 'handover_from', type: 'varchar', length: 255 })
|
||||
handoverFrom!: string;
|
||||
|
||||
@Column({ name: 'handover_to', type: 'varchar', length: 255 })
|
||||
handoverTo!: string;
|
||||
|
||||
@Column({ name: 'operator_name', type: 'varchar', length: 255, nullable: true })
|
||||
operatorName?: string | null;
|
||||
|
||||
@Column({ name: 'port_operator_name', type: 'varchar', length: 255, nullable: true })
|
||||
portOperatorName?: string | null;
|
||||
|
||||
@Column({ name: 'shipping_line_name', type: 'varchar', length: 255, nullable: true })
|
||||
shippingLineName?: string | null;
|
||||
|
||||
@Column({ name: 'customs_reference', type: 'varchar', length: 120, nullable: true })
|
||||
customsReference?: string | null;
|
||||
|
||||
@Column({ name: 'manifest_reference', type: 'varchar', length: 120, nullable: true })
|
||||
manifestReference?: string | null;
|
||||
|
||||
@Column({ name: 'status', type: 'varchar', length: 20, default: 'DRAFT' })
|
||||
status!: InterchangeDocumentStatus;
|
||||
|
||||
@Column({ name: 'generated_at', type: 'timestamptz', nullable: true })
|
||||
generatedAt?: Date | null;
|
||||
|
||||
@Column({ name: 'acknowledged_at', type: 'timestamptz', nullable: true })
|
||||
acknowledgedAt?: Date | null;
|
||||
|
||||
@Column({ name: 'generated_by', type: 'varchar', length: 120, nullable: true })
|
||||
generatedBy?: string | null;
|
||||
|
||||
@Column({ name: 'acknowledged_by', type: 'varchar', length: 120, nullable: true })
|
||||
acknowledgedBy?: string | null;
|
||||
|
||||
@Column({ name: 'remarks', type: 'text', nullable: true })
|
||||
remarks?: string | null;
|
||||
|
||||
@OneToMany(() => InterchangeDocumentItem, (item) => item.document)
|
||||
items?: InterchangeDocumentItem[];
|
||||
}
|
||||
Reference in New Issue
Block a user