From baca5ff758f23a07c176ba8fb0a87732ee94502d Mon Sep 17 00:00:00 2001 From: Narul Hidayah Date: Mon, 2 Feb 2026 20:02:59 +0700 Subject: [PATCH] upd --- src/entity/hrms/hrms_attendance.ts | 3 +- src/entity/hrms/hrms_attendance_request.ts | 71 ++++++++++++++++++++++ src/schema/hrms.ts | 1 + 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/entity/hrms/hrms_attendance_request.ts diff --git a/src/entity/hrms/hrms_attendance.ts b/src/entity/hrms/hrms_attendance.ts index cac059d..ec7942e 100644 --- a/src/entity/hrms/hrms_attendance.ts +++ b/src/entity/hrms/hrms_attendance.ts @@ -24,8 +24,9 @@ export class HrmsAttendance { }) date_at: Date; + /** Nullable when record created from break punch only (no clock in) */ @Column({ - nullable: false, + nullable: true, }) in_at: Date; diff --git a/src/entity/hrms/hrms_attendance_request.ts b/src/entity/hrms/hrms_attendance_request.ts new file mode 100644 index 0000000..f78602c --- /dev/null +++ b/src/entity/hrms/hrms_attendance_request.ts @@ -0,0 +1,71 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, +} from "typeorm"; +import { HrmsEmployee } from "./hrms_employee"; + +export type AttendanceRequestStatus = "PENDING" | "APPROVED" | "REJECTED"; + +/** Type of punch being requested: maps to attendance column on approve */ +export type AttendanceRequestType = "in" | "break_out" | "break_in" | "out"; + +@Entity("hrms_attendance_requests", { schema: "hrms" }) +export class HrmsAttendanceRequest { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => HrmsEmployee, { onDelete: "RESTRICT", nullable: false }) + @JoinColumn() + employee: HrmsEmployee; + + /** Type of punch: in → in_at, break_out → break_out_at, break_in → break_in_at, out → out_at */ + @Column({ length: 32, nullable: false }) + type: AttendanceRequestType; + + @Column({ type: "date", nullable: false }) + date_at: Date; + + /** Requested time for this punch (used for the column indicated by type) */ + @Column({ type: "timestamp", nullable: false }) + requested_at: Date; + + /** Employee reason on submit; supervisor can set when rejecting */ + @Column({ type: "text", nullable: true }) + remark: string; + + @Column({ length: 32, nullable: false, default: "PENDING" }) + status: AttendanceRequestStatus; + + @ManyToOne(() => HrmsEmployee, { onDelete: "SET NULL", nullable: true }) + @JoinColumn() + approved_by: HrmsEmployee; + + @Column({ type: "timestamp", nullable: true }) + approved_at: Date; + + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/schema/hrms.ts b/src/schema/hrms.ts index a6978e4..6835b57 100644 --- a/src/schema/hrms.ts +++ b/src/schema/hrms.ts @@ -10,6 +10,7 @@ export * from "../entity/hrms/hrms_training"; export * from "../entity/hrms/hrms_training_participant"; export * from "../entity/hrms/hrms_bank"; export * from "../entity/hrms/hrms_attendance"; +export * from "../entity/hrms/hrms_attendance_request"; export * from "../entity/hrms/hrms_payroll"; export * from "../entity/hrms/hrms_payroll_monthly"; export * from "../entity/hrms/hrms_leave";