import { BaseEntity } from '@edr/api-common'; import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; import { WarehouseFeeInvoice } from './warehouse-fee-invoice.entity'; export const WAREHOUSE_FEE_TYPES = [ 'CONTAINER_DEMURRAGE', 'BULK_DEMURRAGE', 'STORAGE_FEE', 'HANDLING_FEE', ] as const; export type WarehouseFeeType = (typeof WAREHOUSE_FEE_TYPES)[number]; @Entity({ schema: 'freight', name: 'warehouse_fee_invoice_items' }) @Index(['invoiceId']) export class WarehouseFeeInvoiceItem extends BaseEntity { @Column({ name: 'invoice_id', type: 'uuid' }) invoiceId!: string; @ManyToOne(() => WarehouseFeeInvoice, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'invoice_id' }) invoice?: WarehouseFeeInvoice; @Column({ name: 'fee_rule_id', type: 'uuid', nullable: true }) feeRuleId?: string | null; @Column({ name: 'fee_type', type: 'varchar', length: 32 }) feeType!: WarehouseFeeType; @Column({ name: 'description', type: 'varchar', length: 255 }) description!: string; @Column({ name: 'quantity', type: 'numeric', precision: 12, scale: 2, default: 1 }) quantity!: number; @Column({ name: 'unit_rate', type: 'numeric', precision: 14, scale: 2, default: 0 }) unitRate!: number; @Column({ name: 'amount', type: 'numeric', precision: 14, scale: 2, default: 0 }) amount!: number; @Column({ name: 'currency', type: 'varchar', length: 8, default: 'USD' }) currency!: string; @Column({ name: 'chargeable_days', type: 'int', nullable: true }) chargeableDays?: number | null; @Column({ name: 'free_days', type: 'int', nullable: true }) freeDays?: number | null; }