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

@Index('commission_received_id', ['commission_received_id'], {})
@Index('visa_case_id', ['visa_case_id'], {})
@Entity('vcm_commission_received_details', {
  schema: DB_SCHEMA,
})
export class VcmCommissionReceivedDetailsEntity {
  @PrimaryGeneratedColumn({ type: 'mediumint', name: 'id', unsigned: true })
  id: number;

  @Column('mediumint', { name: 'commission_received_id', unsigned: true })
  commission_received_id: number;

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

  @Column('decimal', { name: 'tuition_fees', precision: 15, scale: 2 })
  tuition_fees: string;

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

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

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

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

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

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

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

  @Column('decimal', {
    name: 'our_commission_amount_inr',
    nullable: true,
    precision: 15,
    scale: 2,
  })
  our_commission_amount_inr: 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;
}
