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