import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
} from "typeorm"
import { BaseEntity } from "../../common/entities/base.entity"
import { Employee } from "./employee.entity"
import { Company } from "../../company/entities/company.entity"
import { Auth } from "src/modules/auth/entities/auth.entity"

@Entity("employee_salary_history")
export class EmployeeSalaryHistory extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ type: "int", nullable: false })
  employee_id: number

  @Column({ type: "int", nullable: false })
  company_id: number

  @Column({ type: "date", nullable: false })
  from_date: Date

  @Column({ type: "date", nullable: true })
  to_date: Date

  @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
  gross_salary: number

  @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
  basic_salary: number

  @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
  total_earnings: number

  @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
  total_deductions: number

  @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
  net_payable_salary: number

  @Column({ type: "varchar", length: 10, nullable: false })
  basic_salary_percentage: string

  @Column({ type: "decimal", precision: 10, scale: 2, nullable: true })
  tds_amount: number

  @Column({ type: "varchar", length: 50, nullable: false, default: "new" })
  regime_type: string

  @Column({ type: "text", nullable: true })
  notes: string

  @ManyToOne(() => Employee)
  @JoinColumn({ name: "employee_id" })
  employee: Employee

  @ManyToOne(() => Company)
  @JoinColumn({ name: "company_id" })
  company: Company

  @ManyToOne(() => Auth)
  @JoinColumn({ name: "updated_by" })
  user: Auth
}
