import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { ProfileLeave } from "./ProfileLeave";

@Entity("leaveType")
export class LeaveType extends EntityBase {
  @Column({
    nullable: true,
    comment: "ประเภทการลา",
    length: 255,
    default: null,
  })
  name: string;

  @Column({
    nullable: true,
    comment: "รหัสประเภอการลา",
    default: null,
  })
  code: string;

  @Column({
    nullable: true,
    comment: "ลาได้สูงสุด(วัน)",
    default: true,
  })
  limit: number;

  @OneToMany(() => ProfileLeave, (v) => v.leaveType)
  profileLeave: ProfileLeave;
}

export class CreateLeaveType {
  name: string | null;
  code: string | null;
  limit: number | null;
}

export type UpdateLeaveType = {
  name?: string | null;
  code?: string | null;
  limit?: number | null;
};
