import { DB_SCHEMA } from 'src/utils';
import {
  Column,
  Entity,
  Index,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { VmsCaseOfferLettersEntity } from './VmsCaseOfferLetters.entity';

@Index('offer_letter_id', ['offer_letter_id'], {})
@Entity('vms_case_offer_letter_instances', {
  schema: DB_SCHEMA,
})
export class VmsCaseOfferLetterInstancesEntity {
  @PrimaryGeneratedColumn({ type: 'int', name: 'id' })
  id: number;

  @Column('int', { name: 'offer_letter_id' })
  offer_letter_id: number;

  @Column('tinyint', { name: 'instance_no' })
  instance_no: number;

  @Column('int', { name: 'instance_fee' })
  instance_fee: number;

  @Column('smallint', { name: 'by_user', nullable: true })
  by_user: number | null;

  @Column('timestamp', { name: 'created', default: () => 'CURRENT_TIMESTAMP' })
  created: Date;

  @Column('timestamp', { name: 'modified', default: () => 'CURRENT_TIMESTAMP' })
  modified: Date;

  @ManyToOne(() => VmsCaseOfferLettersEntity)
  @JoinColumn({ name: 'offer_letter_id' })
  offerLetter: VmsCaseOfferLettersEntity;
}
