This commit is contained in:
Narul Hidayah
2026-01-02 03:33:21 +07:00
parent 4ce075fe5e
commit 6ea1c02a44
4 changed files with 166 additions and 0 deletions

View File

@ -0,0 +1,70 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
ManyToOne,
JoinColumn,
OneToMany,
} from "typeorm";
import { Status } from "../../types/status";
import { HrmsEmployee } from "./hrms_employee";
import { HrmsLeaveType } from "./hrms_leave_type";
import { HrmsLeaveApproval } from "./hrms_leave_approval";
import { HrmsLeaveDocument } from "./hrms_leave_document";
@Entity("hrms_leaves", { schema: "hrms" })
export class HrmsLeave {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => HrmsEmployee, { onDelete: "RESTRICT", nullable: false })
@JoinColumn({ name: "employee_id" })
employee: HrmsEmployee;
@ManyToOne(() => HrmsLeaveType, { onDelete: "RESTRICT", nullable: false })
@JoinColumn({ name: "leave_type_id" })
leave_type: HrmsLeaveType;
@Column({ type: "date", nullable: false })
start_date: Date;
@Column({ type: "date", nullable: false })
end_date: Date;
@Column({ type: "int", nullable: false })
duration_days: number;
@Column({ length: 512, nullable: true })
reason: string;
@Column({ length: 64, nullable: false })
status: Status;
@OneToMany(() => HrmsLeaveApproval, approval => approval.leave, { cascade: true })
approvals: HrmsLeaveApproval[];
@OneToMany(() => HrmsLeaveDocument, document => document.leave, { cascade: true })
documents: HrmsLeaveDocument[];
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true, length: 256 })
created_by: string;
@UpdateDateColumn({ nullable: true })
updated_at: Date;
@Column({ nullable: true, length: 256 })
updated_by: string;
@DeleteDateColumn({ nullable: true })
deleted_at: Date;
@Column({ nullable: true, length: 256 })
deleted_by: string;
}

View File

@ -0,0 +1,64 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
JoinColumn,
} from "typeorm";
import { HrmsLeave } from "./hrms_leave";
import { HrmsEmployee } from "./hrms_employee";
export enum ApprovalType {
SPV = "SPV",
HR = "HR",
}
export enum ApprovalStatus {
PENDING = "PENDING",
APPROVED = "APPROVED",
REJECTED = "REJECTED",
}
@Entity("hrms_leave_approvals", { schema: "hrms" })
export class HrmsLeaveApproval {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => HrmsLeave, leave => leave.approvals, { onDelete: "CASCADE", nullable: false })
@JoinColumn({ name: "leave_id" })
leave: HrmsLeave;
@Column({
type: "enum",
enum: ApprovalType,
nullable: false,
})
approval_type: ApprovalType;
@ManyToOne(() => HrmsEmployee, { onDelete: "RESTRICT", nullable: false })
@JoinColumn({ name: "approver_id" })
approver: HrmsEmployee;
@Column({
type: "enum",
enum: ApprovalStatus,
default: ApprovalStatus.PENDING,
nullable: false,
})
status: ApprovalStatus;
@Column({ type: "timestamp", nullable: true })
approved_at: Date;
@Column({ length: 512, nullable: true })
notes: string;
@CreateDateColumn()
created_at: Date;
@UpdateDateColumn({ nullable: true })
updated_at: Date;
}

View File

@ -0,0 +1,29 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
} from "typeorm";
import { HrmsLeave } from "./hrms_leave";
@Entity("hrms_leave_documents", { schema: "hrms" })
export class HrmsLeaveDocument {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => HrmsLeave, leave => leave.documents, { onDelete: "CASCADE", nullable: false })
@JoinColumn({ name: "leave_id" })
leave: HrmsLeave;
@Column({ length: 256, nullable: false })
document_name: string;
@Column({ length: 512, nullable: false })
document_url: string;
@CreateDateColumn()
created_at: Date;
}

View File

@ -11,5 +11,8 @@ export * from "../entity/hrms/hrms_training_participant";
export * from "../entity/hrms/hrms_bank"; export * from "../entity/hrms/hrms_bank";
export * from "../entity/hrms/hrms_payroll"; export * from "../entity/hrms/hrms_payroll";
export * from "../entity/hrms/hrms_payroll_monthly"; export * from "../entity/hrms/hrms_payroll_monthly";
export * from "../entity/hrms/hrms_leave";
export * from "../entity/hrms/hrms_leave_approval";
export * from "../entity/hrms/hrms_leave_document";
export * from "../types/hrms"; export * from "../types/hrms";