fix ระบบทะเบียนประวัติ>>ทะเบียนประวัติลูกจ้างชั่วคราว (รายชื่อแต่งตั้งเป็นลูกจ้างประจำ ไม่แสดง) #1407

This commit is contained in:
Bright 2025-04-17 16:08:42 +07:00
parent 33a5915bc1
commit 8895eb85d4

View file

@ -2119,75 +2119,73 @@ export class CommandController extends Controller {
refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId), refIds: requestBody.persons.filter((x) => x.refId != null).map((x) => x.refId),
status: "REPORT", status: "REPORT",
}) })
.then(async (res) => { .then(async (res) => {})
let order = .catch(() => {});
command.commandRecives == null || command.commandRecives.length <= 0 let order =
? 0 command.commandRecives == null || command.commandRecives.length <= 0
: command.commandRecives[0].order; ? 0
await Promise.all( : command.commandRecives[0].order;
requestBody.persons.map(async (item) => { await Promise.all(
const _commandRecive = await this.commandReciveRepository.findOne({ requestBody.persons.map(async (item) => {
const _commandRecive = await this.commandReciveRepository.findOne({
where: {
commandId: command.id,
refId: item.refId,
},
});
if (_commandRecive) return;
order = order + 1;
let commandRecive = new CommandRecive();
commandRecive = Object.assign(new CommandRecive(), item);
commandRecive.order = order;
let salaryData = _null;
// const excludedCommands = ["C-PM-33", "C-PM-34", "C-PM-35", "C-PM-36", "C-PM-37"];
// if (!excludedCommands.includes(commandCode)) {
if (item.profileId) {
salaryData = await this.profileRepository.findOne({
where: {
id: item.profileId,
},
});
let _setZero: any = 0;
if (!salaryData) {
salaryData = await this.profileEmployeeRepository.findOne({
where: { where: {
commandId: command.id, id: item.profileId,
refId: item.refId,
}, },
}); });
if (_commandRecive) return; }
order = order + 1; commandRecive.amount = item.amount ?? (salaryData ? salaryData.amount : _setZero);
let commandRecive = new CommandRecive(); commandRecive.amountSpecial =
commandRecive = Object.assign(new CommandRecive(), item); item.amountSpecial ?? (salaryData ? salaryData.amountSpecial : _setZero);
commandRecive.order = order; commandRecive.positionSalaryAmount =
let salaryData = _null; item.positionSalaryAmount ??
(salaryData ? salaryData.positionSalaryAmount : _setZero);
// const excludedCommands = ["C-PM-33", "C-PM-34", "C-PM-35", "C-PM-36", "C-PM-37"]; commandRecive.mouthSalaryAmount =
// if (!excludedCommands.includes(commandCode)) { item.mouthSalaryAmount ?? (salaryData ? salaryData.mouthSalaryAmount : _setZero);
if (item.profileId) { } else {
salaryData = await this.profileRepository.findOne({ commandRecive.amount = _null;
where: { commandRecive.amountSpecial = _null;
id: item.profileId, commandRecive.positionSalaryAmount = _null;
}, commandRecive.mouthSalaryAmount = _null;
}); }
let _setZero: any = 0;
if (!salaryData) {
salaryData = await this.profileEmployeeRepository.findOne({
where: {
id: item.profileId,
},
});
}
commandRecive.amount = item.amount ?? (salaryData ? salaryData.amount : _setZero);
commandRecive.amountSpecial =
item.amountSpecial ?? (salaryData ? salaryData.amountSpecial : _setZero);
commandRecive.positionSalaryAmount =
item.positionSalaryAmount ??
(salaryData ? salaryData.positionSalaryAmount : _setZero);
commandRecive.mouthSalaryAmount =
item.mouthSalaryAmount ?? (salaryData ? salaryData.mouthSalaryAmount : _setZero);
} else {
commandRecive.amount = _null;
commandRecive.amountSpecial = _null;
commandRecive.positionSalaryAmount = _null;
commandRecive.mouthSalaryAmount = _null;
}
commandRecive.remarkVertical =
item.remarkVertical == null ? _null : item.remarkVertical;
commandRecive.remarkHorizontal =
item.remarkHorizontal == null ? _null : item.remarkHorizontal;
commandRecive.order = order;
commandRecive.commandId = command.id;
commandRecive.createdUserId = request.user.sub;
commandRecive.createdFullName = request.user.name;
commandRecive.createdAt = new Date();
commandRecive.lastUpdateUserId = request.user.sub;
commandRecive.lastUpdateFullName = request.user.name;
commandRecive.lastUpdatedAt = new Date();
await this.commandReciveRepository.save(commandRecive);
}),
);
})
.catch(() => {});
commandRecive.remarkVertical =
item.remarkVertical == null ? _null : item.remarkVertical;
commandRecive.remarkHorizontal =
item.remarkHorizontal == null ? _null : item.remarkHorizontal;
commandRecive.order = order;
commandRecive.commandId = command.id;
commandRecive.createdUserId = request.user.sub;
commandRecive.createdFullName = request.user.name;
commandRecive.createdAt = new Date();
commandRecive.lastUpdateUserId = request.user.sub;
commandRecive.lastUpdateFullName = request.user.name;
commandRecive.lastUpdatedAt = new Date();
await this.commandReciveRepository.save(commandRecive);
}),
);
if ( if (
[ [
"C-PM-01", "C-PM-01",