From d94ca5480eea4daafb9458d89e9cdf09a366be16 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 3 Apr 2024 16:34:36 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=84=E0=B8=A5=E0=B8=B5=E0=B8=A2?= =?UTF-8?q?=E0=B8=A3=E0=B8=84=E0=B9=88=E0=B8=B2=E0=B8=AA=E0=B8=B3=E0=B8=A3?= =?UTF-8?q?=E0=B8=AD=E0=B8=87=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80?= =?UTF-8?q?=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 6 +++- .../SalaryPeriodEmployeeController.ts | 36 +++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index ef08d50..3c604cd 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -659,6 +659,11 @@ export class SalaryPeriodController extends Controller { ); } } + } + if (body.type == "FULL") { + salaryProfile.isReserve = body.isReserve; + } else { + salaryProfile.isReserve = false; } //Type & Level @@ -692,7 +697,6 @@ export class SalaryPeriodController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง"); } salaryProfile.type = body.type; - salaryProfile.isReserve = body.isReserve; let type = salaryProfile.type; //SalaryRank let salaryRanks: any = null; diff --git a/src/controllers/SalaryPeriodEmployeeController.ts b/src/controllers/SalaryPeriodEmployeeController.ts index 5cb223e..50f164b 100644 --- a/src/controllers/SalaryPeriodEmployeeController.ts +++ b/src/controllers/SalaryPeriodEmployeeController.ts @@ -373,6 +373,7 @@ export class SalaryPeriodEmployeeController extends Controller { if (salaryFormula != null) { //หาเงินตำ่สุดที่คำนวนเงิน let salary = 0; + let _step = 0; if ( salaryProfile.amount != null && salaryProfile.amount > 0 && @@ -383,12 +384,15 @@ export class SalaryPeriodEmployeeController extends Controller { salary = salaryProfile.amount; } else { salary = salaryFormula.salaryMin; + _step = 0.5; } } else { if (salaryProfile.amount != null && salaryProfile.amount > 0) salary = salaryProfile.amount; - if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0) + if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0) { salary = salaryFormula.salaryMin; + _step = 0.5; + } } //หาขั้นต่ำสุดตามเกณฑ์ let salaryRankMin = await this.salaryRankRepository.findOne({ @@ -438,14 +442,14 @@ export class SalaryPeriodEmployeeController extends Controller { step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5; group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group; } else { - step = salaryRankMin.step; + step = salaryRankMin.step - _step; group = salaryFormula.salaryEmployee.group; } } else { step = salaryRankMin.step - 0.5; } } else { - step = salaryRankMin.step; + step = salaryRankMin.step - _step; } } else { step = 0.5; @@ -718,6 +722,11 @@ export class SalaryPeriodEmployeeController extends Controller { } } } + if (body.type == "FULL") { + salaryProfile.isReserve = body.isReserve; + } else { + salaryProfile.isReserve = false; + } //Type & Level const Type = await this.posTypeRepository.findOne({ @@ -737,7 +746,6 @@ export class SalaryPeriodEmployeeController extends Controller { if (!Level) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบระดับตำแหน่ง"); } - salaryProfile.isReserve = body.isReserve; salaryProfile.type = body.type; let type = salaryProfile.type; @@ -783,6 +791,7 @@ export class SalaryPeriodEmployeeController extends Controller { if (salaryFormula != null) { //หาเงินตำ่สุดที่คำนวนเงิน let salary = 0; + let _step = 0; if ( salaryProfile.amount != null && salaryProfile.amount > 0 && @@ -793,12 +802,15 @@ export class SalaryPeriodEmployeeController extends Controller { salary = salaryProfile.amount; } else { salary = salaryFormula.salaryMin; + _step = 0.5; } } else { if (salaryProfile.amount != null && salaryProfile.amount > 0) salary = salaryProfile.amount; - if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0) + if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0) { salary = salaryFormula.salaryMin; + _step = 0.5; + } } //หาขั้นต่ำสุดตามเกณฑ์ let salaryRankMin = await this.salaryRankRepository.findOne({ @@ -848,14 +860,14 @@ export class SalaryPeriodEmployeeController extends Controller { step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5; group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group; } else { - step = salaryRankMin.step; + step = salaryRankMin.step - _step; group = salaryFormula.salaryEmployee.group; } } else { step = salaryRankMin.step - 0.5; } } else { - step = salaryRankMin.step; + step = salaryRankMin.step - _step; } } else { step = 0.5; @@ -1302,6 +1314,7 @@ export class SalaryPeriodEmployeeController extends Controller { if (salaryFormula != null) { //หาเงินตำ่สุดที่คำนวนเงิน let salary = 0; + let _step = 0; if ( salaryProfile.amount != null && salaryProfile.amount > 0 && @@ -1312,12 +1325,15 @@ export class SalaryPeriodEmployeeController extends Controller { salary = salaryProfile.amount; } else { salary = salaryFormula.salaryMin; + _step = 0.5; } } else { if (salaryProfile.amount != null && salaryProfile.amount > 0) salary = salaryProfile.amount; - if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0) + if (salaryFormula.salaryMin != null && salaryFormula.salaryMin > 0) { salary = salaryFormula.salaryMin; + _step = 0.5; + } } //หาขั้นต่ำสุดตามเกณฑ์ let salaryRankMin = await this.salaryRankRepository.findOne({ @@ -1367,14 +1383,14 @@ export class SalaryPeriodEmployeeController extends Controller { step = salaryRankMin == null ? 0.5 : salaryRankMin.step - 0.5; group = salaryRankMin == null ? group : salaryFormula.salaryEmployee.group; } else { - step = salaryRankMin.step; + step = salaryRankMin.step - _step; group = salaryFormula.salaryEmployee.group; } } else { step = salaryRankMin.step - 0.5; } } else { - step = salaryRankMin.step; + step = salaryRankMin.step - _step; } } else { step = 0.5;