import { Entity, Column, JoinColumn, ManyToOne, Double } from "typeorm";
import { EntityBase } from "./base/Base";
import { ProfileSalary } from "./ProfileSalary";
import { Command } from "./Command";

@Entity("profileSalaryHistory")
export class ProfileSalaryHistory extends EntityBase {
  //   @Column({
  //     length: 40,
  //     comment: "คีย์นอก(FK)ของตาราง profile",
  //     type: "uuid",
  //   })
  //   profileId: string;

  @Column({
    comment: "วันที่",
    type: "datetime",
    nullable: true,
  })
  date: Date;

  @Column({
    nullable: true,
    length: 40,
    comment: "เลขที่ตำแหน่ง",
    default: null,
  })
  posNo: string;

  @Column({
    nullable: true,
    length: 255,
    comment: "ตำแหน่ง",
    default: null,
  })
  position: string;

  @Column({
    nullable: true,
    length: 255,
    comment: "สายงาน",
    default: null,
  })
  positionLine: string;

  @Column({
    nullable: true,
    length: 255,
    comment: "ด้าน/สาขา",
    default: null,
  })
  positionPathSide: string;

  @Column({
    nullable: true,
    length: 255,
    comment: "ตำแหน่งทางการบริหาร",
    default: null,
  })
  positionExecutive: string;

  @Column({
    nullable: true,
    length: 255,
    comment: "ประเภทตำแหน่ง",
    default: null,
  })
  positionType: string;

  @Column({
    nullable: true,
    length: 255,
    comment: "ระดับตำแหน่ง",
    default: null,
  })
  positionLevel: string;

  @Column({
    comment: "เงินเดือนฐาน",
    default: 0,
    nullable: true,
    type: "double",
  })
  amount: Double;

  @Column({
    comment: "เงินประจำตำแหน่ง",
    default: 0,
    nullable: true,
    type: "double",
  })
  positionSalaryAmount: Double;

  @Column({
    comment: "เงินค่าตอบแทนรายเดือน",
    default: 0,
    nullable: true,
    type: "double",
  })
  mouthSalaryAmount: Double;

  @Column({
    nullable: true,
    comment: "เลขที่คำสั่ง",
    type: "text",
    default: null,
  })
  refCommandNo: string;

  @Column({
    nullable: true,
    comment: "เอกสารอ้างอิง",
    type: "text",
    default: null,
  })
  templateDoc: string;

  @Column({
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง profileSalary",
  })
  profileSalaryId: string;

  @Column({
    nullable: true,
    comment: "ลำดับตำแหน่ง",
    default: null,
  })
  order: number;

  @Column({
    nullable: true,
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง command",
    default: null,
  })
  commandId: string;

  @ManyToOne(() => Command, (command) => command.profileSalaryHistorys)
  @JoinColumn({ name: "commandId" })
  command: Command;

  @ManyToOne(() => ProfileSalary, (profileSalary) => profileSalary.profileSalaryHistories)
  @JoinColumn({ name: "profileSalaryId" })
  histories: ProfileSalary;
}

export class CreateProfileSalaryHistory {
  profileId: string;
  date?: Date | null;
  amount?: Double | null;
  positionSalaryAmount?: Double | null;
  mouthSalaryAmount?: Double | null;
  posNo: string | null;
  position: string | null;
  positionLine: string | null;
  positionPathSide: string | null;
  positionExecutive: string | null;
  positionType: string | null;
  positionLevel: string | null;
  refCommandNo: string | null;
  templateDoc: string | null;
}

export class UpdateProfileSalaryHistory {
  date?: Date | null;
  amount?: Double | null;
  positionSalaryAmount?: Double | null;
  mouthSalaryAmount?: Double | null;
  posNo?: string | null;
  position?: string | null;
  positionLine?: string | null;
  positionPathSide?: string | null;
  positionExecutive?: string | null;
  positionType?: string | null;
  positionLevel?: string | null;
  refCommandNo?: string | null;
  templateDoc?: string | null;
}
