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();

View file

@ -46,7 +46,7 @@ export class ImportDataController extends Controller {
private profileFamilyCoupleRepository = AppDataSource.getRepository(ProfileFamilyCouple);
private profileFamilyMotherRepository = AppDataSource.getRepository(ProfileFamilyMother);
private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather);
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
private profileRepo = AppDataSource.getRepository(Profile);
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
private posLevelRepo = AppDataSource.getRepository(PosLevel);
@ -323,14 +323,36 @@ export class ImportDataController extends Controller {
const SALARY: any =
item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY);
profileSalary.amount = SALARY;
const SAL_POS_AMOUNT_1: any =
item.SAL_POS_AMOUNT_1 == null || item.SAL_POS_AMOUNT_1 == ""
? null_
: Number(item.SAL_POS_AMOUNT_1);
const SAL_POS_AMOUNT_2: any =
item.SAL_POS_AMOUNT_2 == null || item.SAL_POS_AMOUNT_2 == ""
? null_
: Number(item.SAL_POS_AMOUNT_2);
profileSalary.positionSalaryAmount = SAL_POS_AMOUNT_1 ?? SAL_POS_AMOUNT_2;
const SPECIAL_AMT: any =
item.SPECIAL_AMT == null || item.SPECIAL_AMT == "" ? null_ : Number(item.SPECIAL_AMT);
profileSalary.amountSpecial = SPECIAL_AMT;
profileSalary.profileId = _item.id;
profileSalary.refCommandNo = item.MP_COMMAND_NUM;
profileSalary.posNo = item.POS_NUM_NAME + item.POS_NUM_CODE;
profileSalary.position = item.FLAG_TO_NAME;
profileSalary.positionLine = item.WORK_LINE_NAME;
profileSalary.position = item.WORK_LINE_NAME;
profileSalary.positionPathSide = item.SPECIALIST_NAME;
profileSalary.positionExecutive = item.ADMIN_NAME;
profileSalary.templateDoc = item.REMARK;
profileSalary.refCommandDate =
item.MP_COMMAND_DATE == ""
? null_
: new Date(item.MP_COMMAND_DATE.replace(" +0700 +07:00", ""));
profileSalary.refCommandCode = item.FLAG_TO_NAME_CODE;
profileSalary.refCommandName = item.FLAG_TO_NAME;
profileSalary.orgRoot = item.DEPARTMENT_NAME;
profileSalary.orgChild1 = item.DIVISION_NAME;
profileSalary.orgChild2 = item.SECTION_NAME;
profileSalary.orgChild3 = item.JOB_NAME;
profileSalary.mpCee = item.MP_CEE;
const ORDER_MOVE_POSITION: any =
item.ORDER_MOVE_POSITION == null || item.ORDER_MOVE_POSITION == ""
? null_
@ -340,10 +362,16 @@ export class ImportDataController extends Controller {
profileSalary.createdFullName = request.user.name;
profileSalary.lastUpdateUserId = request.user.sub;
profileSalary.lastUpdateFullName = request.user.name;
profileSalary.createdAt = new Date();
profileSalary.lastUpdatedAt = new Date();
profileSalary.createdAt =
item.USER_CREATE == ""
? null_
: new Date(item.USER_CREATE.replace(" +0700 +07:00", ""));
profileSalary.lastUpdatedAt =
item.USER_UPDATE == ""
? null_
: new Date(item.USER_UPDATE.replace(" +0700 +07:00", ""));
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
await this.salaryRepository.save(profileSalary);
await this.salaryRepo.save(profileSalary);
}),
);
}),
@ -407,14 +435,36 @@ export class ImportDataController extends Controller {
const SALARY: any =
item.SALARY == null || item.SALARY == "" ? null_ : Number(item.SALARY);
profileSalary.amount = SALARY;
const SAL_POS_AMOUNT_1: any =
item.SAL_POS_AMOUNT_1 == null || item.SAL_POS_AMOUNT_1 == ""
? null_
: Number(item.SAL_POS_AMOUNT_1);
const SAL_POS_AMOUNT_2: any =
item.SAL_POS_AMOUNT_2 == null || item.SAL_POS_AMOUNT_2 == ""
? null_
: Number(item.SAL_POS_AMOUNT_2);
profileSalary.positionSalaryAmount = SAL_POS_AMOUNT_1 ?? SAL_POS_AMOUNT_2;
const SPECIAL_AMT: any =
item.SPECIAL_AMT == null || item.SPECIAL_AMT == "" ? null_ : Number(item.SPECIAL_AMT);
profileSalary.amountSpecial = SPECIAL_AMT;
profileSalary.profileEmployeeId = _item.id;
profileSalary.refCommandNo = item.MP_COMMAND_NUM;
profileSalary.posNo = item.POS_NUM_NAME + item.POS_NUM_CODE;
// profileSalary.position = item.FLAG_TO_NAME;
profileSalary.position = item.WORK_LINE_NAME;
profileSalary.positionPathSide = item.SPECIALIST_NAME;
profileSalary.positionExecutive = item.ADMIN_NAME;
profileSalary.templateDoc = item.REMARK;
profileSalary.refCommandDate =
item.MP_COMMAND_DATE == ""
? null_
: new Date(item.MP_COMMAND_DATE.replace(" +0700 +07:00", ""));
profileSalary.refCommandCode = item.FLAG_TO_NAME_CODE;
profileSalary.refCommandName = item.FLAG_TO_NAME;
profileSalary.orgRoot = item.DEPARTMENT_NAME;
profileSalary.orgChild1 = item.DIVISION_NAME;
profileSalary.orgChild2 = item.SECTION_NAME;
profileSalary.orgChild3 = item.JOB_NAME;
profileSalary.mpCee = item.MP_CEE;
const ORDER_MOVE_POSITION: any =
item.ORDER_MOVE_POSITION == null || item.ORDER_MOVE_POSITION == ""
? null_
@ -424,10 +474,16 @@ export class ImportDataController extends Controller {
profileSalary.createdFullName = request.user.name;
profileSalary.lastUpdateUserId = request.user.sub;
profileSalary.lastUpdateFullName = request.user.name;
profileSalary.createdAt = new Date();
profileSalary.lastUpdatedAt = new Date();
profileSalary.createdAt =
item.USER_CREATE == ""
? null_
: new Date(item.USER_CREATE.replace(" +0700 +07:00", ""));
profileSalary.lastUpdatedAt =
item.USER_UPDATE == ""
? null_
: new Date(item.USER_UPDATE.replace(" +0700 +07:00", ""));
console.log(">>>>>>>>>>>>>>>>>>>" + rowCount);
await this.salaryRepository.save(profileSalary);
await this.salaryRepo.save(profileSalary);
}),
);
}),

