fixed #2413 จำนวนวันอายุราชการแสดงไม่ตรงกัน
All checks were successful
Build & Deploy on Dev / build (push) Successful in 58s

This commit is contained in:
Warunee Tamkoo 2026-05-12 17:24:15 +07:00
parent e64cd3f384
commit 334ce4f5fc
5 changed files with 528 additions and 52 deletions

View file

@ -595,6 +595,10 @@ export class ProfileSalaryController extends Controller {
_position.length > 1
? _position.slice(1).map((curr: any, index: number) => ({
days: curr.days_diff ? Number(curr.days_diff) : 0,
// Use stored procedure's calculated values (calendar arithmetic)
year: curr.Years !== null && curr.Years !== undefined ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months !== null && curr.Months !== undefined ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days !== null && curr.Days !== undefined ? Math.floor(Number(curr.Days)) : 0,
name: _position[index]?.positionName,
}))
: [];
@ -605,15 +609,23 @@ export class ProfileSalaryController extends Controller {
if (existing) {
existing.days += curr.days;
existing.year += curr.year;
existing.month += curr.month;
existing.day += curr.day;
} else {
existing = { name: curr.name, days: curr.days };
existing = { name: curr.name, days: curr.days, year: curr.year, month: curr.month, day: curr.day };
acc.push(existing);
}
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
// Normalize the summed values (convert excess days to months, months to years)
while (existing.day >= 30) {
existing.month += Math.floor(existing.day / 30);
existing.day = existing.day % 30;
}
while (existing.month >= 12) {
existing.year += Math.floor(existing.month / 12);
existing.month = existing.month % 12;
}
return acc;
},
@ -628,6 +640,10 @@ export class ProfileSalaryController extends Controller {
_posLevel.length > 1
? _posLevel.slice(1).map((curr: any, index: number) => ({
days: curr.days_diff ? Number(curr.days_diff) : 0,
// Use stored procedure's calculated values (calendar arithmetic)
year: curr.Years !== null && curr.Years !== undefined ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months !== null && curr.Months !== undefined ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days !== null && curr.Days !== undefined ? Math.floor(Number(curr.Days)) : 0,
name:
!_posLevel[index]?.positionType && _posLevel[index]?.positionCee
? `ระดับ ${_posLevel[index]?.positionCee.trim()}`
@ -644,15 +660,23 @@ export class ProfileSalaryController extends Controller {
if (existing) {
existing.days += curr.days;
existing.year += curr.year;
existing.month += curr.month;
existing.day += curr.day;
} else {
existing = { name: curr.name, days: curr.days };
existing = { name: curr.name, days: curr.days, year: curr.year, month: curr.month, day: curr.day };
acc.push(existing);
}
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
// Normalize the summed values (convert excess days to months, months to years)
while (existing.day >= 30) {
existing.month += Math.floor(existing.day / 30);
existing.day = existing.day % 30;
}
while (existing.month >= 12) {
existing.year += Math.floor(existing.month / 12);
existing.month = existing.month % 12;
}
return acc;
},
@ -668,6 +692,10 @@ export class ProfileSalaryController extends Controller {
_posExecutive.length > 1
? _posExecutive.slice(1).map((curr: any, index: number) => ({
days: curr.days_diff ? Number(curr.days_diff) : 0,
// Use stored procedure's calculated values (calendar arithmetic)
year: curr.Years !== null && curr.Years !== undefined ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months !== null && curr.Months !== undefined ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days !== null && curr.Days !== undefined ? Math.floor(Number(curr.Days)) : 0,
name: _posExecutive[index]?.positionExecutive,
}))
: [];
@ -678,15 +706,23 @@ export class ProfileSalaryController extends Controller {
if (existing) {
existing.days += curr.days;
existing.year += curr.year;
existing.month += curr.month;
existing.day += curr.day;
} else {
existing = { name: curr.name, days: curr.days };
existing = { name: curr.name, days: curr.days, year: curr.year, month: curr.month, day: curr.day };
acc.push(existing);
}
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
// Normalize the summed values (convert excess days to months, months to years)
while (existing.day >= 30) {
existing.month += Math.floor(existing.day / 30);
existing.day = existing.day % 30;
}
while (existing.month >= 12) {
existing.year += Math.floor(existing.month / 12);
existing.month = existing.month % 12;
}
return acc;
},
@ -729,9 +765,10 @@ export class ProfileSalaryController extends Controller {
_position.length > 1
? _position.slice(1).map((curr: any, index: number) => ({
days: curr.days_diff ? Number(curr.days_diff) : 0,
// year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
// month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
// day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
// Use stored procedure's calculated values (calendar arithmetic)
year: curr.Years !== null && curr.Years !== undefined ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months !== null && curr.Months !== undefined ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days !== null && curr.Days !== undefined ? Math.floor(Number(curr.Days)) : 0,
name: _position[index]?.positionName,
}))
: [];
@ -742,15 +779,23 @@ export class ProfileSalaryController extends Controller {
if (existing) {
existing.days += curr.days;
existing.year += curr.year;
existing.month += curr.month;
existing.day += curr.day;
} else {
existing = { name: curr.name, days: curr.days };
existing = { name: curr.name, days: curr.days, year: curr.year, month: curr.month, day: curr.day };
acc.push(existing);
}
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
// Normalize the summed values (convert excess days to months, months to years)
while (existing.day >= 30) {
existing.month += Math.floor(existing.day / 30);
existing.day = existing.day % 30;
}
while (existing.month >= 12) {
existing.year += Math.floor(existing.month / 12);
existing.month = existing.month % 12;
}
return acc;
},
@ -766,9 +811,10 @@ export class ProfileSalaryController extends Controller {
_posLevel.length > 1
? _posLevel.slice(1).map((curr: any, index: number) => ({
days: curr.days_diff ? Number(curr.days_diff) : 0,
// year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
// month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
// day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
// Use stored procedure's calculated values (calendar arithmetic)
year: curr.Years !== null && curr.Years !== undefined ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months !== null && curr.Months !== undefined ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days !== null && curr.Days !== undefined ? Math.floor(Number(curr.Days)) : 0,
name:
!_posLevel[index]?.positionType && _posLevel[index]?.positionCee
? `ระดับ ${_posLevel[index]?.positionCee.trim()}`
@ -785,15 +831,23 @@ export class ProfileSalaryController extends Controller {
if (existing) {
existing.days += curr.days;
existing.year += curr.year;
existing.month += curr.month;
existing.day += curr.day;
} else {
existing = { name: curr.name, days: curr.days };
existing = { name: curr.name, days: curr.days, year: curr.year, month: curr.month, day: curr.day };
acc.push(existing);
}
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
// Normalize the summed values (convert excess days to months, months to years)
while (existing.day >= 30) {
existing.month += Math.floor(existing.day / 30);
existing.day = existing.day % 30;
}
while (existing.month >= 12) {
existing.year += Math.floor(existing.month / 12);
existing.month = existing.month % 12;
}
return acc;
},
@ -808,10 +862,11 @@ export class ProfileSalaryController extends Controller {
const mapPosExecutive =
_posExecutive.length > 1
? _posExecutive.slice(1).map((curr: any, index: number) => ({
// year: curr.Years ? Math.floor(Number(curr.Years)) : 0,
// month: curr.Months ? Math.floor(Number(curr.Months)) : 0,
// day: curr.Days ? Math.floor(Number(curr.Days)) : 0,
days: curr.days_diff ? Number(curr.days_diff) : 0,
// Use stored procedure's calculated values (calendar arithmetic)
year: curr.Years !== null && curr.Years !== undefined ? Math.floor(Number(curr.Years)) : 0,
month: curr.Months !== null && curr.Months !== undefined ? Math.floor(Number(curr.Months)) : 0,
day: curr.Days !== null && curr.Days !== undefined ? Math.floor(Number(curr.Days)) : 0,
name: _posExecutive[index]?.positionExecutive,
}))
: [];
@ -822,15 +877,23 @@ export class ProfileSalaryController extends Controller {
if (existing) {
existing.days += curr.days;
existing.year += curr.year;
existing.month += curr.month;
existing.day += curr.day;
} else {
existing = { name: curr.name, days: curr.days };
existing = { name: curr.name, days: curr.days, year: curr.year, month: curr.month, day: curr.day };
acc.push(existing);
}
const { year, month, day } = calculateTenure(existing.days);
existing.year = year;
existing.month = month;
existing.day = day;
// Normalize the summed values (convert excess days to months, months to years)
while (existing.day >= 30) {
existing.month += Math.floor(existing.day / 30);
existing.day = existing.day % 30;
}
while (existing.month >= 12) {
existing.year += Math.floor(existing.month / 12);
existing.month = existing.month % 12;
}
return acc;
},