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" }, }); } }