fixing bug
This commit is contained in:
parent
9fa83891f2
commit
3c0d83631f
1 changed files with 18 additions and 16 deletions
|
|
@ -39,7 +39,9 @@ export class ProfileSalaryController extends Controller {
|
|||
@Get("XXX")
|
||||
public async cronjobTenurePositionOfficer() {
|
||||
let data: any = [];
|
||||
const profile = await this.profileRepo.find({where:{id: "09e89026-c420-4136-bd9e-7e408f530b69"}})
|
||||
const profile = await this.profileRepo.find({
|
||||
where: { id: "09e89026-c420-4136-bd9e-7e408f530b69" },
|
||||
});
|
||||
await Promise.all(
|
||||
profile.map(async (x) => {
|
||||
const sql_mode = await AppDataSource.query(
|
||||
|
|
@ -49,22 +51,21 @@ export class ProfileSalaryController extends Controller {
|
|||
const _position = position.length > 0 ? position[0] : [];
|
||||
const mapPosition =
|
||||
_position.length > 1
|
||||
? _position.slice(1)
|
||||
.map((curr: any, index: number) => ({
|
||||
? _position.slice(1).map((curr: any, index: number) => ({
|
||||
days_diff: curr.days_diff,
|
||||
positionName: _position[index]?.positionName,
|
||||
}))
|
||||
}))
|
||||
: [];
|
||||
const calDayDiff = mapPosition
|
||||
.filter((curr: any) => curr.positionName == x.position)
|
||||
.reduce(
|
||||
(acc: any, curr: any) => {
|
||||
acc.days_diff += Number(curr.days_diff) || 0;
|
||||
acc.days_diff += Number(curr.days_diff) || 0;
|
||||
return acc;
|
||||
},
|
||||
{ days_diff: 0}
|
||||
{ days_diff: 0 },
|
||||
);
|
||||
console.log("==========> ", calDayDiff)
|
||||
console.log("==========> ", calDayDiff);
|
||||
const _mapData = {
|
||||
profileId: x.id,
|
||||
positionName: x.position,
|
||||
|
|
@ -72,13 +73,13 @@ export class ProfileSalaryController extends Controller {
|
|||
Years: null,
|
||||
Months: null,
|
||||
Days: null,
|
||||
}
|
||||
};
|
||||
data.push(_mapData);
|
||||
})
|
||||
}),
|
||||
|
||||
// await this.positionOfficerRepo.save(data);
|
||||
);
|
||||
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
@Get("user")
|
||||
|
|
@ -216,12 +217,13 @@ export class ProfileSalaryController extends Controller {
|
|||
// 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,
|
||||
name: !_posLevel[index]?.positionType
|
||||
? `ระดับ ${_posLevel[index]?.positionCee.trim()}`
|
||||
: _posLevel[index]?.positionType == "บริหาร" ||
|
||||
_posLevel[index]?.positionType == "อำนวยการ"
|
||||
? `${_posLevel[index]?.positionType}${_posLevel[index]?.positionLevel}`
|
||||
: _posLevel[index]?.positionLevel,
|
||||
name:
|
||||
!_posLevel[index]?.positionType && _posLevel[index]?.positionCee
|
||||
? `ระดับ ${_posLevel[index]?.positionCee.trim()}`
|
||||
: _posLevel[index]?.positionType == "บริหาร" ||
|
||||
_posLevel[index]?.positionType == "อำนวยการ"
|
||||
? `${_posLevel[index]?.positionType}${_posLevel[index]?.positionLevel}`
|
||||
: _posLevel[index]?.positionLevel,
|
||||
}))
|
||||
: [];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue