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

@Entity("clock_in_records")
export class ClockInRecord extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number

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

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

  @Column({ type: "timestamp", nullable: false })
  clock_in: Date

  @Column({ type: "timestamp", nullable: true })
  clock_out: Date

  @Column({ type: "int", nullable: true })
  duration: number

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

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