diff --git a/src/controllers/SalaryFormulaEmployeeController.ts b/src/controllers/SalaryFormulaEmployeeController.ts index 690ac91..d35b899 100644 --- a/src/controllers/SalaryFormulaEmployeeController.ts +++ b/src/controllers/SalaryFormulaEmployeeController.ts @@ -18,7 +18,7 @@ import { AppDataSource } from "../database/data-source"; import HttpSuccess from "../interfaces/http-success"; import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; -import { In, Like, Not } from "typeorm"; +import { Brackets, In, Like, Not } from "typeorm"; import { CreateSalaryFormulaEmployee, SalaryFormulaEmployee, @@ -245,14 +245,27 @@ export class SalaryFormulaEmployeeController extends Controller { .leftJoinAndSelect("salaryFormulaEmployee.posLevel", "posLevel") .leftJoinAndSelect("salaryFormulaEmployee.salaryEmployeeMins", "salaryEmployeeMins") .andWhere( - keyword == undefined - ? "1=1" - : [ - { details: Like(`%${keyword}%`) }, - { position: Like(`%${keyword}%`) }, - { posLevel: { posLevelName: Like(`%${keyword}%`) } }, - { posType: { posTypeName: Like(`%${keyword}%`) } }, - ], + new Brackets((qb) => { + qb.orWhere( + keyword == undefined ? "1=1" : `salaryFormulaEmployee.details like '%${keyword}%'`, + { + keyword: `%${keyword}%`, + }, + ); + qb.orWhere( + keyword == undefined ? "1=1" : `salaryFormulaEmployee.position like '%${keyword}%'`, + { + keyword: `%${keyword}%`, + }, + ).orWhere( + keyword == undefined + ? "1=1" + : `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${keyword}%'`, + { + keyword: `%${keyword}%`, + }, + ); + }), ) .andWhere(posTypeId == undefined ? "1=1" : { posTypeId: Like(`%${posTypeId}%`) }) .orderBy("salaryFormulaEmployee.lastUpdatedAt", "DESC") diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 1a2d16a..79fea90 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -1224,8 +1224,8 @@ export class SalaryPeriodController extends Controller { }) // .orWhere("profile.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` }) - // .orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` }) - // .orWhere("profile.posLevel LIKE :keyword", { keyword: `%${body.keyword}%` }) + .orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` }) + .orWhere("profile.posLevel LIKE :keyword", { keyword: `%${body.keyword}%` }) // .orWhere("profile.posExecutive LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.amount LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.amountSpecial LIKE :keyword", { keyword: `%${body.keyword}%` }) @@ -1712,13 +1712,14 @@ export class SalaryPeriodController extends Controller { salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); - + let _null: any = null; await Promise.all( orgs.map(async (root: any) => { let salaryOrgNew = Object.assign(new SalaryOrg()); salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId ?? _null; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = salaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -1739,6 +1740,7 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId ?? _null; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = salaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -1835,7 +1837,7 @@ export class SalaryPeriodController extends Controller { await this.salaryPeriodRepository.save(chk_SalaryPeriod, { data: request }); setLogDataDiff(request, { before: beforeChk_SalaryPeriod, after: chk_SalaryPeriod }); - + let _null: any = null; await Promise.all( orgs.map(async (root: any) => { let salaryOrgNew = Object.assign(new SalaryOrg()); @@ -1844,6 +1846,7 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.salaryPeriodId = chk_SalaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId ?? _null; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = chk_SalaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -1867,6 +1870,7 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.salaryPeriodId = chk_SalaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId ?? _null; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = chk_SalaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -2203,7 +2207,7 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; - salaryOrgNew.rootDnaId = root.rootDnaId; + salaryOrgNew.rootDnaId = root.rootDnaId ?? _null; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = salaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -2721,13 +2725,14 @@ export class SalaryPeriodController extends Controller { salaryPeriod.lastUpdatedAt = new Date(); await this.salaryPeriodRepository.save(salaryPeriod, { data: request }); setLogDataDiff(request, { before, after: salaryPeriod }); - + let _null: any = null; await Promise.all( orgs.map(async (root: any) => { let salaryOrgNew = Object.assign(new SalaryOrg()); salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId ?? _null; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = salaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -2756,6 +2761,7 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId ?? _null; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = salaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot;