hrms-api-org/src/entities/ProfileLeave.ts

150 lines
3.4 KiB
TypeScript

import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
import { LeaveType } from "./LeaveType";
@Entity("profileLeave")
export class ProfileLeave extends EntityBase {
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง Profile",
default: null,
})
profileId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null,
})
profileEmployeeId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง LeaveType",
default: null,
})
leaveTypeId: string;
@Column({
nullable: true,
type: "datetime",
comment: "วัน เดือน ปี ที่เริ่มลา",
default: null,
})
dateLeaveStart: Date;
@Column({
nullable: true,
type: "datetime",
comment: "วัน เดือน ปี ที่สิ้นสุดลา",
default: null,
})
dateLeaveEnd: Date;
@Column({
nullable: true,
type: "double",
comment: "จำนวนวันลา",
default: null,
})
leaveDays: number;
@Column({
nullable: true,
type: "double",
comment: "ลามาเเล้ว",
default: null,
})
leaveCount: number;
@Column({
nullable: true,
type: "double",
comment: "รวมเป็น",
default: null,
})
totalLeave: number;
@Column({
nullable: true,
comment: "สถานะ",
type: "text",
default: null,
})
status: string;
@Column({
nullable: true,
comment: "เหตุผล",
type: "text",
default: null,
})
reason: string;
@OneToMany(() => ProfileLeaveHistory, (v) => v.profileLeave)
histories: ProfileLeaveHistory[];
@ManyToOne(() => LeaveType, (v) => v.profileLeave)
leaveType: LeaveType;
@ManyToOne(() => Profile, (v) => v.profileLeaves)
profile: Profile;
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileLeaves)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
@Entity("profileLeaveHistory")
export class ProfileLeaveHistory extends ProfileLeave {
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileLeave",
default: null,
})
profileLeaveId: string;
@ManyToOne(() => ProfileLeave, (v) => v.histories)
profileLeave: ProfileLeave;
}
export class CreateProfileLeave {
profileId: string | null;
leaveTypeId: string;
dateLeaveStart: Date | null;
dateLeaveEnd: Date | null;
leaveDays: number | null;
leaveCount: number | null;
totalLeave: number | null;
status: string | null;
reason: string | null;
}
export class CreateProfileEmployeeLeave {
leaveTypeId: string;
profileEmployeeId: string | null;
dateLeaveStart: Date | null;
dateLeaveEnd: Date | null;
leaveDays: number | null;
leaveCount: number | null;
totalLeave: number | null;
status: string | null;
reason: string | null;
}
export type UpdateProfileLeave = {
leaveTypeId?: string;
dateLeaveStart?: Date | null;
dateLeaveEnd?: Date | null;
leaveDays?: number | null;
leaveCount?: number | null;
totalLeave?: number | null;
status?: string | null;
reason?: string | null;
};