import { BaseEntity } from '@edr/api-common'; import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm'; import { Contract } from './contract.entity'; export const CONTRACT_REVIEW_NOTE_TYPES = [ 'CHANGES_REQUESTED', 'REJECTION', 'STAFF_NOTE', 'CUSTOMER_NOTE', 'AMENDMENT', /** * The customer disputed the advised duty & tax and asked GL Ethiopia to * correct it. One row per round — the advice/dispute loop can repeat. */ 'DUTY_DISPUTE', /** Backoffice froze the contract; body is the reason shown to the customer. */ 'SUSPENSION', /** Backoffice lifted a suspension; body is the optional lift note. */ 'SUSPENSION_LIFTED', /** Customer cancelled their own contract; body is their reason. */ 'CANCELLATION', ] as const; export type ContractReviewNoteType = (typeof CONTRACT_REVIEW_NOTE_TYPES)[number]; @Entity({ schema: 'freight', name: 'contract_review_notes' }) @Index(['contractId']) export class ContractReviewNote extends BaseEntity { @Column({ name: 'contract_id', type: 'uuid' }) contractId!: string; @ManyToOne(() => Contract, (c) => c.reviewNotes, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'contract_id' }) contract?: Contract; @Column({ name: 'note_type', type: 'varchar', length: 40 }) noteType!: ContractReviewNoteType; @Column({ name: 'body', type: 'text' }) body!: string; @Column({ name: 'author_role', type: 'varchar', length: 20, nullable: true }) authorRole?: string | null; @Column({ name: 'author_user_id', type: 'uuid', nullable: true }) authorUserId?: string | null; }