import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany, Double } from "typeorm"; import { EntityBase } from "./base/Base"; import { SalaryPeriod } from "./SalaryPeriod"; import { SalaryProfile } from "./SalaryProfile"; @Entity("salaryOrg") export class SalaryOrg extends EntityBase { @Column({ comment: "คีย์นอก(FK)ของตาราง salaryPeriod", length: 40, }) salaryPeriodId: string; @Column({ comment: "สถานะ", }) status: string; @Column({ comment: "คีย์นอก(FK)ของตาราง orgRoot", length: 40, }) rootId: string; @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgRoot Dna", length: 40, }) rootDnaId: string; @Column({ nullable: true, comment: "orgRoot", length: 255, }) root: string; @Column({ nullable: true, comment: "คีย์นอก(FK)ของตาราง orgRevision", length: 40, }) revisionId: string; @Column({ comment: "รอบการ Snapshot", length: 20, default: "SNAP1", }) snapshot: string; @Column({ default: 0, comment: "จำนวนคนทั้งหมด", }) total: number; @Column({ default: 0, comment: "15%ของจำนวนคน(จำนวนเต็ม)", }) fifteenPercent: number; @Column({ comment: "15%ของจำนวนคน(จุดทศนิยม)", type: "double", default: 0, }) fifteenPoint: number; @Column({ comment: "กลุ่ม GROUP1->กลุ่ม1 GROUP2->กลุ่ม2", length: 10, }) group: string; @Column({ comment: "เลือกไปแล้ว", default: 0, }) quantityUsed: number; @Column({ comment: "คงเหลือโควตา", default: 0, }) remainQuota: number; @Column({ comment: "จำนวนเงินคนครองปัจจุบัน", type: "double", default: 0, }) currentAmount: number; @Column({ comment: "วงเงิน6%", type: "double", default: 0, }) sixPercentAmount: number; @Column({ comment: "ยอดเงินที่ใช้ไป", type: "double", default: 0, }) spentAmount: number; @Column({ comment: "ใช้ไปเท่าไหร่", type: "double", default: 0, }) useAmount: number; @Column({ comment: "เหลือเท่าไหร่", type: "double", default: 0, }) remainingAmount: number; @Column({ nullable: true, comment: "คำแนะนำ สกจ", length: 255, }) ownerRecommend: string; @Column({ nullable: true, comment: "คำแนะนำ ผอ", length: 255, }) headRecommend: string; @ManyToOne(() => SalaryPeriod, (salaryPeriod) => salaryPeriod.salaryOrgs) @JoinColumn({ name: "salaryPeriodId" }) salaryPeriod: SalaryPeriod; @OneToMany(() => SalaryProfile, (salaryProfile) => salaryProfile.salaryOrg) salaryProfiles: SalaryProfile[]; } export class CreateSalaryOrg { @Column("uuid") salaryPeriodId: string; @Column() status: string; @Column("uuid") rootId: string; @Column() root: string; @Column() total: number; @Column() fifteenPercent: number; } export type UpdateSalaryOrg = Partial;