สร้างรอบพิเศษ
This commit is contained in:
parent
5ef3c3e417
commit
a4f9676297
1 changed files with 69 additions and 0 deletions
|
|
@ -1179,6 +1179,41 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryPeriod.lastUpdateUserId = request.user.sub;
|
||||
salaryPeriod.lastUpdateFullName = request.user.name;
|
||||
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||
|
||||
if (salaryPeriod.period == "SPECIAL") {
|
||||
const snapshot = "SNAP1";
|
||||
const salaryOrg = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
});
|
||||
const salaryProfile = await this.salaryProfileRepository.find({
|
||||
where: { salaryOrgId: In(salaryOrg.map((x) => x.id)) },
|
||||
});
|
||||
await this.salaryOrgRepository.remove(salaryOrg);
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
|
||||
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
|
||||
|
||||
salaryPeriod.revisionId = revisionId;
|
||||
await this.salaryPeriodRepository.save(salaryPeriod);
|
||||
|
||||
await Promise.all(
|
||||
orgs.map(async (rootId: string) => {
|
||||
let salaryOrgNew = Object.assign(new SalaryOrg());
|
||||
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
|
||||
salaryOrgNew.status = "PENDING";
|
||||
salaryOrgNew.rootId = rootId;
|
||||
salaryOrgNew.revisionId = salaryPeriod.revisionId;
|
||||
salaryOrgNew.snapshot = snapshot;
|
||||
salaryOrgNew.createdUserId = request.user.sub;
|
||||
salaryOrgNew.createdFullName = request.user.name;
|
||||
salaryOrgNew.lastUpdateUserId = request.user.sub;
|
||||
salaryOrgNew.lastUpdateFullName = request.user.name;
|
||||
salaryOrgNew.group = "GROUP1";
|
||||
await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
}),
|
||||
);
|
||||
}
|
||||
return new HttpSuccess(salaryPeriod.id);
|
||||
}
|
||||
|
||||
|
|
@ -1227,6 +1262,40 @@ export class SalaryPeriodController extends Controller {
|
|||
chk_SalaryPeriod.lastUpdatedAt = new Date();
|
||||
this.salaryPeriodRepository.merge(chk_SalaryPeriod, requestBody);
|
||||
await this.salaryPeriodRepository.save(chk_SalaryPeriod);
|
||||
if (chk_SalaryPeriod.period == "SPECIAL") {
|
||||
const snapshot = "SNAP1";
|
||||
const salaryOrg = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: chk_SalaryPeriod.id, snapshot: snapshot },
|
||||
});
|
||||
const salaryProfile = await this.salaryProfileRepository.find({
|
||||
where: { salaryOrgId: In(salaryOrg.map((x) => x.id)) },
|
||||
});
|
||||
await this.salaryOrgRepository.remove(salaryOrg);
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
|
||||
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
|
||||
|
||||
chk_SalaryPeriod.revisionId = revisionId;
|
||||
await this.salaryPeriodRepository.save(chk_SalaryPeriod);
|
||||
|
||||
await Promise.all(
|
||||
orgs.map(async (rootId: string) => {
|
||||
let salaryOrgNew = Object.assign(new SalaryOrg());
|
||||
salaryOrgNew.salaryPeriodId = chk_SalaryPeriod.id;
|
||||
salaryOrgNew.status = "PENDING";
|
||||
salaryOrgNew.rootId = rootId;
|
||||
salaryOrgNew.revisionId = chk_SalaryPeriod.revisionId;
|
||||
salaryOrgNew.snapshot = snapshot;
|
||||
salaryOrgNew.createdUserId = request.user.sub;
|
||||
salaryOrgNew.createdFullName = request.user.name;
|
||||
salaryOrgNew.lastUpdateUserId = request.user.sub;
|
||||
salaryOrgNew.lastUpdateFullName = request.user.name;
|
||||
salaryOrgNew.group = "GROUP1";
|
||||
await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
}),
|
||||
);
|
||||
}
|
||||
return new HttpSuccess(id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue