From a8b77ec2fb57ea7b2ca256e4874cdfa548186649 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 29 Feb 2024 12:08:11 +0700 Subject: [PATCH 1/4] =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=84=E0=B8=99=E0=B9=80=E0=B8=81=E0=B8=A9=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 537e8cd..06dbc9e 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -440,7 +440,8 @@ export class SalaryPeriodController extends Controller { @Put("org/{id}") async GetListsSalaryProfile( @Path() id: string, - @Body() body: { page: number; pageSize: number; keyword?: string; type: string }, + @Body() + body: { page: number; pageSize: number; keyword?: string; type?: any; isRetire?: boolean }, ) { const salaryOrg = await this.salaryOrgRepository.findOne({ where: { @@ -452,11 +453,14 @@ export class SalaryPeriodController extends Controller { } const [salaryProfile, total] = await AppDataSource.getRepository(SalaryProfile) .createQueryBuilder("profile") - .orWhere( + .andWhere( new Brackets((qb) => { qb.andWhere(body.type != null && body.type != "" ? "profile.type LIKE :type" : "1=1", { type: `%${body.type.toUpperCase()}%`, }) + .andWhere(body.isRetire != null ? "profile.isRetire = :isRetire" : "1=1", { + isRetire: `${body.isRetire}`, + }) .andWhere({ salaryOrgId: salaryOrg.id, }) From 6791dde26ff0de70fb51906ad34632a6a060b416 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 29 Feb 2024 13:40:49 +0700 Subject: [PATCH 2/4] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=84?= =?UTF-8?q?=E0=B8=B4=E0=B8=A7=E0=B8=A3=E0=B8=B5=E0=B9=88=E0=B8=84=E0=B9=89?= =?UTF-8?q?=E0=B8=99=E0=B8=AB=E0=B8=B2=E0=B8=84=E0=B8=99=E0=B9=83=E0=B8=99?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A=E0=B9=80=E0=B8=87=E0=B8=B4?= =?UTF-8?q?=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 06dbc9e..3e7861e 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -441,7 +441,13 @@ export class SalaryPeriodController extends Controller { async GetListsSalaryProfile( @Path() id: string, @Body() - body: { page: number; pageSize: number; keyword?: string; type?: any; isRetire?: boolean }, + body: { + page: number; + pageSize: number; + keyword?: string; + type?: any; + isRetire?: boolean | null; + }, ) { const salaryOrg = await this.salaryOrgRepository.findOne({ where: { @@ -455,12 +461,10 @@ export class SalaryPeriodController extends Controller { .createQueryBuilder("profile") .andWhere( new Brackets((qb) => { - qb.andWhere(body.type != null && body.type != "" ? "profile.type LIKE :type" : "1=1", { - type: `%${body.type.toUpperCase()}%`, + qb.andWhere(body.type != null && body.type != "" ? `profile.type LIKE :type` : "1=1", { + type: body.type == null ? "" : `%${body.type.toUpperCase()}%`, }) - .andWhere(body.isRetire != null ? "profile.isRetire = :isRetire" : "1=1", { - isRetire: `${body.isRetire}`, - }) + .andWhere(body.isRetire != null ? `profile.isRetired = ${body.isRetire}` : "1=1") .andWhere({ salaryOrgId: salaryOrg.id, }) From 0888d3d8d8cba047a0443dda4bdc240f63bf1380 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 29 Feb 2024 14:07:27 +0700 Subject: [PATCH 3/4] =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B9=84=E0=B8=A1?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=E0=B8=B5=E0=B8=84=E0=B9=88=E0=B8=B2=E0=B9=83?= =?UTF-8?q?=E0=B8=AB=E0=B9=89=E0=B9=80=E0=B8=9B=E0=B9=87=E0=B8=99null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 2 +- src/entities/SalaryProfile.ts | 25 ++++++++----------- ...date_table_salaryProfile_add_isretired1.ts | 18 +++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 src/migration/1709189881087-update_table_salaryProfile_add_isretired1.ts diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 3e7861e..d30628f 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -388,7 +388,7 @@ export class SalaryPeriodController extends Controller { if (body.type == "NONE") { salaryProfile.amountSpecial = 0; salaryProfile.amountUse = 0; - salaryProfile.positionSalaryAmount = salaryProfile.amount; + salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount; } else if (body.type == "PENDING") { salaryProfile.amountSpecial = 0; salaryProfile.amountUse = 0; diff --git a/src/entities/SalaryProfile.ts b/src/entities/SalaryProfile.ts index 7b72baf..badbaba 100644 --- a/src/entities/SalaryProfile.ts +++ b/src/entities/SalaryProfile.ts @@ -111,31 +111,28 @@ export class SalaryProfile extends EntityBase { comment: "เงินเดือนฐาน", default: null, }) - amount: number; + amount: number | null; @Column({ - nullable: true, type: "double", comment: "เงินพิเศษ", - default: null, + default: 0, }) amountSpecial: number; @Column({ - nullable: true, type: "double", comment: "จำนวนเงินที่ใช้เลื่อน", - default: null, + default: 0, }) - amountUse: number | null; + amountUse: number; @Column({ - nullable: true, type: "double", comment: "เงินเดือนหลังเลื่อน", - default: null, + default: 0, }) - positionSalaryAmount: number | null; + positionSalaryAmount: number; @Column({ comment: @@ -358,19 +355,19 @@ export class CreateSalaryProfile { child4: string | null; @Column() - result: string; + result: string | null; @Column() - duration: string; + duration: string | null; @Column() - punish: string; + punish: string | null; @Column() - retired: string; + retired: string | null; @Column() - retired2: string; + retired2: string | null; @Column() isRetired: boolean; diff --git a/src/migration/1709189881087-update_table_salaryProfile_add_isretired1.ts b/src/migration/1709189881087-update_table_salaryProfile_add_isretired1.ts new file mode 100644 index 0000000..c067c3a --- /dev/null +++ b/src/migration/1709189881087-update_table_salaryProfile_add_isretired1.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableSalaryProfileAddIsretired11709189881087 implements MigrationInterface { + name = 'UpdateTableSalaryProfileAddIsretired11709189881087' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountSpecial\` \`amountSpecial\` double NOT NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountUse\` \`amountUse\` double NOT NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน' DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`positionSalaryAmount\` \`positionSalaryAmount\` double NOT NULL COMMENT 'เงินเดือนหลังเลื่อน' DEFAULT '0'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`positionSalaryAmount\` \`positionSalaryAmount\` double NULL COMMENT 'เงินเดือนหลังเลื่อน'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountUse\` \`amountUse\` double NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน'`); + await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountSpecial\` \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ'`); + } + +} From 442be8bf38628fa7211809792e886b1956fbfafe Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 29 Feb 2024 14:41:44 +0700 Subject: [PATCH 4/4] =?UTF-8?q?=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99?= =?UTF-8?q?=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=A7=E0=B9=88?= =?UTF-8?q?=E0=B8=B2=E0=B8=87=E0=B9=84=E0=B8=94=E0=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 1 + src/entities/SalaryProfile.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index d30628f..346c32c 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -527,6 +527,7 @@ export class SalaryPeriodController extends Controller { const salaryOrgAll = await this.salaryOrgRepository.find({ where: { salaryPeriodId: salaryOrg.salaryPeriodId, + snapshot: salaryOrg.snapshot, }, }); if (!salaryOrgAll) { diff --git a/src/entities/SalaryProfile.ts b/src/entities/SalaryProfile.ts index badbaba..9c2377a 100644 --- a/src/entities/SalaryProfile.ts +++ b/src/entities/SalaryProfile.ts @@ -322,7 +322,7 @@ export class CreateSalaryProfile { posExecutive: string | null; @Column() - amount: number; + amount: number | null; @Column("uuid") rootId: string | null;