View file

@ -99,7 +99,7 @@ export class ProfileController extends Controller {
private profileFamilyFatherHistoryRepo = AppDataSource.getRepository(ProfileFamilyFatherHistory);
private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
private profileEducationRepo = AppDataSource.getRepository(ProfileEducation);
private provinceRepo = AppDataSource.getRepository(Province);
private districtRepo = AppDataSource.getRepository(District);
@ -221,7 +221,7 @@ export class ProfileController extends Controller {
let _child3 = child3 == null || child3 == undefined ? "" : `${child3.orgChild3Name}/`;
let _child4 = child4 == null || child4 == undefined ? "" : `${child4.orgChild4Name}/`;
const salary_raw = await this.salaryRepository.find({
const salary_raw = await this.salaryRepo.find({
select: [
"date",
"position",
@ -580,7 +580,7 @@ export class ProfileController extends Controller {
field: "-",
},
];
const salary_raw = await this.salaryRepository.find({
const salary_raw = await this.salaryRepo.find({
select: [
"date",
"position",
@ -1403,12 +1403,12 @@ export class ProfileController extends Controller {
let condition: any = {
orgRootId: posMaster.orgRootId || "",
};
// if (body.isDirector == true) {
condition = {
orgRootId: posMaster.orgRootId || "",
isDirector: true,
};
// }
if (body.isDirector == true) {
condition = {
orgRootId: posMaster.orgRootId || "",
isDirector: true,
};
}
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
.createQueryBuilder("viewDirectorActing")
.andWhere(condition)
@ -2034,6 +2034,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2056,6 +2058,13 @@ export class ProfileController 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
@ -2098,10 +2107,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2111,14 +2120,22 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await Promise.all([this.salaryRepository.save(profileSalary)]);
await Promise.all([this.salaryRepo.save(profileSalary)]);
}
return new HttpSuccess();
}
@ -2138,6 +2155,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2173,6 +2192,13 @@ export class ProfileController 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
@ -2209,10 +2235,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2222,15 +2248,23 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await removeProfileInOrganize(profile.id, "OFFICER");
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -2250,6 +2284,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2284,6 +2320,13 @@ export class ProfileController 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
@ -2320,10 +2363,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2333,15 +2376,23 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await removeProfileInOrganize(profile.id, "OFFICER");
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -2361,6 +2412,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2395,6 +2448,13 @@ export class ProfileController 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
@ -2431,10 +2491,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2444,31 +2504,23 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
// //เพิ่มวินัย
// const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), {
// date: body.date,
// profileId: body.profileId,
// refCommandNo: body.refCommandNo,
// createdUserId: req.user.sub,
// createdFullName: req.user.name,
// lastUpdateUserId: req.user.sub,
// lastUpdateFullName: req.user.name,
// createdAt: new Date(),
// lastUpdatedAt: new Date(),
// });
await removeProfileInOrganize(profile.id, "OFFICER");
await Promise.all([
this.profileRepo.save(_profile),
this.salaryRepository.save(profileSalary),
// this.profileDisciplineRepo.save(profileDiscipline)
]);
await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -2488,6 +2540,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2522,6 +2576,13 @@ export class ProfileController 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
@ -2558,10 +2619,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2571,15 +2632,23 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await removeProfileInOrganize(profile.id, "OFFICER");
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -2599,6 +2668,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2632,6 +2703,13 @@ export class ProfileController 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
@ -2668,10 +2746,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2681,15 +2759,23 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await removeProfileInOrganize(profile.id, "OFFICER");
await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]);
await Promise.all([this.profileRepo.save(_profile), this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -2709,6 +2795,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2736,6 +2824,13 @@ export class ProfileController 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
@ -2772,10 +2867,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2785,14 +2880,22 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await Promise.all([this.salaryRepository.save(profileSalary)]);
await Promise.all([this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -2812,6 +2915,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2839,6 +2944,13 @@ export class ProfileController 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
@ -2875,10 +2987,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2888,14 +3000,22 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await Promise.all([this.salaryRepository.save(profileSalary)]);
await Promise.all([this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -2915,6 +3035,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -2942,6 +3064,13 @@ export class ProfileController 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
@ -2979,10 +3108,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -2992,14 +3121,22 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await Promise.all([this.salaryRepository.save(profileSalary)]);
await Promise.all([this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -3019,6 +3156,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -3046,6 +3185,13 @@ export class ProfileController 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
@ -3082,10 +3228,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -3095,14 +3241,22 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await Promise.all([this.salaryRepository.save(profileSalary)]);
await Promise.all([this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -3122,6 +3276,8 @@ export class ProfileController extends Controller {
date: Date | null;
refCommandNo: string | null;
salaryRef: string | null;
refCommandCode?: string | null;
refCommandName?: string | null;
},
) {
const profile = await this.profileRepo.findOne({
@ -3149,6 +3305,13 @@ export class ProfileController 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
@ -3186,10 +3349,10 @@ export class ProfileController 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: profile.amount,
positionSalaryAmount: profile.positionSalaryAmount,
mouthSalaryAmount: profile.mouthSalaryAmount,
@ -3199,14 +3362,22 @@ export class ProfileController 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: body.refCommandCode,
refCommandName: body.refCommandName,
});
await Promise.all([this.salaryRepository.save(profileSalary)]);
await Promise.all([this.salaryRepo.save(profileSalary)]);
return new HttpSuccess();
}
@ -8183,7 +8354,7 @@ export class ProfileController extends Controller {
const _null: any = null;
const profiles = await Promise.all(
profile.map(async (_data) => {
const salary = await this.salaryRepository.findOne({
const salary = await this.salaryRepo.findOne({
where: {
profileId: _data.id,
},

View file

@ -91,7 +91,7 @@ export class ProfileEmployeeController extends Controller {
private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather);
private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1);
private child2Repository = AppDataSource.getRepository(OrgChild2);
@ -548,7 +548,7 @@ export class ProfileEmployeeController extends Controller {
Field: "-",
},
];
const salary_raw = await this.salaryRepository.find({
const salary_raw = await this.salaryRepo.find({
select: [
"date",
"position",

View file

@ -90,7 +90,7 @@ export class ProfileEmployeeTempController extends Controller {
private profileFamilyFatherRepository = AppDataSource.getRepository(ProfileFamilyFather);
private trainingRepository = AppDataSource.getRepository(ProfileTraining);
private disciplineRepository = AppDataSource.getRepository(ProfileDiscipline);
private salaryRepository = AppDataSource.getRepository(ProfileSalary);
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
private child1Repository = AppDataSource.getRepository(OrgChild1);
private child2Repository = AppDataSource.getRepository(OrgChild2);
@ -545,7 +545,7 @@ export class ProfileEmployeeTempController extends Controller {
Field: "-",
},
];
const salary_raw = await this.salaryRepository.find({
const salary_raw = await this.salaryRepo.find({
select: [
"date",
"position",

View file

@ -119,10 +119,11 @@ export class ProfileSalaryController extends Controller {
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
refCommandDate: new Date(),
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
const _null:any = null;
const _null: any = null;
Object.assign(data, { ...body, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
@ -131,11 +132,11 @@ export class ProfileSalaryController extends Controller {
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
profile.amount = body?.amount??_null;
profile.positionSalaryAmount = body?.positionSalaryAmount??_null;
profile.mouthSalaryAmount = body.mouthSalaryAmount??_null;
profile.amount = body?.amount ?? _null;
profile.positionSalaryAmount = body?.positionSalaryAmount ?? _null;
profile.mouthSalaryAmount = body.mouthSalaryAmount ?? _null;
await this.profileRepo.save(profile, { data: req });
return new HttpSuccess();
}
@ -164,6 +165,7 @@ export class ProfileSalaryController extends Controller {
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
refCommandDate: new Date(),
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
@ -176,7 +178,7 @@ export class ProfileSalaryController extends Controller {
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
let null_:any = null;
let null_: any = null;
profile.amount = body.amount ?? null_;
profile.amountSpecial = body.amountSpecial ?? null_;
profile.positionSalaryAmount = body.positionSalaryAmount ?? null_;
@ -208,6 +210,7 @@ export class ProfileSalaryController extends Controller {
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
record.refCommandDate = new Date();
history.createdAt = new Date();
history.lastUpdatedAt = new Date();

View file

@ -130,6 +130,7 @@ export class ProfileSalaryEmployeeController extends Controller {
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
refCommandDate: new Date(),
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
@ -137,17 +138,17 @@ export class ProfileSalaryEmployeeController extends Controller {
Object.assign(data, { ...body, ...meta });
const history = new ProfileSalaryHistory();
Object.assign(history, { ...data, id: undefined });
const _null:any = null;
const _null: any = null;
await this.salaryRepo.save(data, { data: req });
setLogDataDiff(req, { before, after: data });
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
profile.amount = body?.amount??_null;
profile.positionSalaryAmount = body?.positionSalaryAmount??_null;
profile.mouthSalaryAmount = body.mouthSalaryAmount??_null;
profile.amount = body?.amount ?? _null;
profile.positionSalaryAmount = body?.positionSalaryAmount ?? _null;
profile.mouthSalaryAmount = body.mouthSalaryAmount ?? _null;
await this.profileRepo.save(profile, { data: req });
return new HttpSuccess();
}
@ -179,6 +180,7 @@ export class ProfileSalaryEmployeeController extends Controller {
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
refCommandDate: new Date(),
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
@ -191,8 +193,8 @@ export class ProfileSalaryEmployeeController extends Controller {
setLogDataDiff(req, { before, after: data });
history.profileSalaryId = data.id;
await this.salaryHistoryRepo.save(history, { data: req });
let null_:any = null;
let null_: any = null;
profile.amount = body.amount ?? null_;
profile.amountSpecial = body.amountSpecial ?? null_;
profile.positionSalaryAmount = body.positionSalaryAmount ?? null_;
@ -228,6 +230,7 @@ export class ProfileSalaryEmployeeController extends Controller {
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
record.refCommandDate = new Date();
history.createdAt = new Date();
history.lastUpdatedAt = new Date();

View file

@ -122,6 +122,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
refCommandDate: new Date(),
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
@ -158,6 +159,7 @@ export class ProfileSalaryEmployeeTempController extends Controller {
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
record.refCommandDate = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;