เงินเดือนลูกจ้าง
This commit is contained in:
parent
6950954268
commit
fa79bb5b7a
8 changed files with 2893 additions and 270 deletions
|
|
@ -26,6 +26,8 @@ import { PosLevel } from "../entities/PosLevel";
|
|||
import { Salarys } from "../entities/Salarys";
|
||||
import { SalaryRanks } from "../entities/SalaryRanks";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { SalaryOrgEmployee } from "../entities/SalaryOrgEmployee";
|
||||
import { SalaryProfileEmployee } from "../entities/SalaryProfileEmployee";
|
||||
|
||||
@Route("api/v1/salary/period")
|
||||
@Tags("Salary")
|
||||
|
|
@ -33,7 +35,9 @@ import CallAPI from "../interfaces/call-api";
|
|||
export class SalaryPeriodController extends Controller {
|
||||
private salaryPeriodRepository = AppDataSource.getRepository(SalaryPeriod);
|
||||
private salaryOrgRepository = AppDataSource.getRepository(SalaryOrg);
|
||||
private salaryOrgEmployeeRepository = AppDataSource.getRepository(SalaryOrgEmployee);
|
||||
private salaryProfileRepository = AppDataSource.getRepository(SalaryProfile);
|
||||
private salaryProfileEmployeeRepository = AppDataSource.getRepository(SalaryProfileEmployee);
|
||||
private posTypeRepository = AppDataSource.getRepository(PosType);
|
||||
private posLevelRepository = AppDataSource.getRepository(PosLevel);
|
||||
private salaryRepository = AppDataSource.getRepository(Salarys);
|
||||
|
|
@ -1466,6 +1470,16 @@ export class SalaryPeriodController extends Controller {
|
|||
});
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
await this.salaryOrgRepository.remove(salaryOrg);
|
||||
|
||||
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", {
|
||||
|
|
@ -1493,6 +1507,37 @@ export class SalaryPeriodController extends Controller {
|
|||
});
|
||||
}
|
||||
}
|
||||
total = 1000;
|
||||
let orgProfileEmployees: any;
|
||||
let _orgProfileEmployees = await new CallAPI().PostData(
|
||||
request,
|
||||
"org/unauthorize/profile/salary/employee/gen",
|
||||
{
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
},
|
||||
);
|
||||
orgProfileEmployees = _orgProfileEmployees.data;
|
||||
total = _orgProfileEmployees.total;
|
||||
if (total > 1000) {
|
||||
const page = Math.ceil(total / 1000);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/orgProfileEmployees/gen", {
|
||||
page: index,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
})
|
||||
.then((x) => {
|
||||
Array.prototype.push.apply(orgProfileEmployees, x.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
|
||||
|
||||
salaryPeriod.revisionId = revisionId;
|
||||
|
|
@ -1520,6 +1565,28 @@ export class SalaryPeriodController extends Controller {
|
|||
}
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
orgs.map(async (rootId: string) => {
|
||||
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
|
||||
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);
|
||||
// if (salaryPeriod.period != "SPECIAL") {
|
||||
// delete salaryOrgNew.id;
|
||||
// salaryOrgNew.group = "GROUP2";
|
||||
// await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
// }
|
||||
}),
|
||||
);
|
||||
if (salaryPeriod.period != "SPECIAL") {
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
|
|
@ -1575,12 +1642,58 @@ export class SalaryPeriodController extends Controller {
|
|||
}
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
const salaryOrgNew = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: "GROUP1",
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfileEmployee(), 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.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileEmployeeRepository.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;
|
||||
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
||||
}
|
||||
await this.salaryProfileEmployeeRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
const salaryOrgEmployeeNew = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
if (salaryPeriod.period == "OCT") {
|
||||
const salaryPeriodAPROld = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -1640,6 +1753,58 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
let totalAmount = 0;
|
||||
if (salaryPeriodAPROld != null) {
|
||||
const salaryOrgSnap2Old: any = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodAPROld.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
totalAmount =
|
||||
salaryOrgSnap2Old == null
|
||||
? 0
|
||||
: Extension.sumObjectValues(salaryOrgSnap2Old.salaryProfiles, "amountUse");
|
||||
}
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
} else {
|
||||
_salaryOrg.currentAmount = salaryOrgSnap1.currentAmount;
|
||||
_salaryOrg.sixPercentAmount = salaryOrgSnap1.sixPercentAmount;
|
||||
_salaryOrg.spentAmount = salaryOrgSnap1.spentAmount;
|
||||
_salaryOrg.useAmount = salaryOrgSnap1.useAmount;
|
||||
_salaryOrg.remainingAmount = salaryOrgSnap1.remainingAmount;
|
||||
}
|
||||
} else {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
} else if (salaryPeriod.period == "APR") {
|
||||
await Promise.all(
|
||||
salaryOrgNew.map(async (_salaryOrg: SalaryOrg) => {
|
||||
|
|
@ -1674,6 +1839,39 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
} else {
|
||||
_salaryOrg.total = salaryOrgSnap1.total;
|
||||
_salaryOrg.fifteenPercent = salaryOrgSnap1.fifteenPercent;
|
||||
_salaryOrg.fifteenPoint = salaryOrgSnap1.fifteenPoint;
|
||||
_salaryOrg.quantityUsed = salaryOrgSnap1.quantityUsed;
|
||||
_salaryOrg.remainQuota = salaryOrgSnap1.remainQuota;
|
||||
}
|
||||
} else {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
@ -1754,25 +1952,23 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
let orgs = await new CallAPI().GetData(request, "org/unauthorize/active/root/id");
|
||||
let orgProfiles: any;
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/gen", {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
})
|
||||
.then((x) => {
|
||||
orgProfiles = x.data;
|
||||
});
|
||||
if (orgProfiles.total > 100) {
|
||||
const page = Math.ceil(orgProfiles.total.length / 100);
|
||||
let total = 1000;
|
||||
let _orgProfiles = await new CallAPI().PostData(request, "org/unauthorize/salary/gen", {
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
});
|
||||
let orgProfiles = _orgProfiles.data;
|
||||
total = _orgProfiles.total;
|
||||
if (total > 1000) {
|
||||
const page = Math.ceil(total / 1000);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/gen", {
|
||||
page: index,
|
||||
pageSize: 100,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
|
|
@ -1782,6 +1978,37 @@ export class SalaryPeriodController extends Controller {
|
|||
});
|
||||
}
|
||||
}
|
||||
total = 1000;
|
||||
let orgProfileEmployees: any;
|
||||
let _orgProfileEmployees = await new CallAPI().PostData(
|
||||
request,
|
||||
"org/unauthorize/profile/salary/employee/gen",
|
||||
{
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
},
|
||||
);
|
||||
orgProfileEmployees = _orgProfileEmployees.data;
|
||||
total = _orgProfileEmployees.total;
|
||||
if (total > 1000) {
|
||||
const page = Math.ceil(total / 1000);
|
||||
for (let index = 2; index <= page; index++) {
|
||||
await new CallAPI()
|
||||
.PostData(request, "org/unauthorize/profile/salary/orgProfileEmployees/gen", {
|
||||
page: index,
|
||||
pageSize: 1000,
|
||||
keyword: "",
|
||||
year: salaryPeriod.year,
|
||||
period: salaryPeriod.period,
|
||||
})
|
||||
.then((x) => {
|
||||
Array.prototype.push.apply(orgProfileEmployees, x.data);
|
||||
});
|
||||
}
|
||||
}
|
||||
let revisionId = await new CallAPI().GetData(request, "org/unauthorize/revision/latest");
|
||||
|
||||
salaryPeriod.revisionId = revisionId;
|
||||
|
|
@ -1809,6 +2036,28 @@ export class SalaryPeriodController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
orgs.map(async (rootId: string) => {
|
||||
let salaryOrgNew = Object.assign(new SalaryOrgEmployee());
|
||||
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);
|
||||
// if (salaryPeriod.period != "SPECIAL") {
|
||||
// delete salaryOrgNew.id;
|
||||
// salaryOrgNew.group = "GROUP2";
|
||||
// await this.salaryOrgRepository.save(salaryOrgNew);
|
||||
// }
|
||||
}),
|
||||
);
|
||||
|
||||
if (salaryPeriod.period != "SPECIAL") {
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
|
|
@ -1863,12 +2112,58 @@ export class SalaryPeriodController extends Controller {
|
|||
}
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
orgProfiles.map(async (profile: any) => {
|
||||
const salaryOrgNew = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: profile.rootId,
|
||||
snapshot: snapshot,
|
||||
group: "GROUP1",
|
||||
},
|
||||
});
|
||||
|
||||
if (salaryOrgNew != null) {
|
||||
let salaryProfileNew = Object.assign(new SalaryProfileEmployee(), 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.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: "SNAP1" },
|
||||
});
|
||||
const salaryOld = await this.salaryProfileEmployeeRepository.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;
|
||||
salaryProfileNew.isNext = salaryOld == null ? false : salaryOld.isNext;
|
||||
}
|
||||
await this.salaryProfileEmployeeRepository.save(salaryProfileNew);
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const salaryOrgNew = await this.salaryOrgRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
const salaryOrgEmployeeNew = await this.salaryOrgEmployeeRepository.find({
|
||||
where: { salaryPeriodId: salaryPeriod.id, snapshot: snapshot },
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
if (salaryPeriod.period == "OCT") {
|
||||
const salaryPeriodAPROld = await this.salaryPeriodRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -1928,6 +2223,58 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
let totalAmount = 0;
|
||||
if (salaryPeriodAPROld != null) {
|
||||
const salaryOrgSnap2Old: any = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriodAPROld.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP2",
|
||||
},
|
||||
relations: ["salaryProfiles"],
|
||||
});
|
||||
totalAmount =
|
||||
salaryOrgSnap2Old == null
|
||||
? 0
|
||||
: Extension.sumObjectValues(salaryOrgSnap2Old.salaryProfiles, "amountUse");
|
||||
}
|
||||
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
} else {
|
||||
_salaryOrg.currentAmount = salaryOrgSnap1.currentAmount;
|
||||
_salaryOrg.sixPercentAmount = salaryOrgSnap1.sixPercentAmount;
|
||||
_salaryOrg.spentAmount = salaryOrgSnap1.spentAmount;
|
||||
_salaryOrg.useAmount = salaryOrgSnap1.useAmount;
|
||||
_salaryOrg.remainingAmount = salaryOrgSnap1.remainingAmount;
|
||||
}
|
||||
} else {
|
||||
const totalProfile = Extension.sumObjectValues(_salaryOrg.salaryProfiles, "amount");
|
||||
_salaryOrg.currentAmount = totalProfile;
|
||||
_salaryOrg.sixPercentAmount = totalProfile * 0.06;
|
||||
_salaryOrg.spentAmount = totalAmount;
|
||||
_salaryOrg.remainingAmount = totalProfile * 0.06 - totalAmount;
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
} else if (salaryPeriod.period == "APR") {
|
||||
await Promise.all(
|
||||
salaryOrgNew.map(async (_salaryOrg: SalaryOrg) => {
|
||||
|
|
@ -1962,6 +2309,39 @@ export class SalaryPeriodController extends Controller {
|
|||
await this.salaryOrgRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
await Promise.all(
|
||||
salaryOrgEmployeeNew.map(async (_salaryOrg: SalaryOrgEmployee) => {
|
||||
if (snapshot == "SNAP2") {
|
||||
const salaryOrgSnap1 = await this.salaryOrgEmployeeRepository.findOne({
|
||||
where: {
|
||||
salaryPeriodId: salaryPeriod.id,
|
||||
rootId: _salaryOrg.rootId,
|
||||
group: _salaryOrg.group,
|
||||
snapshot: "SNAP1",
|
||||
},
|
||||
});
|
||||
if (salaryOrgSnap1 == null) {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
} else {
|
||||
_salaryOrg.total = salaryOrgSnap1.total;
|
||||
_salaryOrg.fifteenPercent = salaryOrgSnap1.fifteenPercent;
|
||||
_salaryOrg.fifteenPoint = salaryOrgSnap1.fifteenPoint;
|
||||
_salaryOrg.quantityUsed = salaryOrgSnap1.quantityUsed;
|
||||
_salaryOrg.remainQuota = salaryOrgSnap1.remainQuota;
|
||||
}
|
||||
} else {
|
||||
_salaryOrg.total = _salaryOrg.salaryProfiles.length;
|
||||
_salaryOrg.fifteenPercent = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
_salaryOrg.fifteenPoint = (_salaryOrg.salaryProfiles.length * 15) % 100;
|
||||
_salaryOrg.remainQuota = Math.floor((_salaryOrg.salaryProfiles.length * 15) / 100);
|
||||
}
|
||||
|
||||
await this.salaryOrgEmployeeRepository.save(_salaryOrg);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue