no message
This commit is contained in:
parent
23b8909706
commit
f0a815f75c
1 changed files with 64 additions and 66 deletions
|
|
@ -143,18 +143,18 @@ export class SalaryPeriodController extends Controller {
|
|||
@Delete("profile/{id}")
|
||||
async deleteSalaryProfile(@Path() id: string) {
|
||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||
relations: ["salaryOrg","salaryOrg.salaryPeriod"],
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: { id: id },
|
||||
});
|
||||
if (!salaryProfile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ");
|
||||
}
|
||||
|
||||
await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
// await this.salaryProfileRepository.remove(salaryProfile);
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if(salaryProfile.salaryOrg.salaryPeriod.period == "APR"){
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
|
|
@ -165,16 +165,17 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}else if(salaryProfile.salaryOrg.salaryPeriod.period == "OCT"){
|
||||
} else if (salaryProfile.salaryOrg.salaryPeriod.period == "OCT") {
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
||||
.where({
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select("SUM(salaryProfile.amountUse)", "totalAmount")
|
||||
.where({
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: 'FULL',
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
type: "FULL",
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount =
|
||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
|
|
@ -195,7 +196,7 @@ export class SalaryPeriodController extends Controller {
|
|||
@Post("change/amount")
|
||||
async changeAmount(@Body() body: { profileId: string; amount: number }) {
|
||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||
relations: ["salaryOrg","salaryOrg.salaryPeriod"],
|
||||
relations: ["salaryOrg"],
|
||||
where: { id: body.profileId },
|
||||
});
|
||||
if (!salaryProfile) {
|
||||
|
|
@ -285,10 +286,10 @@ export class SalaryPeriodController extends Controller {
|
|||
}
|
||||
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if(salaryProfile.salaryOrg.salaryPeriod.period == "APR"){
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
|
|
@ -299,16 +300,17 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}else if(salaryProfile.salaryOrg.salaryPeriod.period == "OCT"){
|
||||
} else if (salaryProfile.salaryOrg.salaryPeriod.period == "OCT") {
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
||||
.where({
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select("SUM(salaryProfile.amountUse)", "totalAmount")
|
||||
.where({
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: 'FULL',
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
type: "FULL",
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount =
|
||||
salaryProfile?.salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryProfile.salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
|
|
@ -334,7 +336,6 @@ export class SalaryPeriodController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการขอเงินเดือนผู้ใช้งานนี้ในระบบ");
|
||||
}
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
relations: ["salaryPeriod"],
|
||||
where: { id: body.groupId },
|
||||
});
|
||||
if (!salaryOrg) {
|
||||
|
|
@ -343,34 +344,33 @@ export class SalaryPeriodController extends Controller {
|
|||
|
||||
salaryProfile.salaryOrgId = salaryOrg.id;
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
if (salaryOrg) {
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if(salaryOrg.salaryPeriod.period == "APR"){
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryOrg.quantityUsed = amountFullType;
|
||||
salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}else if(salaryOrg.salaryPeriod.period == "OCT"){
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryOrg.quantityUsed = amountFullType;
|
||||
salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
} else if (salaryOrg.salaryPeriod.period == "OCT") {
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
||||
.select("SUM(salaryProfile.amountUse)", "totalAmount")
|
||||
.where({
|
||||
salaryOrgId: salaryOrg.id,
|
||||
type: 'FULL',
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}
|
||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}
|
||||
}
|
||||
return new HttpSuccess();
|
||||
|
|
@ -509,7 +509,7 @@ export class SalaryPeriodController extends Controller {
|
|||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(body.type != null && body.type != "" ? `profile.type LIKE :type` : "1=1", {
|
||||
type: body.type == null ? "" : `%${body.type.toUpperCase()}%`,
|
||||
type: body.type == null ? "" : `${body.type.toUpperCase()}`,
|
||||
})
|
||||
.andWhere(body.isRetire != null ? `profile.isRetired = ${body.isRetire}` : "1=1")
|
||||
.andWhere({
|
||||
|
|
@ -563,7 +563,6 @@ export class SalaryPeriodController extends Controller {
|
|||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
relations:["salaryPeriod"],
|
||||
where: {
|
||||
id: requestBody.id,
|
||||
},
|
||||
|
|
@ -593,7 +592,7 @@ export class SalaryPeriodController extends Controller {
|
|||
if (salaryProfileAll != null) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"ไม่สามารถเพิ่มรายชื่อนี้ได้ เนื่องจากมีการยื่นขอเลื่อนเงินเดือนแล้ว",
|
||||
"ไม่สามารถเพิ่มรายชื่อนี้ได้ เนื่องจากมีการยื่นของเลื่อนเงินเดือนแล้ว",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -693,7 +692,7 @@ export class SalaryPeriodController extends Controller {
|
|||
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryOrg.snapshot == "SNAP1") {
|
||||
if(salaryOrg.salaryPeriod.period == "APR"){
|
||||
if (salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryOrg.id,
|
||||
|
|
@ -704,15 +703,15 @@ export class SalaryPeriodController extends Controller {
|
|||
salaryOrg.quantityUsed = amountFullType;
|
||||
salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryOrg);
|
||||
}else if(salaryOrg.salaryPeriod.period == "OCT"){
|
||||
} else if (salaryOrg.salaryPeriod.period == "OCT") {
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select('SUM(salaryProfile.amountUse)', 'totalAmount')
|
||||
.where({
|
||||
salaryOrgId: salaryOrg.id,
|
||||
type: 'FULL',
|
||||
})
|
||||
.getRawOne();
|
||||
.createQueryBuilder("salaryProfile")
|
||||
.select("SUM(salaryProfile.amountUse)", "totalAmount")
|
||||
.where({
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
})
|
||||
.getRawOne();
|
||||
const calRemainAmount = salaryOrg.sixPercentAmount - sumAmountUse.totalAmount;
|
||||
salaryOrg.useAmount = sumAmountUse.totalAmount;
|
||||
salaryOrg.remainingAmount = calRemainAmount;
|
||||
|
|
@ -751,7 +750,7 @@ export class SalaryPeriodController extends Controller {
|
|||
if (chk_period) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ประเภทผังปี " + Extension.ToThaiYear(salaryPeriod.year) + " ซ้ำ",
|
||||
"ประเภทผังปี " + salaryPeriod.effectiveDate.getFullYear() + " ซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -799,7 +798,7 @@ export class SalaryPeriodController extends Controller {
|
|||
if (chk_period) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ประเภทผังปี " + Extension.ToThaiYear(requestBody.year) + " ซ้ำ",
|
||||
"ประเภทผังปี " + (requestBody.effectiveDate.getFullYear() + 543) + " ซ้ำ",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -880,10 +879,9 @@ export class SalaryPeriodController extends Controller {
|
|||
) {
|
||||
const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod)
|
||||
.createQueryBuilder("salaryPeriod")
|
||||
.andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `%${year}%` })
|
||||
.orWhere("salaryPeriod.period LIKE :keyword", { keyword: `%${keyword}%` })
|
||||
.orWhere("salaryPeriod.isActive LIKE :keyword", { keyword: `%${keyword}%` })
|
||||
.orWhere("salaryPeriod.year LIKE :keyword", { keyword: `%${year}%` })
|
||||
.andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` })
|
||||
.orWhere("salaryPeriod.period LIKE :keyword", { keyword: `${keyword}` })
|
||||
// .orWhere("salaryPeriod.isActive LIKE :keyword", { keyword: `${keyword}` })
|
||||
.select([
|
||||
"salaryPeriod.id",
|
||||
"salaryPeriod.period",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue