fixed calculate tenure (สูตรคำนวนอายุราชการจาก diff date)
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m6s

This commit is contained in:
Warunee Tamkoo 2026-04-20 18:20:20 +07:00
parent 5e52206987
commit 7e3982a96d
3 changed files with 85 additions and 57 deletions

View file

@ -27,6 +27,7 @@ import { Profile } from "../entities/Profile";
import { In, LessThan, IsNull, MoreThan } from "typeorm";
import permission from "../interfaces/permission";
import { setLogDataDiff } from "../interfaces/utils";
import { calculateTenure } from "../utils/tenure";
import { Command } from "../entities/Command";
import { OrgRoot } from "../entities/OrgRoot";
import Extension from "../interfaces/extension";
@ -175,9 +176,10 @@ export class ProfileSalaryEmployeeController extends Controller {
acc.push(existing);
}
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.ceil(existing.days % 30.4375);
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
return acc;
},
@ -211,9 +213,10 @@ export class ProfileSalaryEmployeeController extends Controller {
acc.push(existing);
}
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.ceil(existing.days % 30.4375);
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
return acc;
},
@ -266,9 +269,10 @@ export class ProfileSalaryEmployeeController extends Controller {
acc.push(existing);
}
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.ceil(existing.days % 30.4375);
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
return acc;
},
@ -302,9 +306,10 @@ export class ProfileSalaryEmployeeController extends Controller {
acc.push(existing);
}
existing.year = Math.floor(existing.days / 365.2524);
existing.month = Math.floor((existing.days / 30.4375) % 12);
existing.day = Math.ceil(existing.days % 30.4375);
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
return acc;
},