This commit is contained in:
fro1991
2026-01-06 22:45:01 +07:00
parent 92863f2d65
commit 2ab9cb84d2

View File

@ -1,14 +1,4 @@
import { import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToOne, JoinColumn, Index } from "typeorm";
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
ManyToOne,
JoinColumn,
Index,
} from "typeorm";
import { Status } from "../../types/status"; import { Status } from "../../types/status";
import { HrmsEmployee } from "./hrms_employee"; import { HrmsEmployee } from "./hrms_employee";
import { HrmsPayroll } from "./hrms_payroll"; import { HrmsPayroll } from "./hrms_payroll";
@ -16,100 +6,35 @@ import { HrmsPayroll } from "./hrms_payroll";
@Entity("hrms_payroll_monthly", { schema: "hrms" }) @Entity("hrms_payroll_monthly", { schema: "hrms" })
@Index(["employee", "period_month", "period_year"], { unique: true }) @Index(["employee", "period_month", "period_year"], { unique: true })
export class HrmsPayrollMonthly { export class HrmsPayrollMonthly {
@PrimaryGeneratedColumn("uuid") @PrimaryGeneratedColumn("uuid")
id: string; id: string;
@ManyToOne(() => HrmsEmployee, { onDelete: "RESTRICT", nullable: true }) @ManyToOne(() => HrmsEmployee, { onDelete: "RESTRICT", nullable: true })
@JoinColumn() @JoinColumn()
employee: HrmsEmployee; employee: HrmsEmployee;
@ManyToOne(() => HrmsPayroll, { onDelete: "RESTRICT", nullable: true }) @ManyToOne(() => HrmsPayroll, { onDelete: "RESTRICT", nullable: true })
@JoinColumn() @JoinColumn()
payroll_setup: HrmsPayroll; payroll_setup: HrmsPayroll;
@Column({ type: "int", nullable: false }) @Column({ type: "text", nullable: true })
period_month: number; // 1-12 notes: string;
@Column({ type: "int", nullable: false }) @CreateDateColumn()
period_year: number; // e.g., 2026 created_at: Date;
// Payroll Setup Data (snapshot at the time of generation) @Column({ nullable: true, length: 256 })
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false }) created_by: string;
basic_salary: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 }) @UpdateDateColumn({ nullable: true })
subsidy: number; updated_at: Date;
// Working Days Calculation @Column({ nullable: true, length: 256 })
@Column({ type: "int", nullable: false }) updated_by: string;
working_days_in_month: number;
@Column({ type: "int", nullable: false, default: 0 }) @DeleteDateColumn({ nullable: true })
days_present: number; deleted_at: Date;
@Column({ type: "int", nullable: false, default: 0 }) @Column({ nullable: true, length: 256 })
days_absent: number; deleted_by: string;
@Column({ type: "int", nullable: false, default: 0 })
unpaid_leave_days: number;
// Deductions for Absences
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
deduction_absence: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
deduction_unpaid_leave: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
total_attendance_deduction: number;
// Recalculated Amounts
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false })
adjusted_basic_salary: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false })
total_gross: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
ss_4_percent: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
ss_6_percent: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
ss_total: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
tax_amount: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
total_deduct: number;
@Column({ type: "decimal", precision: 15, scale: 2, nullable: false, default: 0 })
total_nett: number;
@Column({ length: 64 })
status: Status;
@Column({ type: "text", nullable: true })
notes: string;
@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;
} }