diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index b0d128ba..5aeef032 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -86,7 +86,9 @@ export class ProfileSalaryController extends Controller { await this.positionEmployeeRepo.clear(); const profile = await this.profileEmployeeRepo.find(); for await (const x of profile) { - const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [x.id]); + const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [ + x.id, + ]); const _position = position.length > 0 ? position[0] : []; const mapPosition = _position.length > 1 @@ -174,9 +176,11 @@ export class ProfileSalaryController extends Controller { public async cronjobTenureLevelEmployee() { let data: any = []; await this.levelEmployeeRepo.clear(); - const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel"] }); + const profile = await this.profileEmployeeRepo.find({ relations: ["posLevel", "posType"] }); for await (const x of profile) { - const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [x.id]); + const positionLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [ + x.id, + ]); const _positionLevel = positionLevel.length > 0 ? positionLevel[0] : []; const mapPositionLevel = _positionLevel.length > 1 @@ -188,7 +192,11 @@ export class ProfileSalaryController extends Controller { })) : []; const calDayDiff = mapPositionLevel - .filter((curr: any) => curr.positionLevel == (x.posLevel?.posLevelName ?? null)) + .filter( + (curr: any) => + curr.positionLevel == (x.posLevel?.posLevelName ?? null) && + curr.positionType == (x.posType?.posTypeName ?? null), + ) .reduce( (acc: any, curr: any) => { acc.days_diff += Number(curr.days_diff) || 0;