import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

/**
 * Individual NC finding — child of nc__ncs via nc_id.
 * Multiple entries per NC report (typically 3-6 findings per audit).
 */
@Entity({ name: 'ncr_entries' })
export class PreviousNcrEntryEntity {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

  @Column({ type: 'bigint', unsigned: true })
  nc_id: number;

  @Column({ type: 'varchar', length: 100, nullable: true })
  nc_type: string | null;

  @Column({ type: 'text', nullable: true })
  ncr_statement: string | null;

  @Column({ type: 'text', nullable: true })
  criteria_clause: string | null;

  @Column({ type: 'text', nullable: true })
  corrective_action: string | null;

  @Column({ type: 'text', nullable: true })
  document_path: string | null;

  @Column({ type: 'enum', enum: ['open', 'closed', 'pending'], default: 'open' })
  status: 'open' | 'closed' | 'pending';

  @CreateDateColumn({ type: 'timestamp' })
  created_at: Date;

  @UpdateDateColumn({ type: 'timestamp' })
  updated_at: Date;
}
