diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 22c4ecc..4e66213 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -1215,8 +1215,13 @@ export class SalaryPeriodController extends Controller { .orWhere("profile.prefix LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.firstName LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.lastName LIKE :keyword", { keyword: `%${body.keyword}%` }) - .orWhere("CONCAT(profile.prefix,profile.firstName,' ',profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` }) - .orWhere("CONCAT(profile.orgShortName,profile.posMasterNo) LIKE :keyword", { keyword: `%${body.keyword}%` }) + .orWhere( + "CONCAT(profile.prefix,profile.firstName,' ',profile.lastName) LIKE :keyword", + { keyword: `%${body.keyword}%` }, + ) + .orWhere("CONCAT(profile.orgShortName,profile.posMasterNo) LIKE :keyword", { + keyword: `%${body.keyword}%`, + }) // .orWhere("profile.citizenId LIKE :keyword", { keyword: `%${body.keyword}%` }) .orWhere("profile.position LIKE :keyword", { keyword: `%${body.keyword}%` }) // .orWhere("profile.posType LIKE :keyword", { keyword: `%${body.keyword}%` }) @@ -2167,6 +2172,7 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = salaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -2197,6 +2203,7 @@ export class SalaryPeriodController extends Controller { salaryOrgNew.salaryPeriodId = salaryPeriod.id; salaryOrgNew.status = "PENDING"; salaryOrgNew.rootId = root.rootId; + salaryOrgNew.rootDnaId = root.rootDnaId; salaryOrgNew.root = root.root; salaryOrgNew.revisionId = salaryPeriod.revisionId; salaryOrgNew.snapshot = snapshot; @@ -2357,7 +2364,7 @@ export class SalaryPeriodController extends Controller { const salaryOrgSnap2Old: any = await this.salaryOrgRepository.findOne({ where: { salaryPeriodId: salaryPeriodAPROld.id, - rootId: _salaryOrg.rootId, + rootDnaId: _salaryOrg.rootDnaId, group: _salaryOrg.group, snapshot: "SNAP2", }, @@ -2374,7 +2381,7 @@ export class SalaryPeriodController extends Controller { const salaryOrgSnap1 = await this.salaryOrgRepository.findOne({ where: { salaryPeriodId: salaryPeriod.id, - rootId: _salaryOrg.rootId, + rootDnaId: _salaryOrg.rootDnaId, group: _salaryOrg.group, snapshot: "SNAP1", }, @@ -2423,7 +2430,7 @@ export class SalaryPeriodController extends Controller { const salaryOrgSnap2Old: any = await this.salaryOrgEmployeeRepository.findOne({ where: { salaryPeriodId: salaryPeriodAPROld.id, - rootId: _salaryOrg.rootId, + rootDnaId: _salaryOrg.rootDnaId, group: _salaryOrg.group, snapshot: "SNAP2", }, @@ -2439,7 +2446,7 @@ export class SalaryPeriodController extends Controller { const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({ where: { salaryPeriodId: salaryPeriod.id, - rootId: _salaryOrg.rootId, + rootDnaId: _salaryOrg.rootDnaId, group: _salaryOrg.group, snapshot: "SNAP1", }, @@ -2487,7 +2494,7 @@ export class SalaryPeriodController extends Controller { const salaryOrgSnap1 = await this.salaryOrgRepository.findOne({ where: { salaryPeriodId: salaryPeriod.id, - rootId: _salaryOrg.rootId, + rootDnaId: _salaryOrg.rootDnaId, group: _salaryOrg.group, snapshot: "SNAP1", }, @@ -2529,7 +2536,7 @@ export class SalaryPeriodController extends Controller { const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({ where: { salaryPeriodId: salaryPeriod.id, - rootId: _salaryOrg.rootId, + rootDnaId: _salaryOrg.rootDnaId, group: _salaryOrg.group, snapshot: "SNAP1", }, diff --git a/src/entities/SalaryOrg.ts b/src/entities/SalaryOrg.ts index 0e575d9..48d36cc 100644 --- a/src/entities/SalaryOrg.ts +++ b/src/entities/SalaryOrg.ts @@ -22,6 +22,12 @@ export class SalaryOrg extends EntityBase { }) rootId: string; + @Column({ + comment: "คีย์นอก(FK)ของตาราง orgRoot Dna", + length: 40, + }) + rootDnaId: string; + @Column({ nullable: true, comment: "orgRoot", diff --git a/src/entities/SalaryOrgEmployee.ts b/src/entities/SalaryOrgEmployee.ts index 24e5b62..8433ef9 100644 --- a/src/entities/SalaryOrgEmployee.ts +++ b/src/entities/SalaryOrgEmployee.ts @@ -22,6 +22,12 @@ export class SalaryOrgEmployee extends EntityBase { }) rootId: string; + @Column({ + comment: "คีย์นอก(FK)ของตาราง orgRoot Dna", + length: 40, + }) + rootDnaId: string; + @Column({ nullable: true, comment: "orgRoot",