import { DB_SCHEMA } from 'src/utils';
import {
  Column,
  Entity,
  Index,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { UserEntity } from './User.entity';
import { CountryEntity } from './Country.entity';
import { CompanyBankAccountEntity } from './CompanyBankAccount.entity';
import { PaymentModeMasterEntity } from './PaymentModeMaster.entity';

@Index('associate_id', ['associate_id'], {})
@Index('association_type', ['association_type'], {})
@Index('bank_account_id', ['bank_account_id'], {})
@Index('visa_service_country_id', ['visa_service_country_id'], {})
@Entity('vcm_commission_bonus_received', { schema: DB_SCHEMA })
export class VcmCommissionBonusReceivedEntity {
  @PrimaryGeneratedColumn({ type: 'mediumint', name: 'id', unsigned: true })
  id: number;

  @Column('tinyint', {
    name: 'association_type',
    comment: '1=Institute, 2= Master Agent',
  })
  association_type: number;

  @Column('smallint', { name: 'visa_service_country_id' })
  visa_service_country_id: number;

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

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

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

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

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

  @Column('json', { name: 'tax_details', nullable: true })
  tax_details: object | null;

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

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

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

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

  @Column('date', { name: 'payment_date' })
  payment_date: string;

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

  @Column('tinyint', { name: 'bank_account_id', nullable: true })
  bank_account_id: number;

  @Column('varchar', { name: 'transaction_id', length: 250 })
  transaction_id: string;

  @Column('json', {
    name: 'attachment_file',
    nullable: true,
    comment: 'Transaction Screenshot',
  })
  attachment_file: object | null;

  @Column('mediumtext', { name: 'remarks', nullable: true })
  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(() => UserEntity, { nullable: true })
  @JoinColumn({ name: 'by_user' })
  user: UserEntity;

  @ManyToOne(() => UserEntity, { nullable: true })
  @JoinColumn({ name: 'modified_by_user' })
  modified_by: UserEntity;

  @ManyToOne(() => CountryEntity)
  @JoinColumn({ name: 'visa_service_country_id' })
  visa_country: CountryEntity;

  @ManyToOne(() => CompanyBankAccountEntity)
  @JoinColumn({ name: 'bank_account_id' })
  bank: CompanyBankAccountEntity;

  @ManyToOne(() => PaymentModeMasterEntity)
  @JoinColumn({ name: 'payment_mode_id' })
  mode: PaymentModeMasterEntity;
}
