เพิ่มข้อมูล "อายุราชการ (กทม.)" #2285
All checks were successful
Build & Deploy on Dev / build (push) Successful in 49s

This commit is contained in:
harid 2026-02-06 14:47:47 +07:00
parent 5b726e69c8
commit 1696890f74
3 changed files with 10 additions and 2 deletions

View file

@ -127,6 +127,7 @@ export class ProfileGovernmentHistoryController extends Controller {
dateRetireLaw: record.dateRetireLaw ?? null,
// govAge: record.dateStart == null ? null : calculateAge(record.dateStart),
govAge: await calculateGovAge(profile.id, "OFFICER"),
govAgeBkk: await calculateGovAge(profile.id, "OFFICER", true),
dateAppoint: record.dateAppoint,
dateStart: record.dateStart,
govAgeAbsent: record.govAgeAbsent,
@ -310,6 +311,7 @@ export class ProfileGovernmentHistoryController extends Controller {
dateRetireLaw: record?.dateRetireLaw ?? null,
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart),
govAge: await calculateGovAge(profileId, "OFFICER"),
govAgeBkk: await calculateGovAge(profileId, "OFFICER", true),
dateAppoint: record?.dateAppoint,
dateStart: record?.dateStart,
govAgeAbsent: record?.govAgeAbsent,
@ -483,6 +485,7 @@ export class ProfileGovernmentHistoryController extends Controller {
dateRetireLaw: record?.dateRetireLaw ?? null,
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart),
govAge: await calculateGovAge(profileId, "OFFICER"),
govAgeBkk: await calculateGovAge(profileId, "OFFICER", true),
dateAppoint: record?.dateAppoint,
dateStart: record?.dateStart,
govAgeAbsent: record?.govAgeAbsent,

View file

@ -121,6 +121,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
dateRetireLaw: record.dateRetireLaw ?? null,
// govAge: record.dateStart == null ? null : calculateAge(record.dateStart),
govAge: await calculateGovAge(profile.id, "EMPLOYEE"),
govAgeBkk: await calculateGovAge(profile.id, "EMPLOYEE", true),
dateAppoint: record.dateAppoint,
dateStart: record.dateStart,
govAgeAbsent: record.govAgeAbsent,
@ -292,6 +293,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
dateRetire: record?.dateRetire ?? null, //วันครบเกษียณอายุ
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart), //อายุราชการ
govAge: await calculateGovAge(profileEmployeeId, "EMPLOYEE"),
govAgeBkk: await calculateGovAge(profileEmployeeId, "EMPLOYEE", true),
govAgeAbsent: record?.govAgeAbsent ?? null, // ขาดราชการ
govAgePlus: record?.govAgePlus, // อายุราชการเกื้อกูล
dateRetireLaw: record?.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย
@ -451,6 +453,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
dateRetire: record?.dateRetire ?? null, //วันครบเกษียณอายุ
// govAge: record?.dateStart == null ? null : calculateAge(record?.dateStart), //อายุราชการ
govAge: await calculateGovAge(profileEmployeeId, "EMPLOYEE"),
govAgeBkk: await calculateGovAge(profileEmployeeId, "EMPLOYEE", true),
govAgeAbsent: record?.govAgeAbsent ?? null, // ขาดราชการ
govAgePlus: record?.govAgePlus, // อายุราชการเกื้อกูล
dateRetireLaw: record?.dateRetireLaw ?? null, // วันที่เกษียฯอายุราชการตามกฎหมาย

View file

@ -44,7 +44,7 @@ export function calculateAge(start: Date, end = new Date()) {
return { year, month, day };
}
export async function calculateGovAge(profileId: string, type: string) {
export async function calculateGovAge(profileId: string, type: string, bkk?: boolean) {
// type = OFFICER , EMPLOYEE
const isEmployee = type === "EMPLOYEE";
@ -107,7 +107,9 @@ export async function calculateGovAge(profileId: string, type: string) {
});
}
// const firstStartDate = new Date(records[0].date);
const firstStartDate = profile?.dateAppoint ? profile?.dateAppoint : new Date();
const firstStartDate = !bkk
? profile?.dateAppoint ? profile?.dateAppoint : new Date()
: profile?.dateStart ? profile?.dateStart : new Date() ;
const firstEndDate = endDateFristRec ? new Date(endDateFristRec.dateGovernment) : new Date();
// console.log("firstStartDate1", firstStartDate);