diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 2a9a8772..a677171c 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1455,6 +1455,7 @@ export class CommandController extends Controller { templateDoc: string | null; posmasterId: string; positionId: string; + commandId?: string | null; }[]; }, ) { @@ -1464,7 +1465,7 @@ export class CommandController extends Controller { if (!profile) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); } - + let _null: any = null; const dest_item = await this.salaryRepo.findOne({ where: { profileId: item.profileId }, order: { order: "DESC" }, @@ -1485,10 +1486,9 @@ export class CommandController extends Controller { Object.assign(data, { ...item, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); - await this.salaryRepo.save(data, { data: req }); setLogDataDiff(req, { before, after: data }); - history.profileSalaryId = data.id; + history.commandId = item.commandId??_null; await this.salaryHistoryRepo.save(history, { data: req }); const posMaster = await this.posMasterRepository.findOne({ @@ -1573,6 +1573,7 @@ export class CommandController extends Controller { templateDoc: string | null; posmasterId: string; positionId: string; + commandId?: string | null; }[]; }, ) { @@ -1706,6 +1707,7 @@ export class CommandController extends Controller { isLeave: boolean; leaveReason?: string | null; dateLeave?: Date | null; + commandId?: string | null; }[]; }, ) { @@ -1857,6 +1859,7 @@ export class CommandController extends Controller { positionLevel: string | null; refCommandNo: string | null; templateDoc: string | null; + commandId?: string | null; }[]; }, ) { @@ -1978,6 +1981,7 @@ export class CommandController extends Controller { detail?: string | null; level?: string | null; unStigma?: string | null; + commandId?: string | null; }[]; }, ) { @@ -2092,6 +2096,7 @@ export class CommandController extends Controller { date?: Date | null; refCommandNo?: string | null; salaryRef?: string | null; + commandId?: string | null; }[]; }, ) { @@ -2171,6 +2176,7 @@ export class CommandController extends Controller { date?: Date | null; refCommandNo?: string | null; salaryRef?: string | null; + commandId?: string | null; }[]; }, ) { @@ -2208,6 +2214,7 @@ export class CommandController extends Controller { date: item.date, refCommandNo: item.refCommandNo, templateDoc: item.salaryRef, + commandId: item.commandId, position: profile.profileSalary.length > 0 ? profile.profileSalary[0].position : null, positionType: profile.profileSalary.length > 0 ? profile.profileSalary[0].positionType : null, @@ -2462,6 +2469,7 @@ export class CommandController extends Controller { refId: string; commandAffectDate: Date | null; commandNo: string | null; + commandId?: string | null; commandYear: number; templateDoc: string | null; amount: Double | null; @@ -2488,6 +2496,7 @@ export class CommandController extends Controller { profileEmployeeId: profile.id, date: new Date(), amount: item.amount, + commandId: item.commandId, positionSalaryAmount: item.positionSalaryAmount, mouthSalaryAmount: item.mouthSalaryAmount, posNo: profile.posMasterNoTemp, @@ -2628,6 +2637,7 @@ export class CommandController extends Controller { refId: string; commandAffectDate: Date | null; commandNo: string | null; + commandId?: string | null; commandYear: number; templateDoc: string | null; amount: Double | null; @@ -2766,6 +2776,7 @@ export class CommandController extends Controller { refId: string; commandAffectDate: Date | null; commandNo: string | null; + commandId?: string | null; commandYear: number; templateDoc: string | null; amount: Double | null; @@ -2795,6 +2806,7 @@ export class CommandController extends Controller { profileId: profile.id, date: new Date(), amount: item.amount, + commandId: item.commandId, positionSalaryAmount: item.positionSalaryAmount, mouthSalaryAmount: item.mouthSalaryAmount, posNo: "", diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index a7fbea2c..26f2c188 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -121,7 +121,6 @@ export class ProfileSalaryController extends Controller { Object.assign(data, { ...body, ...meta }); const history = new ProfileSalaryHistory(); Object.assign(history, { ...data, id: undefined }); - await this.salaryRepo.save(data, { data: req }); setLogDataDiff(req, { before, after: data }); history.profileSalaryId = data.id; diff --git a/src/entities/ProfileSalary.ts b/src/entities/ProfileSalary.ts index 9c02c4c7..0d76a620 100644 --- a/src/entities/ProfileSalary.ts +++ b/src/entities/ProfileSalary.ts @@ -203,6 +203,7 @@ export class CreateProfileSalaryEmployee { profileEmployeeId: string | null; date?: Date | null; amount?: Double | null; + commandId: string | null; positionSalaryAmount?: Double | null; mouthSalaryAmount?: Double | null; posNo: string | null; diff --git a/src/interfaces/utils.ts b/src/interfaces/utils.ts index c2daf911..b6b9a9a0 100644 --- a/src/interfaces/utils.ts +++ b/src/interfaces/utils.ts @@ -233,9 +233,9 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-10": return "/probation/report/command10/officer/report"; case "C-PM-11": - return "/probation/report/command11/officer/report"; + return "/probation/report/command11/officer/report";//PROBATION case "C-PM-12": - return "/probation/report/command12/officer/report"; + return "/probation/report/command12/officer/report";//PROBATION case "C-PM-13": return "/placement/transfer/command/report"; case "C-PM-14": @@ -253,7 +253,7 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-20": return "/discipline/result/command20/report"; case "C-PM-21": - return "/org/command/command21/employee/report"; + return "/org/command/command21/employee/report";//ORG case "C-PM-22": return "/placement/appointment/employee-appoint/report"; case "C-PM-23": @@ -277,21 +277,21 @@ export function commandTypePath(commandCode: string): string | null { case "C-PM-32": return "/discipline/result/command32/report"; case "C-PM-33": - return "/salary/report/command/officer/report"; + return "/salary/report/command/officer/report";//SALARY case "C-PM-34": - return "/salary/report/command/officer/report"; + return "/salary/report/command/officer/report";//SALARY case "C-PM-35": - return "/salary/report/command/officer/report"; + return "/salary/report/command/officer/report";//SALARY case "C-PM-36": - return "/salary/report/command/employee/report"; + return "/salary/report/command/employee/report";//SALARY case "C-PM-37": - return "/salary/report/command/employee/report"; + return "/salary/report/command/employee/report";//SALARY case "C-PM-38": - return "/org/command/command38/officer/report"; + return "/org/command/command38/officer/report";//ORG case "C-PM-39": return "/placement/appointment/slip/report"; case "C-PM-40": - return "/org/command/command40/officer/report"; + return "/org/command/command40/officer/report";//ORG case "C-PM-41": return "/retirement/resign/leave-cancel/report"; default: diff --git a/src/migration/1729492903054-update_table_migration10212024.ts b/src/migration/1729492903054-update_table_migration10212024.ts new file mode 100644 index 00000000..90e53e48 --- /dev/null +++ b/src/migration/1729492903054-update_table_migration10212024.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableMigration102120241729492903054 implements MigrationInterface { + name = 'UpdateTableMigration102120241729492903054' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`commandSend\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`citizenId\` varchar(255) NULL COMMENT 'เลขประจำตัวประชาชน', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`org\` varchar(255) NULL COMMENT 'หน่วยงาน', \`commandId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง command', \`profileId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง profile', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD \`commandId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง command'`); + await queryRunner.query(`ALTER TABLE \`commandSend\` ADD CONSTRAINT \`FK_71884cff2519003c997c4129374\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`commandSend\` ADD CONSTRAINT \`FK_4f257ba4ce200ddc0726156a00d\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` ADD CONSTRAINT \`FK_8ba1f49c8315bf86848ebcb29f5\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP FOREIGN KEY \`FK_8ba1f49c8315bf86848ebcb29f5\``); + await queryRunner.query(`ALTER TABLE \`commandSend\` DROP FOREIGN KEY \`FK_4f257ba4ce200ddc0726156a00d\``); + await queryRunner.query(`ALTER TABLE \`commandSend\` DROP FOREIGN KEY \`FK_71884cff2519003c997c4129374\``); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` DROP COLUMN \`commandId\``); + await queryRunner.query(`DROP TABLE \`commandSend\``); + } + +}