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