hrms-api-org/src/entities/ProfileLeave.ts
2024-03-21 14:29:45 +07:00

115 lines
2.5 KiB
TypeScript

import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
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)ของตาราง LeaveType",
default: null,
})
leaveTypeId: string;
@Column({
nullable: true,
type: "datetime",
comment: "วัน เดือน ปี ที่ลา",
default: null,
})
dateLeave: 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;
}
@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 | null;
dateLeave: Date | null;
leaveDays: number | null;
leverCount: number | null;
totalLeave: number | null;
status: string | null;
reason: string | null;
}
export type UpdateProfileLeave = {
leaveTypeId?: string | null;
dateLeave?: Date | null;
leaveDays?: number | null;
leverCount?: number | null;
totalLeave?: number | null;
status?: string | null;
reason?: string | null;
};