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

/**
 * Final closure verification data — created when an NC is closed.
 * Links to both nc__ncs (via nc_id) and optionally a specific entry
 * (via ncrentry_id).
 */
@Entity({ name: 'nc_final_closures' })
export class PreviousNcFinalClosureEntity {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

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

  @Column({ type: 'bigint', unsigned: true, nullable: true })
  ncrentry_id: number | null;

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

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

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

  @Column({ type: 'tinyint', nullable: true })
  submitted_documents_checkbox: number | null;

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

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

  @Column({ type: 'tinyint', default: 0 })
  result_accepted: number;

  @Column({ type: 'tinyint', default: 0 })
  result_not_accepted: number;

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

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

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

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

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

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