แก้บันทึกstepเงินเดือน

This commit is contained in:
Kittapath 2024-03-18 16:17:05 +07:00
parent 596efe624a
commit 64f9cd9421
2 changed files with 44 additions and 30 deletions

View file

@ -184,7 +184,8 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryProfile.salaryOrg.sixPercentAmount -
sumAmountUse.totalAmount -
salaryProfile.salaryOrg.spentAmount;
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
salaryProfile.salaryOrg.useAmount =
sumAmountUse == null || sumAmountUse.totalAmount == null ? 0 : sumAmountUse.totalAmount;
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
}
@ -415,7 +416,8 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryProfile.salaryOrg.sixPercentAmount -
sumAmountUse.totalAmount -
salaryProfile.salaryOrg.spentAmount;
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
salaryProfile.salaryOrg.useAmount =
sumAmountUse == null || sumAmountUse.totalAmount == null ? 0 : sumAmountUse.totalAmount;
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
}
@ -477,7 +479,8 @@ export class SalaryPeriodEmployeeController extends Controller {
.getRawOne();
const calRemainAmount =
salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount;
salaryOrg.useAmount = sumAmountUse.totalAmount;
salaryOrg.useAmount =
sumAmountUse == null || sumAmountUse.totalAmount == null ? 0 : sumAmountUse.totalAmount;
salaryOrg.remainingAmount = calRemainAmount;
await this.salaryOrgRepository.save(salaryOrg);
}
@ -737,7 +740,8 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryProfile.salaryOrg.sixPercentAmount -
sumAmountUse.totalAmount -
salaryProfile.salaryOrg.spentAmount;
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
salaryProfile.salaryOrg.useAmount =
sumAmountUse == null || sumAmountUse.totalAmount == null ? 0 : sumAmountUse.totalAmount;
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
await this.salaryOrgRepository.save(salaryProfile.salaryOrg);
}
@ -1125,7 +1129,8 @@ export class SalaryPeriodEmployeeController extends Controller {
.getRawOne();
const calRemainAmount =
salaryOrg.sixPercentAmount - sumAmountUse.totalAmount - salaryOrg.spentAmount;
_salaryOrg.useAmount = sumAmountUse.totalAmount;
_salaryOrg.useAmount =
sumAmountUse == null || sumAmountUse.totalAmount == null ? 0 : sumAmountUse.totalAmount;
_salaryOrg.remainingAmount = calRemainAmount;
await this.salaryOrgRepository.save(_salaryOrg);
}
@ -1461,10 +1466,12 @@ export class SalaryPeriodEmployeeController extends Controller {
if (!salaryPeriod)
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
await Promise.all(
salaryPeriod.salaryOrgs.map(async (x) => {
x.status = "WAITHEAD1";
await this.salaryPeriodRepository.save(salaryPeriod);
}),
salaryPeriod.salaryOrgs
.filter((x) => x.rootId == rootId)
.map(async (x: any) => {
x.status = "WAITHEAD1";
await this.salaryOrgRepository.save(x);
}),
);
return new HttpSuccess();
}
@ -1488,9 +1495,9 @@ export class SalaryPeriodEmployeeController extends Controller {
await Promise.all(
salaryPeriod.salaryOrgs
.filter((x) => x.rootId == rootId)
.map(async (x) => {
.map(async (x: any) => {
x.status = "WAITOWNER1";
await this.salaryPeriodRepository.save(salaryPeriod);
await this.salaryOrgRepository.save(x);
}),
);
return new HttpSuccess();
@ -1515,9 +1522,9 @@ export class SalaryPeriodEmployeeController extends Controller {
await Promise.all(
salaryPeriod.salaryOrgs
.filter((x) => x.rootId == rootId)
.map(async (x) => {
.map(async (x: any) => {
x.status = "REPORT";
await this.salaryPeriodRepository.save(salaryPeriod);
await this.salaryOrgRepository.save(x);
}),
);
return new HttpSuccess();
@ -1549,10 +1556,10 @@ export class SalaryPeriodEmployeeController extends Controller {
await Promise.all(
salaryPeriod.salaryOrgs
.filter((x) => x.rootId == rootId)
.map(async (x) => {
.map(async (x: any) => {
x.status = "WAITHEAD2";
x.ownerRecommend = body.titleRecommend;
await this.salaryPeriodRepository.save(salaryPeriod);
await this.salaryOrgRepository.save(x);
}),
);
return new HttpSuccess();
@ -1584,10 +1591,10 @@ export class SalaryPeriodEmployeeController extends Controller {
await Promise.all(
salaryPeriod.salaryOrgs
.filter((x) => x.rootId == rootId)
.map(async (x) => {
.map(async (x: any) => {
x.status = "REPORT";
x.ownerRecommend = body.titleRecommend;
await this.salaryPeriodRepository.save(salaryPeriod);
await this.salaryOrgRepository.save(x);
}),
);
return new HttpSuccess();