เพิ่มวันเวลา แก้ไข/สร้าง

This commit is contained in:
kittapath 2024-09-03 14:48:19 +07:00
parent 2a117223f7
commit 5c2569e5b4
10 changed files with 284 additions and 0 deletions

View file

@ -290,6 +290,9 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryOrg.quantityUsed = amountFullType;
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
salaryOrg.remainQuota = calRemainQuota;
salaryOrg.lastUpdateUserId = request.user.sub;
salaryOrg.lastUpdateFullName = request.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: request });
}
}
@ -344,6 +347,9 @@ export class SalaryPeriodEmployeeController extends Controller {
? 0
: sumAmountUse.totalAmount;
salaryOrg.remainingAmount = calRemainAmount;
salaryOrg.lastUpdateUserId = request.user.sub;
salaryOrg.lastUpdateFullName = request.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: request });
}
}
@ -713,6 +719,9 @@ export class SalaryPeriodEmployeeController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
}
salaryProfile.lastUpdateUserId = req.user.sub;
salaryProfile.lastUpdateFullName = req.user.name;
salaryProfile.lastUpdatedAt = new Date();
const before = structuredClone(salaryProfile);
await this.salaryProfileRepository.save(salaryProfile, { data: req });
setLogDataDiff(req, { before, after: salaryProfile });
@ -746,6 +755,9 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryOrg.quantityUsed = amountFullType;
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
salaryOrg.remainQuota = calRemainQuota;
salaryOrg.lastUpdateUserId = req.user.sub;
salaryOrg.lastUpdateFullName = req.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: req });
setLogDataDiff(req, { before, after: salaryOrg });
}
@ -801,6 +813,9 @@ export class SalaryPeriodEmployeeController extends Controller {
? 0
: sumAmountUse.totalAmount;
salaryOrg.remainingAmount = calRemainAmount;
salaryOrg.lastUpdateUserId = req.user.sub;
salaryOrg.lastUpdateFullName = req.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: req });
setLogDataDiff(req, { before, after: salaryOrg });
}
@ -842,6 +857,9 @@ export class SalaryPeriodEmployeeController extends Controller {
}
const before = null;
salaryProfile.salaryOrgId = salaryOrg.id;
salaryProfile.lastUpdateUserId = req.user.sub;
salaryProfile.lastUpdateFullName = req.user.name;
salaryProfile.lastUpdatedAt = new Date();
await this.salaryProfileRepository.save(salaryProfile, { data: req });
setLogDataDiff(req, { before, after: salaryProfile });
const _salaryProfile = await this.salaryProfileRepository.findOne({
@ -873,6 +891,9 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryOrg.quantityUsed = amountFullType;
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
salaryOrg.remainQuota = calRemainQuota;
salaryOrg.lastUpdateUserId = req.user.sub;
salaryOrg.lastUpdateFullName = req.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: req });
setLogDataDiff(req, { before, after: salaryOrg });
}
@ -928,6 +949,9 @@ export class SalaryPeriodEmployeeController extends Controller {
? 0
: sumAmountUse.totalAmount;
salaryOrg.remainingAmount = calRemainAmount;
salaryOrg.lastUpdateUserId = req.user.sub;
salaryOrg.lastUpdateFullName = req.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: req });
setLogDataDiff(req, { before, after: salaryOrg });
}
@ -1334,6 +1358,9 @@ export class SalaryPeriodEmployeeController extends Controller {
} else {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
}
salaryProfile.lastUpdateUserId = req.user.sub;
salaryProfile.lastUpdateFullName = req.user.name;
salaryProfile.lastUpdatedAt = new Date();
const before = structuredClone(salaryProfile);
await this.salaryProfileRepository.save(salaryProfile, { data: req });
setLogDataDiff(req, { before, after: salaryProfile });
@ -1367,6 +1394,9 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryOrg.quantityUsed = amountFullType;
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
salaryOrg.remainQuota = calRemainQuota;
salaryOrg.lastUpdateUserId = req.user.sub;
salaryOrg.lastUpdateFullName = req.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: req });
setLogDataDiff(req, { before, after: salaryOrg });
}
@ -1422,6 +1452,9 @@ export class SalaryPeriodEmployeeController extends Controller {
? 0
: sumAmountUse.totalAmount;
salaryOrg.remainingAmount = calRemainAmount;
salaryOrg.lastUpdateUserId = req.user.sub;
salaryOrg.lastUpdateFullName = req.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: req });
setLogDataDiff(req, { before, after: salaryOrg });
}
@ -2003,6 +2036,8 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryProfile.createdFullName = request.user.name;
salaryProfile.lastUpdateUserId = request.user.sub;
salaryProfile.lastUpdateFullName = request.user.name;
salaryProfile.createdAt = new Date();
salaryProfile.lastUpdatedAt = new Date();
await this.salaryProfileRepository.save(salaryProfile, { data: request });
setLogDataDiff(request, { before, after: salaryProfile });
@ -2035,6 +2070,9 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryOrg.quantityUsed = amountFullType;
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
salaryOrg.remainQuota = calRemainQuota;
salaryOrg.lastUpdateUserId = request.user.sub;
salaryOrg.lastUpdateFullName = request.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: request });
setLogDataDiff(request, { before, after: salaryOrg });
}
@ -2090,6 +2128,9 @@ export class SalaryPeriodEmployeeController extends Controller {
? 0
: sumAmountUse.totalAmount;
salaryOrg.remainingAmount = calRemainAmount;
salaryOrg.lastUpdateUserId = request.user.sub;
salaryOrg.lastUpdateFullName = request.user.name;
salaryOrg.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(salaryOrg, { data: request });
setLogDataDiff(request, { before, after: salaryOrg });
}
@ -2119,6 +2160,9 @@ export class SalaryPeriodEmployeeController extends Controller {
}
const before = structuredClone(salaryPeriod);
salaryPeriod.isClose = !salaryPeriod.isClose;
salaryPeriod.lastUpdateUserId = request.user.sub;
salaryPeriod.lastUpdateFullName = request.user.name;
salaryPeriod.lastUpdatedAt = new Date();
await this.salaryPeriodRepository.save(salaryPeriod, { data: request });
setLogDataDiff(request, { before, after: salaryPeriod });
return new HttpSuccess();
@ -2162,6 +2206,8 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryPeriod.createdFullName = request.user.name;
salaryPeriod.lastUpdateUserId = request.user.sub;
salaryPeriod.lastUpdateFullName = request.user.name;
salaryPeriod.createdAt = new Date();
salaryPeriod.lastUpdatedAt = new Date();
await this.salaryPeriodRepository.save(salaryPeriod, { data: request });
setLogDataDiff(request, { before, after: salaryPeriod });
@ -2180,6 +2226,9 @@ export class SalaryPeriodEmployeeController extends Controller {
let revisionId = await new CallAPI().GetData(request, "/org/unauthorize/revision/latest");
salaryPeriod.revisionId = revisionId;
salaryPeriod.lastUpdateUserId = request.user.sub;
salaryPeriod.lastUpdateFullName = request.user.name;
salaryPeriod.lastUpdatedAt = new Date();
await this.salaryPeriodRepository.save(salaryPeriod, { data: request });
setLogDataDiff(request, { before, after: salaryPeriod });
@ -2195,6 +2244,8 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryOrgNew.createdFullName = request.user.name;
salaryOrgNew.lastUpdateUserId = request.user.sub;
salaryOrgNew.lastUpdateFullName = request.user.name;
salaryOrgNew.createdAt = new Date();
salaryOrgNew.lastUpdatedAt = new Date();
salaryOrgNew.group = "GROUP1";
await this.salaryOrgRepository.save(salaryOrgNew, { data: request });
setLogDataDiff(request, { before, after: salaryOrgNew });
@ -2267,6 +2318,9 @@ export class SalaryPeriodEmployeeController extends Controller {
let revisionId = await new CallAPI().GetData(request, "/org/unauthorize/revision/latest");
chk_SalaryPeriod.revisionId = revisionId;
chk_SalaryPeriod.lastUpdateUserId = request.user.sub;
chk_SalaryPeriod.lastUpdateFullName = request.user.name;
chk_SalaryPeriod.lastUpdatedAt = new Date();
await this.salaryPeriodRepository.save(chk_SalaryPeriod, { data: request });
setLogDataDiff(request, { before: beforechk_SalaryPeriod, after: chk_SalaryPeriod });
@ -2283,6 +2337,8 @@ export class SalaryPeriodEmployeeController extends Controller {
salaryOrgNew.createdFullName = request.user.name;
salaryOrgNew.lastUpdateUserId = request.user.sub;
salaryOrgNew.lastUpdateFullName = request.user.name;
salaryOrgNew.createdAt = new Date();
salaryOrgNew.lastUpdatedAt = new Date();
salaryOrgNew.group = "GROUP1";
await this.salaryOrgRepository.save(salaryOrgNew, { data: request });
setLogDataDiff(request, { before, after: salaryOrgNew });
@ -2451,6 +2507,9 @@ export class SalaryPeriodEmployeeController extends Controller {
.map(async (x: any) => {
const before = structuredClone(x);
x.status = "WAITHEAD1";
x.lastUpdateUserId = request.user.sub;
x.lastUpdateFullName = request.user.name;
x.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(x, { data: request });
setLogDataDiff(request, { before, after: x });
}),
@ -2480,6 +2539,9 @@ export class SalaryPeriodEmployeeController extends Controller {
.map(async (x: any) => {
const before = structuredClone(x);
x.status = "WAITOWNER1";
x.lastUpdateUserId = request.user.sub;
x.lastUpdateFullName = request.user.name;
x.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(x, { data: request });
setLogDataDiff(request, { before, after: x });
}),
@ -2513,6 +2575,9 @@ export class SalaryPeriodEmployeeController extends Controller {
.map(async (x: any) => {
const before = structuredClone(x);
x.status = "REPORT";
x.lastUpdateUserId = request.user.sub;
x.lastUpdateFullName = request.user.name;
x.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(x, { data: request });
setLogDataDiff(request, { before, after: x });
}),
@ -2552,6 +2617,9 @@ export class SalaryPeriodEmployeeController extends Controller {
const before = structuredClone(x);
x.status = "WAITHEAD2";
x.ownerRecommend = body.titleRecommend;
x.lastUpdateUserId = request.user.sub;
x.lastUpdateFullName = request.user.name;
x.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(x, { data: request });
setLogDataDiff(request, { before, after: x });
}),
@ -2591,6 +2659,9 @@ export class SalaryPeriodEmployeeController extends Controller {
const before = structuredClone(x);
x.status = "REPORT";
x.ownerRecommend = body.titleRecommend;
x.lastUpdateUserId = request.user.sub;
x.lastUpdateFullName = request.user.name;
x.lastUpdatedAt = new Date();
await this.salaryOrgRepository.save(x, { data: request });
setLogDataDiff(request, { before, after: x });
}),