diff --git a/src/controllers/ReportController.ts b/src/controllers/ReportController.ts index c754136..b770b6a 100644 --- a/src/controllers/ReportController.ts +++ b/src/controllers/ReportController.ts @@ -2963,16 +2963,23 @@ export class ReportController extends Controller { if (!salaryPeriod) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขึ้นเงินเดือน"); } + let condition: any = { + salaryOrg: { + snapshot: "SNAP2", + rootId: rootId, + salaryPeriodId: salaryPeriodId, + }, + }; + + if(salaryPeriod.period == "APR"){ + condition.type = In(["HAFT", "FULL"]); + }else{ + condition.type = In(["HAFT", "FULL", "FULLHAFT"]); + } + const _salaryPeriod = await this.salaryProfileEmployeeRepository.find({ relations: ["salaryOrg", "salaryOrg.salaryPeriod"], - where: { - type: In(["HAFT", "FULL", "FULLHAFT"]), - salaryOrg: { - snapshot: "SNAP2", - rootId: rootId, - salaryPeriodId: salaryPeriodId, - }, - }, + where: condition, order: { amount: "ASC", rootOrder: "ASC", @@ -3037,6 +3044,7 @@ export class ReportController extends Controller { }, }); } + /** * API 05-แบบ ลจ.กทม.1-1-รายชื่อลูกจ้างผู้สมควรได้รับค่าตอบแทนพิเศษ * @@ -7814,6 +7822,7 @@ export class ReportController extends Controller { body: { type: string; rootId: string; + isRetired?: boolean; }, ) { // let conditionGroup = ""; @@ -7838,7 +7847,14 @@ export class ReportController extends Controller { const salaryOrgs = await this.salaryOrgEmployeeRepository.find({ where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, }); + + let condition = "1=1"; + let parameters = {}; + if(body.isRetired === true){ + condition = "salaryProfileEmployee.isRetired = :isRetired" + parameters = { isRetired: true } + } let salaryRank = await AppDataSource.getRepository(SalaryProfileEmployee) .createQueryBuilder("salaryProfileEmployee") // .andWhere("salaryProfileEmployee.rootId LIKE :rootId", { @@ -7856,6 +7872,7 @@ export class ReportController extends Controller { // ) .andWhere("salaryProfileEmployee.status36 = :status", { status: "PENDING" }) .andWhere("salaryProfileEmployee.rootId = :rootId", { rootId: body.rootId }) + .andWhere(condition, parameters) .select([ "salaryProfileEmployee.id", "salaryProfileEmployee.orgShortName", @@ -7916,6 +7933,7 @@ export class ReportController extends Controller { body: { type: string; rootId: string; + isRetired?: boolean; }, ) { // let conditionGroup = ""; @@ -7941,6 +7959,14 @@ export class ReportController extends Controller { where: { salaryPeriodId: salary.id, snapshot: "SNAP2" }, }); + let condition = "1=1"; + let parameters = {}; + + if(body.isRetired === true){ + condition = "salaryProfileEmployee.isRetired = :isRetired" + parameters = { isRetired: true } + } + let salaryRank = await AppDataSource.getRepository(SalaryProfileEmployee) .createQueryBuilder("salaryProfileEmployee") // .andWhere("salaryProfileEmployee.rootId LIKE :rootId", { @@ -7958,6 +7984,7 @@ export class ReportController extends Controller { // ) .andWhere("salaryProfileEmployee.status37 = :status", { status: "PENDING" }) .andWhere("salaryProfileEmployee.rootId = :rootId", { rootId: body.rootId }) + .andWhere(condition, parameters) .select([ "salaryProfileEmployee.id", "salaryProfileEmployee.orgShortName", @@ -9107,7 +9134,7 @@ export class ReportController extends Controller { salary.salaryLevel && salary.salaryLevelNew ? salary.salaryLevelNew : salary.salaryLevel, - group: salary.group && salary.groupNew ? salary.groupNew : salary.group, + group: salary.groupNew ?? salary.group, }) .then(async () => { const before = null; @@ -9198,7 +9225,7 @@ export class ReportController extends Controller { salary.salaryLevel && salary.salaryLevelNew ? salary.salaryLevelNew : salary.salaryLevel, - group: salary.group && salary.groupNew ? salary.groupNew : salary.group, + group: salary.groupNew ?? salary.group, }) .then(async () => { const before = null;