2024-03-12 17:33:22 +07:00
|
|
|
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
|
|
|
|
import { EntityBase } from "./base/Base";
|
|
|
|
|
import { Profile } from "./Profile";
|
|
|
|
|
import { ProfileLeaveHistory } from "./ProfileLeaveHistory";
|
2024-03-21 11:28:24 +07:00
|
|
|
import { LeaveType } from "./LeaveType";
|
2024-03-12 17:33:22 +07:00
|
|
|
|
|
|
|
|
@Entity("profileLeave")
|
|
|
|
|
export class ProfileLeave extends EntityBase {
|
|
|
|
|
@Column({
|
|
|
|
|
nullable: true,
|
|
|
|
|
length: 40,
|
|
|
|
|
comment: "คีย์นอก(FK)ของตาราง Profile",
|
|
|
|
|
default: null,
|
|
|
|
|
})
|
|
|
|
|
profileId: string;
|
|
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
nullable: true,
|
2024-03-21 11:28:24 +07:00
|
|
|
length: 40,
|
|
|
|
|
comment: "คีย์นอก(FK)ของตาราง LeaveType",
|
2024-03-12 17:33:22 +07:00
|
|
|
default: null,
|
|
|
|
|
})
|
2024-03-21 11:28:24 +07:00
|
|
|
leaveTypeId: string;
|
2024-03-12 17:33:22 +07:00
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
nullable: true,
|
|
|
|
|
type: "datetime",
|
2024-03-21 11:28:24 +07:00
|
|
|
comment: "วัน เดือน ปี ที่ลา",
|
2024-03-12 17:33:22 +07:00
|
|
|
default: null,
|
|
|
|
|
})
|
2024-03-21 11:28:24 +07:00
|
|
|
dateLeave: Date;
|
2024-03-12 17:33:22 +07:00
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
nullable: true,
|
|
|
|
|
type: "double",
|
2024-03-21 11:28:24 +07:00
|
|
|
comment: "จำนวนวันลา",
|
2024-03-12 17:33:22 +07:00
|
|
|
default: null,
|
|
|
|
|
})
|
2024-03-21 11:28:24 +07:00
|
|
|
leaveDays: number;
|
2024-03-12 17:33:22 +07:00
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
nullable: true,
|
|
|
|
|
type: "double",
|
2024-03-21 11:28:24 +07:00
|
|
|
comment: "ลามาเเล้ว",
|
2024-03-12 17:33:22 +07:00
|
|
|
default: null,
|
|
|
|
|
})
|
2024-03-21 11:35:07 +07:00
|
|
|
leaveCount: number;
|
2024-03-12 17:33:22 +07:00
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
nullable: true,
|
|
|
|
|
type: "double",
|
|
|
|
|
comment: "รวมเป็น",
|
|
|
|
|
default: null,
|
|
|
|
|
})
|
|
|
|
|
totalLeave: number;
|
|
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
|
nullable: true,
|
|
|
|
|
comment: "สถานะ",
|
|
|
|
|
type: "text",
|
|
|
|
|
default: null,
|
|
|
|
|
})
|
|
|
|
|
status: string;
|
|
|
|
|
|
2024-03-18 17:45:44 +07:00
|
|
|
@Column({
|
2024-03-12 17:33:22 +07:00
|
|
|
nullable: true,
|
|
|
|
|
comment: "เหตุผล",
|
|
|
|
|
type: "text",
|
|
|
|
|
default: null,
|
|
|
|
|
})
|
|
|
|
|
reason: string;
|
|
|
|
|
|
|
|
|
|
@OneToMany(() => ProfileLeaveHistory, (profileLeaveHistory) => profileLeaveHistory.histories)
|
|
|
|
|
profileLeaves: ProfileLeaveHistory[];
|
|
|
|
|
|
2024-03-21 11:28:24 +07:00
|
|
|
@ManyToOne(() => LeaveType, (leaveType) => leaveType.profileLeave)
|
|
|
|
|
@JoinColumn({ name: "leaveTypeId" })
|
|
|
|
|
leaveType: LeaveType;
|
|
|
|
|
|
2024-03-12 17:33:22 +07:00
|
|
|
@ManyToOne(() => Profile, (profile) => profile.profileLeaves)
|
|
|
|
|
@JoinColumn({ name: "profileId" })
|
|
|
|
|
profile: Profile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class CreateProfileLeave {
|
|
|
|
|
profileId: string | null;
|
2024-03-21 11:28:24 +07:00
|
|
|
leaveTypeId: string | null;
|
|
|
|
|
dateLeave: Date | null;
|
|
|
|
|
leaveDays: number | null;
|
|
|
|
|
leverCount: number | null;
|
2024-03-12 17:33:22 +07:00
|
|
|
totalLeave: number | null;
|
|
|
|
|
status: string | null;
|
|
|
|
|
reason: string | null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-18 17:45:44 +07:00
|
|
|
export type UpdateProfileLeave = {
|
2024-03-21 11:28:24 +07:00
|
|
|
dateLeave?: Date | null;
|
|
|
|
|
leaveDays?: number | null;
|
|
|
|
|
leverCount?: number | null;
|
2024-03-19 08:53:43 +07:00
|
|
|
totalLeave?: number | null;
|
|
|
|
|
status?: string | null;
|
|
|
|
|
reason?: string | null;
|
2024-03-18 17:45:44 +07:00
|
|
|
};
|