From b049632ef7cf730d2179e7549da445ff75e94b70 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 4 Apr 2024 11:51:05 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84=E0=B8=B3?= =?UTF-8?q?=E0=B8=99=E0=B8=A7=E0=B8=99=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=A5=E0=B8=B9?= =?UTF-8?q?=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SalaryPeriodEmployeeController.ts | 69 +++++++++++++++---- 1 file changed, 57 insertions(+), 12 deletions(-) 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: {