import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; // Enums export enum AbsentLateStatus { LATE = "LATE", // มาสาย ABSENT = "ABSENT", // ขาดราชการ } export enum StampType { FULL_DAY = "FULL_DAY", // เต็มวัน MORNING = "MORNING", // ครึ่งเช้า AFTERNOON = "AFTERNOON", // ครึ่งบ่าย } @Entity("profileAbsentLate") export class ProfileAbsentLate extends EntityBase { @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง Profile", default: null, }) profileId: string; @Column({ type: "enum", enum: AbsentLateStatus, comment: "สถานะ มาสาย/ขาดราชการ", nullable: false, }) status: AbsentLateStatus; @Column({ type: "datetime", comment: "วันที่และเวลาที่ลงเวลา", nullable: false, }) stampDate: Date; @Column({ type: "enum", enum: StampType, comment: "เต็มวัน/ครึ่งเช้า/ครึ่งบ่าย", default: StampType.FULL_DAY, }) stampType: StampType; @Column({ type: "decimal", precision: 2, scale: 1, comment: "จำนวน (1.0/0.5)", default: "1.0", }) stampAmount: number; @Column({ type: "varchar", length: 250, comment: "หมายเหตุ", nullable: true, }) remark: string; @Column({ comment: "สถานะลบข้อมูล", default: false, }) isDeleted: boolean; @ManyToOne(() => Profile, (profile) => profile.profileAbsentLates) @JoinColumn({ name: "profileId" }) profile: Profile; } // DTO Classes export class CreateProfileAbsentLate { profileId: string; status: AbsentLateStatus; stampDate: Date; stampType?: StampType; stampAmount?: number; remark?: string; } export class CreateProfileAbsentLateBatch { records: CreateProfileAbsentLate[]; } export type UpdateProfileAbsentLate = { status?: AbsentLateStatus; stampDate?: Date; stampType?: StampType; stampAmount?: number; remark?: string; };