save profile salary

This commit is contained in:
kittapath 2025-01-08 14:15:28 +07:00
parent 3a0fc39397
commit 479e9a3938
14 changed files with 817 additions and 129 deletions

View file

@ -2200,6 +2200,14 @@ export class CommandController extends Controller {
posmasterId: string;
positionId: string;
commandId?: string | null;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -2225,6 +2233,7 @@ export class CommandController extends Controller {
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
Object.assign(data, { ...item, ...meta });
@ -2322,6 +2331,14 @@ export class CommandController extends Controller {
posmasterId: string;
positionId: string;
commandId?: string | null;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -2347,6 +2364,7 @@ export class CommandController extends Controller {
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
Object.assign(data, {
@ -2459,6 +2477,14 @@ export class CommandController extends Controller {
dateLeave?: Date | null;
commandId?: string | null;
isGovernment?: boolean | null;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -2490,6 +2516,7 @@ export class CommandController extends Controller {
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
Object.assign(data, { ...item, ...meta });
@ -2600,6 +2627,14 @@ export class CommandController extends Controller {
dateLeave?: Date | null;
isGovernment?: boolean | null;
commandId?: string | null;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -2628,6 +2663,7 @@ export class CommandController extends Controller {
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
Object.assign(data, {
@ -2700,6 +2736,14 @@ export class CommandController extends Controller {
leaveReason?: string | null;
dateLeave?: Date | null;
isLeave?: boolean;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -2728,6 +2772,7 @@ export class CommandController extends Controller {
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
if (item.isLeave != undefined && item.isLeave == true) {
await removeProfileInOrganize(profile.id, "OFFICER");
@ -2783,6 +2828,14 @@ export class CommandController extends Controller {
positionLevel: string | null;
refCommandNo: string | null;
templateDoc: string | null;
orgRoot?: string | null;
orgChild1?: string | null;
orgChild2?: string | null;
orgChild3?: string | null;
orgChild4?: string | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -2808,6 +2861,7 @@ export class CommandController extends Controller {
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
Object.assign(data, {
@ -2843,7 +2897,6 @@ export class CommandController extends Controller {
isLeave: boolean | null;
leaveReason?: string | null;
dateLeave?: Date | null;
refCommandDate?: Date | null;
detail?: string | null;
level?: string | null;
unStigma?: string | null;
@ -2852,6 +2905,9 @@ export class CommandController extends Controller {
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
isGovernment?: boolean | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -2887,6 +2943,13 @@ export class CommandController extends Controller {
orgRevisionIsDraft: false,
},
});
const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName =
!profile.current_holders || profile.current_holders.length == 0
? null
@ -2929,10 +2992,10 @@ export class CommandController extends Controller {
position: profile.position,
positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName,
posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
posNo: shortName ? shortName : null,
positionLine: position?.positionField ?? null,
positionPathSide: position?.positionArea ?? null,
positionExecutive: position?.posExecutive?.posExecutiveName ?? null,
amount: item.amount ? item.amount : null,
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
@ -2942,6 +3005,11 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1
: 1
: null,
orgRoot: orgRootRef?.orgRootName ?? null,
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
orgChild3: orgChild3Ref?.orgChild3Name ?? null,
orgChild4: orgChild4Ref?.orgChild4Name ?? null,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
@ -2949,7 +3017,10 @@ export class CommandController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
dateGovernment: new Date(),
refCommandDate: new Date(),
isGovernment: item.isGovernment,
refCommandCode: item.refCommandCode,
refCommandName: item.refCommandName,
};
Object.assign(data, meta);
@ -3056,6 +3127,13 @@ export class CommandController extends Controller {
orgRevisionIsDraft: false,
},
});
const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName =
!profile.current_holders || profile.current_holders.length == 0
? null
@ -3098,7 +3176,7 @@ export class CommandController extends Controller {
position: profile.position,
positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName,
posNo: shortName ? shortName : "-",
posNo: shortName ? shortName : null,
// positionLine: position?.positionField ?? "-",
// positionPathSide: position?.positionArea ?? "-",
// positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -3111,6 +3189,11 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1
: 1
: null,
orgRoot: orgRootRef?.orgRootName ?? null,
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
orgChild3: orgChild3Ref?.orgChild3Name ?? null,
orgChild4: orgChild4Ref?.orgChild4Name ?? null,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
@ -3118,7 +3201,10 @@ export class CommandController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
dateGovernment: new Date(),
refCommandDate: new Date(),
isGovernment: item.isGovernment,
refCommandCode: item.refCommandCode,
refCommandName: item.refCommandName,
};
Object.assign(data, meta);
@ -3220,7 +3306,6 @@ export class CommandController extends Controller {
isLeave: boolean | null;
leaveReason?: string | null;
dateLeave?: Date | null;
refCommandDate?: Date | null;
detail?: string | null;
level?: string | null;
unStigma?: string | null;
@ -3229,6 +3314,9 @@ export class CommandController extends Controller {
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
isGovernment?: boolean | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -3263,6 +3351,13 @@ export class CommandController extends Controller {
orgRevisionIsDraft: false,
},
});
const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName =
!profile.current_holders || profile.current_holders.length == 0
? null
@ -3304,7 +3399,7 @@ export class CommandController extends Controller {
position: profile.position,
positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName,
posNo: shortName ? shortName : "-",
posNo: shortName ? shortName : null,
// positionLine: position?.positionField ?? "-",
// positionPathSide: position?.positionArea ?? "-",
// positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
@ -3317,6 +3412,11 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1
: 1
: null,
orgRoot: orgRootRef?.orgRootName ?? null,
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
orgChild3: orgChild3Ref?.orgChild3Name ?? null,
orgChild4: orgChild4Ref?.orgChild4Name ?? null,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
@ -3324,7 +3424,10 @@ export class CommandController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
dateGovernment: new Date(),
refCommandDate: new Date(),
isGovernment: item.isGovernment,
refCommandCode: item.refCommandCode,
refCommandName: item.refCommandName,
};
Object.assign(data, meta);
@ -3426,6 +3529,9 @@ export class CommandController extends Controller {
amount?: Double | null;
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -3461,6 +3567,13 @@ export class CommandController extends Controller {
},
});
const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName =
!profile.current_holders || profile.current_holders.length == 0
? null
@ -3502,10 +3615,10 @@ export class CommandController extends Controller {
position: profile.position,
positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName,
posNo: shortName ? shortName : "-",
positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
posNo: shortName ? shortName : null,
positionLine: position?.positionField ?? null,
positionPathSide: position?.positionArea ?? null,
positionExecutive: position?.posExecutive?.posExecutiveName ?? null,
amount: item.amount ? item.amount : null,
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
@ -3515,12 +3628,20 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1
: 1
: null,
orgRoot: orgRootRef?.orgRootName ?? null,
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
orgChild3: orgChild3Ref?.orgChild3Name ?? null,
orgChild4: orgChild4Ref?.orgChild4Name ?? null,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
refCommandCode: item.refCommandCode,
refCommandName: item.refCommandName,
};
Object.assign(data, meta);
const history = new ProfileSalaryHistory();
@ -3563,6 +3684,9 @@ export class CommandController extends Controller {
positionSalaryAmount?: Double | null;
mouthSalaryAmount?: Double | null;
isGovernment?: boolean | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -3614,6 +3738,13 @@ export class CommandController extends Controller {
orgRevisionIsDraft: false,
},
});
const orgRevisionRef =
profile?.current_holders?.find((x) => x.orgRevisionId == orgRevision?.id) ?? null;
const orgRootRef = orgRevisionRef?.orgRoot ?? null;
const orgChild1Ref = orgRevisionRef?.orgChild1 ?? null;
const orgChild2Ref = orgRevisionRef?.orgChild2 ?? null;
const orgChild3Ref = orgRevisionRef?.orgChild3 ?? null;
const orgChild4Ref = orgRevisionRef?.orgChild4 ?? null;
const shortName =
!profile.current_holders || profile.current_holders.length == 0
? null
@ -3654,9 +3785,9 @@ export class CommandController extends Controller {
positionType: profile.posType.posTypeName,
positionLevel: profile.posLevel.posLevelName,
posNo: shortName,
positionLine: position?.positionField ?? "-",
positionPathSide: position?.positionArea ?? "-",
positionExecutive: position?.posExecutive?.posExecutiveName ?? "-",
positionLine: position?.positionField ?? null,
positionPathSide: position?.positionArea ?? null,
positionExecutive: position?.posExecutive?.posExecutiveName ?? null,
amount: item.amount ? item.amount : null,
positionSalaryAmount: item.positionSalaryAmount ? item.positionSalaryAmount : null,
mouthSalaryAmount: item.mouthSalaryAmount ? item.mouthSalaryAmount : null,
@ -3666,6 +3797,11 @@ export class CommandController extends Controller {
? profile.profileSalary[0].order + 1
: 1
: null,
orgRoot: orgRootRef?.orgRootName ?? null,
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
orgChild3: orgChild3Ref?.orgChild3Name ?? null,
orgChild4: orgChild4Ref?.orgChild4Name ?? null,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
@ -3673,7 +3809,10 @@ export class CommandController extends Controller {
createdAt: new Date(),
lastUpdatedAt: new Date(),
dateGovernment: new Date(),
refCommandDate: new Date(),
isGovernment: item.isGovernment,
refCommandCode: item.refCommandCode,
refCommandName: item.refCommandName,
});
await removeProfileInOrganize(profile.id, "OFFICER");
const clearProfile = await checkCommandType(String(item.commandId));
@ -3736,6 +3875,7 @@ export class CommandController extends Controller {
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
const _null: any = null;
if (item.bodyProfile.posLevelId === "") item.bodyProfile.posLevelId = null;
@ -4031,9 +4171,12 @@ export class CommandController extends Controller {
commandYear: number;
templateDoc: string | null;
amount: Double | null;
amountSpecial: Double | null;
amountSpecial?: Double | null;
positionSalaryAmount: Double | null;
mouthSalaryAmount: Double | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -4072,12 +4215,20 @@ export class CommandController extends Controller {
refCommandNo: `${item.commandNo}/${Extension.ToThaiYear(item.commandYear)}`,
templateDoc: item.templateDoc,
order: dest_item == null ? 1 : dest_item.order + 1,
// orgRoot: orgRootRef?.orgRootName??null,
// orgChild1: orgChild1Ref?.orgChild1Name??null,
// orgChild2: orgChild2Ref?.orgChild2Name??null,
// orgChild3: orgChild3Ref?.orgChild3Name??null,
// orgChild4: orgChild4Ref?.orgChild4Name??null,
refCommandCode: item.refCommandCode,
refCommandName: item.refCommandName,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
Object.assign(data, meta);
@ -4226,6 +4377,9 @@ export class CommandController extends Controller {
amountSpecial?: Double | null;
positionSalaryAmount: Double | null;
mouthSalaryAmount: Double | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -4376,6 +4530,9 @@ export class CommandController extends Controller {
amountSpecial?: Double | null;
positionSalaryAmount: Double | null;
mouthSalaryAmount: Double | null;
mpCee?: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
}[];
},
) {
@ -4398,6 +4555,11 @@ export class CommandController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบตำแหน่งดังกล่าว");
}
if (posMaster.next_holderId != null) {
const orgRootRef = posMaster?.orgRoot ?? null;
const orgChild1Ref = posMaster?.orgChild1 ?? null;
const orgChild2Ref = posMaster?.orgChild2 ?? null;
const orgChild3Ref = posMaster?.orgChild3 ?? null;
const orgChild4Ref = posMaster?.orgChild4 ?? null;
const shortName =
posMaster != null && posMaster.orgChild4 != null
? `${posMaster.orgChild4.orgChild4ShortName}${posMaster.posMasterNo}`
@ -4441,12 +4603,20 @@ export class CommandController extends Controller {
refCommandNo: `${item.commandNo}/${Extension.ToThaiYear(item.commandYear)}`,
templateDoc: item.templateDoc,
order: dest_item == null ? 1 : dest_item.order + 1,
orgRoot: orgRootRef?.orgRootName ?? null,
orgChild1: orgChild1Ref?.orgChild1Name ?? null,
orgChild2: orgChild2Ref?.orgChild2Name ?? null,
orgChild3: orgChild3Ref?.orgChild3Name ?? null,
orgChild4: orgChild4Ref?.orgChild4Name ?? null,
refCommandCode: item.refCommandCode,
refCommandName: item.refCommandName,
createdUserId: req.user.sub,
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
refCommandDate: new Date(),
};
Object.assign(data, meta);
const history = new ProfileSalaryHistory();