ระยะเวลาดำรงตำแหน่งลูกจ้าง #1245
This commit is contained in:
parent
c778b52e8b
commit
e09317203e
1 changed files with 112 additions and 26 deletions
|
|
@ -100,24 +100,67 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
const mapPosition =
|
||||
_position.length > 1
|
||||
? _position.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,
|
||||
name: _position[index]?.positionName,
|
||||
}))
|
||||
: [];
|
||||
|
||||
const posLevel: any = [
|
||||
// {
|
||||
// year: 3,
|
||||
// month: 0,
|
||||
// day: 0,
|
||||
// name: "ส 1",
|
||||
// }
|
||||
];
|
||||
const groupMapPosition = mapPosition.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
let existing = acc.find((item: any) => item.name === curr.name);
|
||||
|
||||
if (existing) {
|
||||
existing.days += curr.days;
|
||||
} else {
|
||||
existing = { name: curr.name, days: curr.days };
|
||||
acc.push(existing);
|
||||
}
|
||||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [profile.id]);
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const mapPosLevel =
|
||||
_posLevel.length > 1
|
||||
? _posLevel.slice(1).map((curr: any, index: number) => ({
|
||||
days: curr.days_diff ? Number(curr.days_diff) : 0,
|
||||
name:
|
||||
!_posLevel[index]?.positionType && _posLevel[index]?.positionCee
|
||||
? `ระดับ ${_posLevel[index]?.positionCee.trim()}`
|
||||
: _posLevel[index]?.positionLevel,
|
||||
}))
|
||||
: [];
|
||||
|
||||
const groupMapPosLevel = mapPosLevel.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
let existing = acc.find((item: any) => item.name === curr.name);
|
||||
|
||||
if (existing) {
|
||||
existing.days += curr.days;
|
||||
} else {
|
||||
existing = { name: curr.name, days: curr.days };
|
||||
acc.push(existing);
|
||||
}
|
||||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
return new HttpSuccess({
|
||||
position: mapPosition,
|
||||
posLevel: posLevel,
|
||||
position: groupMapPosition,
|
||||
posLevel: groupMapPosLevel,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -130,24 +173,67 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
const mapPosition =
|
||||
_position.length > 1
|
||||
? _position.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,
|
||||
name: _position[index]?.positionName,
|
||||
}))
|
||||
: [];
|
||||
|
||||
const posLevel: any = [
|
||||
// {
|
||||
// year: 3,
|
||||
// month: 0,
|
||||
// day: 0,
|
||||
// name: "ส 1",
|
||||
// }
|
||||
];
|
||||
const groupMapPosition = mapPosition.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
let existing = acc.find((item: any) => item.name === curr.name);
|
||||
|
||||
if (existing) {
|
||||
existing.days += curr.days;
|
||||
} else {
|
||||
existing = { name: curr.name, days: curr.days };
|
||||
acc.push(existing);
|
||||
}
|
||||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [profileId]);
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const mapPosLevel =
|
||||
_posLevel.length > 1
|
||||
? _posLevel.slice(1).map((curr: any, index: number) => ({
|
||||
days: curr.days_diff ? Number(curr.days_diff) : 0,
|
||||
name:
|
||||
!_posLevel[index]?.positionType && _posLevel[index]?.positionCee
|
||||
? `ระดับ ${_posLevel[index]?.positionCee.trim()}`
|
||||
: _posLevel[index]?.positionLevel,
|
||||
}))
|
||||
: [];
|
||||
|
||||
const groupMapPosLevel = mapPosLevel.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
let existing = acc.find((item: any) => item.name === curr.name);
|
||||
|
||||
if (existing) {
|
||||
existing.days += curr.days;
|
||||
} else {
|
||||
existing = { name: curr.name, days: curr.days };
|
||||
acc.push(existing);
|
||||
}
|
||||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
return new HttpSuccess({
|
||||
position: mapPosition,
|
||||
posLevel: posLevel,
|
||||
position: groupMapPosition,
|
||||
posLevel: groupMapPosLevel,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue