diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index b8296cd..fe84fb6 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -380,7 +380,7 @@ export class SalaryPeriodEmployeeController extends Controller { salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0 ) { - if (salaryProfile.amount > salaryFormula.salaryMin) { + if (salaryProfile.amount >= salaryFormula.salaryMin) { salary = salaryProfile.amount; } else { salary = salaryFormula.salaryMin; @@ -439,8 +439,22 @@ export class SalaryPeriodEmployeeController extends Controller { }, order: { salaryMonth: "ASC" }, }); - step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5; - group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group; + let _salaryRankAmountMax = await this.salaryRankRepository.findOne({ + where: { + salaryMonth: salaryFormula.salaryMax == null ? 0 : salaryFormula.salaryMax, + salaryEmployee_: { + id: salaryFormula.salaryEmployee.id, + }, + }, + }); + step = + salaryRankMin == null + ? _salaryRankAmountMax == null + ? 0.5 + : _salaryRankAmountMax.step + : salaryRankMin.step - 0.5; + // step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5; + group = salaryFormula.salaryEmployee.group; } else { step = salaryRankMin.step - _step; group = salaryFormula.salaryEmployee.group; @@ -572,7 +586,11 @@ export class SalaryPeriodEmployeeController extends Controller { salaryProfile.amountSpecial = 0; } } else { - if (salaryFormula != null && salaryFormula.salaryMax == salaryProfile.amount) { + if ( + salaryFormula != null && + salaryFormula.salaryMax != null && + salaryFormula.salaryMax <= salaryProfile.amount + ) { let salaryRankAmountMax = await this.salaryRankRepository.findOne({ where: { salaryMonth: salaryFormula.salaryMax, @@ -852,7 +870,7 @@ export class SalaryPeriodEmployeeController extends Controller { salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0 ) { - if (salaryProfile.amount > salaryFormula.salaryMin) { + if (salaryProfile.amount >= salaryFormula.salaryMin) { salary = salaryProfile.amount; } else { salary = salaryFormula.salaryMin; @@ -911,8 +929,21 @@ export class SalaryPeriodEmployeeController extends Controller { }, order: { salaryMonth: "ASC" }, }); - step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5; - group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group; + let _salaryRankAmountMax = await this.salaryRankRepository.findOne({ + where: { + salaryMonth: salaryFormula.salaryMax == null ? 0 : salaryFormula.salaryMax, + salaryEmployee_: { + id: salaryFormula.salaryEmployee.id, + }, + }, + }); + step = + salaryRankMin == null + ? _salaryRankAmountMax == null + ? 0.5 + : _salaryRankAmountMax.step + : salaryRankMin.step - 0.5; + group = salaryFormula.salaryEmployee.group; } else { step = salaryRankMin.step - _step; group = salaryFormula.salaryEmployee.group; @@ -1048,7 +1079,8 @@ export class SalaryPeriodEmployeeController extends Controller { if ( salaryFormula != null && salaryFormula.salaryMax != null && - salaryFormula.salaryMax == salaryProfile.amount + salaryProfile.amount != null && + salaryFormula.salaryMax <= salaryProfile.amount ) { let salaryRankAmountMax = await this.salaryRankRepository.findOne({ where: { @@ -1434,7 +1466,7 @@ export class SalaryPeriodEmployeeController extends Controller { salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0 ) { - if (salaryProfile.amount > salaryFormula.salaryMin) { + if (salaryProfile.amount >= salaryFormula.salaryMin) { salary = salaryProfile.amount; } else { salary = salaryFormula.salaryMin; @@ -1493,8 +1525,21 @@ export class SalaryPeriodEmployeeController extends Controller { }, order: { salaryMonth: "ASC" }, }); - step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5; - group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group; + let _salaryRankAmountMax = await this.salaryRankRepository.findOne({ + where: { + salaryMonth: salaryFormula.salaryMax == null ? 0 : salaryFormula.salaryMax, + salaryEmployee_: { + id: salaryFormula.salaryEmployee.id, + }, + }, + }); + step = + salaryRankMin == null + ? _salaryRankAmountMax == null + ? 0.5 + : _salaryRankAmountMax.step + : salaryRankMin.step - 0.5; + group = salaryFormula.salaryEmployee.group; } else { step = salaryRankMin.step - _step; group = salaryFormula.salaryEmployee.group; @@ -1630,7 +1675,7 @@ export class SalaryPeriodEmployeeController extends Controller { if ( salaryFormula != null && salaryFormula.salaryMax != null && - salaryFormula.salaryMax == salaryProfile.amount + salaryFormula.salaryMax <= salaryProfile.amount ) { let salaryRankAmountMax = await this.salaryRankRepository.findOne({ where: {