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

/**
 * nc_final_closures in scheme_dbs s — closure rows for a NEW NC (one per closed
 * finding). Not written by the raise-NC flow; created now so the closure
 * feature can reuse it later. Columns mirror the qrs/tqs closure table.
 */
@Entity({ name: 'nc_final_closures' })
export class NcFinalClosureEntity {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

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

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

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

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

  @Column({ type: 'varchar', length: 255, 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: 'varchar', length: 255, 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: 255, nullable: true })
  auditor_name: string | null;

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

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

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

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