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

@Index('commission_enquiry_id', ['commission_enquiry_id'], {})
@Index('commission_response_reason_id', ['commission_response_reason_id'], {})
@Index('commission_response_status_id', ['commission_response_status_id'], {})
@Index('visa_case_id', ['visa_case_id'], {})
@Entity('vcm_institute_commission_enquiry_details', {
  schema: DB_SCHEMA,
})
export class VcmInstituteCommissionEnquiryDetailsEntity {
  @PrimaryGeneratedColumn({ type: 'mediumint', name: 'id', unsigned: true })
  id: number;

  @Column('mediumint', {
    name: 'commission_enquiry_id',
    nullable: true,
    unsigned: true,
  })
  commission_enquiry_id: number | null;

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

  @Column('decimal', {
    name: 'tuition_fees',
    nullable: true,
    precision: 11,
    scale: 2,
  })
  tuition_fees: string | null;

  @Column('varchar', { name: 'tuition_fees_currency', length: 5 })
  tuition_fees_currency: string;

  @Column('tinyint', { name: 'commission_type', comment: '1=Fixed, 2=Percent' })
  commission_type: number;

  @Column('decimal', {
    name: 'commission_percentage',
    nullable: true,
    precision: 5,
    scale: 2,
  })
  commission_percentage: string | null;

  @Column('decimal', {
    name: 'commission_amount',
    nullable: true,
    precision: 11,
    scale: 2,
  })
  commission_amount: string | null;

  @Column('varchar', { name: 'commission_currency', length: 5 })
  commission_currency: string;

  @Column('tinyint', {
    name: 'commission_response_status_id',
    nullable: true,
    unsigned: true,
  })
  commission_response_status_id: number | null;

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

  @Column('decimal', {
    name: 'difference',
    nullable: true,
    precision: 11,
    scale: 2,
  })
  difference: string | null;

  @Column('tinyint', {
    name: 'commission_response_reason_id',
    nullable: true,
    unsigned: true,
  })
  commission_response_reason_id: string | number | null;

  @Column('tinyint', {
    name: 'commission_difference_reason_id',
    nullable: true,
    unsigned: true,
  })
  commission_difference_reason_id: string | number | null;

  @Column('varchar', { name: 'remarks', nullable: true, length: 500 })
  remarks: string | null;

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

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

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

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

  @ManyToOne(() => VmsVisaCasesEntity)
  @JoinColumn({ name: 'visa_case_id' })
  case: VmsVisaCasesEntity;
}
