dashboard เงินเดือน

This commit is contained in:
Kittapath 2024-03-27 16:39:45 +07:00
parent 94d0412e21
commit 76f42d1a96
3 changed files with 191 additions and 12 deletions

View file

@ -1213,6 +1213,15 @@ export class SalaryPeriodController extends Controller {
await this.salaryOrgRepository.remove(salaryOrg);
await this.salaryProfileRepository.remove(salaryProfile);
const salaryOrgEmployee = await this.salaryOrgEmployeeRepository.find({
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
});
const salaryProfileEmployee = await this.salaryProfileEmployeeRepository.find({
where: { salaryOrgId: In(salaryOrgEmployee.map((x) => x.id)) },
});
await this.salaryProfileEmployeeRepository.remove(salaryProfileEmployee);
await this.salaryOrgEmployeeRepository.remove(salaryOrgEmployee);
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
@ -1220,11 +1229,29 @@ export class SalaryPeriodController extends Controller {
await this.salaryPeriodRepository.save(salaryPeriod);
await Promise.all(
orgs.map(async (rootId: string) => {
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrg());
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = rootId;
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
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);
}),
);
await Promise.all(
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
salaryOrgNew.createdUserId = request.user.sub;
@ -1295,6 +1322,15 @@ export class SalaryPeriodController extends Controller {
await this.salaryOrgRepository.remove(salaryOrg);
await this.salaryProfileRepository.remove(salaryProfile);
const salaryOrgEmployee = await this.salaryOrgEmployeeRepository.find({
where: { salaryPeriodId: chk_SalaryPeriod.id, snapshot: snapshot },
});
const salaryProfileEmployee = await this.salaryProfileEmployeeRepository.find({
where: { salaryOrgId: In(salaryOrgEmployee.map((x) => x.id)) },
});
await this.salaryProfileEmployeeRepository.remove(salaryProfileEmployee);
await this.salaryOrgEmployeeRepository.remove(salaryOrgEmployee);
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
@ -1302,11 +1338,30 @@ export class SalaryPeriodController extends Controller {
await this.salaryPeriodRepository.save(chk_SalaryPeriod);
await Promise.all(
orgs.map(async (rootId: string) => {
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrg());
salaryOrgNew.salaryPeriodId = chk_SalaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = rootId;
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
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);
}),
);
await Promise.all(
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
salaryOrgNew.salaryPeriodId = chk_SalaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = chk_SalaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
salaryOrgNew.createdUserId = request.user.sub;
@ -1591,12 +1646,13 @@ export class SalaryPeriodController extends Controller {
await this.salaryPeriodRepository.save(salaryPeriod);
await Promise.all(
orgs.map(async (rootId: string) => {
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrg());
delete salaryOrgNew.id;
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = rootId;
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
salaryOrgNew.createdUserId = request.user.sub;
@ -1614,11 +1670,12 @@ export class SalaryPeriodController extends Controller {
);
await Promise.all(
orgs.map(async (rootId: string) => {
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = rootId;
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
salaryOrgNew.createdUserId = request.user.sub;
@ -2004,6 +2061,15 @@ export class SalaryPeriodController extends Controller {
await this.salaryOrgRepository.remove(salaryOrg);
await this.salaryProfileRepository.remove(salaryProfile);
const salaryOrgEmployee = await this.salaryOrgEmployeeRepository.find({
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
});
const salaryProfileEmployee = await this.salaryProfileEmployeeRepository.find({
where: { salaryOrgId: In(salaryOrgEmployee.map((x) => x.id)) },
});
await this.salaryProfileEmployeeRepository.remove(salaryProfileEmployee);
await this.salaryOrgEmployeeRepository.remove(salaryOrgEmployee);
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
let total = 1000;
let _orgProfiles = await new CallAPI().PostData(request, "org/unauthorize/salary/gen", {
@ -2067,11 +2133,12 @@ export class SalaryPeriodController extends Controller {
await this.salaryPeriodRepository.save(salaryPeriod);
await Promise.all(
orgs.map(async (rootId: string) => {
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrg());
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = rootId;
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
salaryOrgNew.createdUserId = request.user.sub;
@ -2089,11 +2156,12 @@ export class SalaryPeriodController extends Controller {
);
await Promise.all(
orgs.map(async (rootId: string) => {
orgs.map(async (root: any) => {
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
salaryOrgNew.salaryPeriodId = salaryPeriod.id;
salaryOrgNew.status = "PENDING";
salaryOrgNew.rootId = rootId;
salaryOrgNew.rootId = root.rootId;
salaryOrgNew.root = root.root;
salaryOrgNew.revisionId = salaryPeriod.revisionId;
salaryOrgNew.snapshot = snapshot;
salaryOrgNew.createdUserId = request.user.sub;