เพิ่ม snap รอบพิเศษ
This commit is contained in:
parent
33a5cf2a57
commit
b7da166a82
1 changed files with 109 additions and 106 deletions
|
|
@ -1140,60 +1140,61 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
let group = "GROUP1";
|
||||
if (
|
||||
(profile.posType == "ทั่วไป" && profile.posLevel == "ทักษะพิเศษ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "เชี่ยวชาญ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "ทรงคุณวุฒิ") ||
|
||||
(profile.posType == "อำนวยการ" && profile.posLevel == "สูง") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "ต้น") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "สูง")
|
||||
) {
|
||||
group = "GROUP2";
|
||||
}
|
||||
const salaryOrgNew = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: group,
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfile(), profile);
|
||||
delete profile.id;
|
||||
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
||||
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryProfileNew.createdUserId = request.user.sub;
|
||||
salaryProfileNew.createdFullName = request.user.name;
|
||||
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
||||
salaryProfileNew.lastUpdateFullName = request.user.name;
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgOld = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileRepository.findOne({
|
||||
where: {
|
||||
citizenId: salaryProfileNew.citizenId,
|
||||
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
||||
},
|
||||
});
|
||||
salaryProfileNew.type = salaryOld == null ? "PENDING" : salaryOld.type;
|
||||
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
||||
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||
salaryProfileNew.positionSalaryAmount =
|
||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||
if (salaryPeriod.period != "SPECIAL") {
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
let group = "GROUP1";
|
||||
if (
|
||||
(profile.posType == "ทั่วไป" && profile.posLevel == "ทักษะพิเศษ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "เชี่ยวชาญ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "ทรงคุณวุฒิ") ||
|
||||
(profile.posType == "อำนวยการ" && profile.posLevel == "สูง") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "ต้น") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "สูง")
|
||||
) {
|
||||
group = "GROUP2";
|
||||
}
|
||||
await this.salaryProfileRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
const salaryOrgNew = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: group,
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfile(), profile);
|
||||
delete profile.id;
|
||||
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
||||
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryProfileNew.createdUserId = request.user.sub;
|
||||
salaryProfileNew.createdFullName = request.user.name;
|
||||
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
||||
salaryProfileNew.lastUpdateFullName = request.user.name;
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgOld = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileRepository.findOne({
|
||||
where: {
|
||||
citizenId: salaryProfileNew.citizenId,
|
||||
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
||||
},
|
||||
});
|
||||
salaryProfileNew.type = salaryOld == null ? "PENDING" : salaryOld.type;
|
||||
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
||||
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||
salaryProfileNew.positionSalaryAmount =
|
||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||
}
|
||||
await this.salaryProfileRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
|
|
@ -1258,7 +1259,7 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
} else if (salaryPeriod.period == "APR") {
|
||||
await Promise.all(
|
||||
salaryOrgNew.map(async (_salaryOrg: SalaryOrg) => {
|
||||
if (snapshot == "SNAP2") {
|
||||
|
|
@ -1422,58 +1423,60 @@ export class SalaryPeriodController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
let group = "GROUP1";
|
||||
if (
|
||||
(profile.posType == "ทั่วไป" && profile.posLevel == "ทักษะพิเศษ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "เชี่ยวชาญ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "ทรงคุณวุฒิ") ||
|
||||
(profile.posType == "อำนวยการ" && profile.posLevel == "สูง") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "ต้น") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "สูง")
|
||||
) {
|
||||
group = "GROUP2";
|
||||
}
|
||||
const salaryOrgNew = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: group,
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfile(), profile);
|
||||
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
||||
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryProfileNew.createdUserId = request.user.sub;
|
||||
salaryProfileNew.createdFullName = request.user.name;
|
||||
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
||||
salaryProfileNew.lastUpdateFullName = request.user.name;
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgOld = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileRepository.findOne({
|
||||
where: {
|
||||
citizenId: salaryProfileNew.citizenId,
|
||||
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
||||
},
|
||||
});
|
||||
salaryProfileNew.type = salaryOld == null ? 0 : salaryOld.type;
|
||||
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
||||
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||
salaryProfileNew.positionSalaryAmount =
|
||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||
if (salaryPeriod.period != "SPECIAL") {
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
let group = "GROUP1";
|
||||
if (
|
||||
(profile.posType == "ทั่วไป" && profile.posLevel == "ทักษะพิเศษ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "เชี่ยวชาญ") ||
|
||||
(profile.posType == "วิชาการ" && profile.posLevel == "ทรงคุณวุฒิ") ||
|
||||
(profile.posType == "อำนวยการ" && profile.posLevel == "สูง") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "ต้น") ||
|
||||
(profile.posType == "บริหาร" && profile.posLevel == "สูง")
|
||||
) {
|
||||
group = "GROUP2";
|
||||
}
|
||||
await this.salaryProfileRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
const salaryOrgNew = await this.salaryOrgRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: group,
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfile(), profile);
|
||||
salaryProfileNew.salaryOrgId = salaryOrgNew.id;
|
||||
salaryProfileNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryProfileNew.createdUserId = request.user.sub;
|
||||
salaryProfileNew.createdFullName = request.user.name;
|
||||
salaryProfileNew.lastUpdateUserId = request.user.sub;
|
||||
salaryProfileNew.lastUpdateFullName = request.user.name;
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgOld = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileRepository.findOne({
|
||||
where: {
|
||||
citizenId: salaryProfileNew.citizenId,
|
||||
salaryOrgId: In(salaryOrgOld.map((x) => x.id)),
|
||||
},
|
||||
});
|
||||
salaryProfileNew.type = salaryOld == null ? 0 : salaryOld.type;
|
||||
salaryProfileNew.amount = salaryOld == null ? 0 : salaryOld.amount;
|
||||
salaryProfileNew.amountSpecial = salaryOld == null ? 0 : salaryOld.amountSpecial;
|
||||
salaryProfileNew.amountUse = salaryOld == null ? 0 : salaryOld.amountUse;
|
||||
salaryProfileNew.positionSalaryAmount =
|
||||
salaryOld == null ? 0 : salaryOld.positionSalaryAmount;
|
||||
}
|
||||
await this.salaryProfileRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
|
|
@ -1538,7 +1541,7 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
} else if (salaryPeriod.period == "APR") {
|
||||
await Promise.all(
|
||||
salaryOrgNew.map(async (_salaryOrg: SalaryOrg) => {
|
||||
if (snapshot == "SNAP2") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue