From 168e59fdf43217fae4b441e337db852b81d32a73 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 2 Apr 2024 13:33:08 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=84=E0=B8=B3=E0=B8=99=E0=B8=A7=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7?= =?UTF-8?q?=E0=B8=AD=E0=B8=99=20=E0=B8=81=E0=B8=A3=E0=B8=93=E0=B8=B5?= =?UTF-8?q?=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B8=9E=E0=B8=AD=E0=B8=94=E0=B8=B5?= =?UTF-8?q?=E0=B8=90=E0=B8=B2=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 47 +++++------------------ 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 9acc35e..5d510f3 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -13,7 +13,7 @@ import { Query, } from "tsoa"; import { AppDataSource } from "../database/data-source"; -import { In, Not, MoreThan, Brackets, Like } from "typeorm"; +import { In, Not, MoreThan, Brackets, Like, MoreThanOrEqual } from "typeorm"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatusCode from "../interfaces/http-status"; @@ -385,20 +385,11 @@ export class SalaryPeriodController extends Controller { salaryRanks = await this.salaryRankRepository.findOne({ where: { salaryId: salarys.id, - salary: salaryProfile.amount, + salary: MoreThanOrEqual(salaryProfile.amount), isNext: false, }, + order: { salary: "ASC" }, }); - if (salaryRanks == null) { - salaryRanks = await this.salaryRankRepository.findOne({ - where: { - salaryId: salarys.id, - salary: MoreThan(salaryProfile.amount), - isNext: false, - }, - order: { salary: "DESC" }, - }); - } if (salaryRanks != null) { if (salaryProfile.type == "HAFT") { if (salaryRanks.salaryHalfSpecial != null && salaryRanks.salaryHalfSpecial > 0) { @@ -457,7 +448,7 @@ export class SalaryPeriodController extends Controller { salary: MoreThan(salaryProfile.amount), isNext: true, }, - order: { salary: "DESC" }, + order: { salary: "ASC" }, }); } } @@ -707,20 +698,11 @@ export class SalaryPeriodController extends Controller { salaryRanks = await this.salaryRankRepository.findOne({ where: { salaryId: salarys.id, - salary: salaryProfile.amount, + salary: MoreThanOrEqual(salaryProfile.amount), isNext: false, }, + order: { salary: "ASC" }, }); - if (salaryRanks == null) { - salaryRanks = await this.salaryRankRepository.findOne({ - where: { - salaryId: salarys.id, - salary: MoreThan(salaryProfile.amount), - isNext: false, - }, - order: { salary: "DESC" }, - }); - } if (salaryRanks != null) { if (salaryProfile.type == "HAFT") { if (salaryRanks.salaryHalfSpecial != null && salaryRanks.salaryHalfSpecial > 0) { @@ -779,7 +761,7 @@ export class SalaryPeriodController extends Controller { salary: MoreThan(salaryProfile.amount), isNext: true, }, - order: { salary: "DESC" }, + order: { salary: "ASC" }, }); } } @@ -1085,20 +1067,11 @@ export class SalaryPeriodController extends Controller { salaryRanks = await this.salaryRankRepository.findOne({ where: { salaryId: salarys.id, - salary: salaryProfile.amount, + salary: MoreThanOrEqual(salaryProfile.amount), isNext: false, }, + order: { salary: "ASC" }, }); - if (salaryRanks == null) { - salaryRanks = await this.salaryRankRepository.findOne({ - where: { - salaryId: salarys.id, - salary: MoreThan(salaryProfile.amount), - isNext: false, - }, - order: { salary: "DESC" }, - }); - } if (salaryRanks != null) { if (salaryProfile.type == "HAFT") { if (salaryRanks.salaryHalfSpecial != null && salaryRanks.salaryHalfSpecial > 0) { @@ -1157,7 +1130,7 @@ export class SalaryPeriodController extends Controller { salary: MoreThan(salaryProfile.amount), isNext: true, }, - order: { salary: "DESC" }, + order: { salary: "ASC" }, }); } }