update script รันเกษียณ #169

This commit is contained in:
harid 2025-10-02 11:40:01 +07:00
parent 7ffb698252
commit 6b719049b0
3 changed files with 38 additions and 15 deletions

View file

@ -1478,7 +1478,7 @@ export class CommandController extends Controller {
return new HttpSuccess();
}
async cronjobUpdateRetirementStatus() {
async cronjobUpdateRetirementStatus(/*@Request() request: RequestWithUser*/) {
let body = {
client_id: "gettoken",
client_secret: process.env.AUTH_ACCOUNT_SECRET,
@ -1576,7 +1576,7 @@ export class CommandController extends Controller {
}
// let profiles: ProfileEmployee[] = [];
await Promise.all(
response_.data.result.map(async (x: any) => {
response_.data.result.profiles.map(async (x: any) => {
const _profileEmp = await this.profileEmployeeRepository.findOneBy({ id: x.profileId });
if (_profileEmp) {
// บันทึกลงประวัติตำแหน่ง
@ -1625,7 +1625,6 @@ export class CommandController extends Controller {
amount: null,
positionSalaryAmount: null,
mouthSalaryAmount: null,
profileId: profileId,
posNo: null,
positionExecutive: null,
positionType: null,
@ -1655,6 +1654,14 @@ export class CommandController extends Controller {
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
data.dateGovernment = _Date;
if (type == "OFFICER") {
data.profileId = profileId;
data.profileEmployeeId = null;
}
else if (type == "EMPLOYEE"){
data.profileEmployeeId = profileId;
data.profileId = null;
}
const savedData = await this.salaryRepo.save(data);
history.profileSalaryId = savedData.id;
await this.salaryHistoryRepo.save(history);

View file

@ -249,9 +249,13 @@ export class ProfileGovernmentHistoryController extends Controller {
if (record.leaveType == "RETIRE") {
_profileSalary = record?.profileSalary.length > 1
? record?.profileSalary[1]
: null;
: record?.profileSalary.length > 0
? record?.profileSalary[0]
: null;
} else {
_profileSalary = record?.profileSalary[0];
_profileSalary = record?.profileSalary.length > 0
? record?.profileSalary[0]
: null;
}
if (_profileSalary) {
_OrgLeave = [
@ -404,9 +408,13 @@ export class ProfileGovernmentHistoryController extends Controller {
if (record.leaveType == "RETIRE") {
_profileSalary = record?.profileSalary.length > 1
? record?.profileSalary[1]
: null;
: record?.profileSalary.length > 0
? record?.profileSalary[0]
: null;
} else {
_profileSalary = record?.profileSalary[0];
_profileSalary = record?.profileSalary.length > 0
? record?.profileSalary[0]
: null;
}
if (_profileSalary) {
_OrgLeave = [

View file

@ -264,11 +264,15 @@ export class ProfileGovernmentEmployeeController extends Controller {
// profileSalary.length > 0 && profileSalary[0].orgRoot ? profileSalary[0].orgRoot : null,
// ];
if (record.leaveType == "RETIRE") {
_profileSalary = record?.profileSalary.length > 1
? record?.profileSalary[1]
: null;
_profileSalary = profileSalary.length > 1
? profileSalary[1]
: profileSalary.length > 0
? profileSalary[0]
: null;
} else {
_profileSalary = record?.profileSalary[0];
_profileSalary = profileSalary.length > 0
? profileSalary[0]
: null
}
if (_profileSalary) {
_OrgLeave = [
@ -435,11 +439,15 @@ export class ProfileGovernmentEmployeeController extends Controller {
// profileSalary.length > 0 && profileSalary[0].orgRoot ? profileSalary[0].orgRoot : null,
// ];
if (record.leaveType == "RETIRE") {
_profileSalary = record?.profileSalary.length > 1
? record?.profileSalary[1]
: null;
_profileSalary = profileSalary.length > 1
? profileSalary[1]
: profileSalary.length > 0
? profileSalary[0]
: null;
} else {
_profileSalary = record?.profileSalary[0];
_profileSalary = profileSalary.length > 0
? profileSalary[0]
: null;
}
if (_profileSalary) {
_OrgLeave = [