เพิ่มฟิวคุณสมบัติบุคคล
This commit is contained in:
parent
aff5aa452e
commit
33a5cf2a57
2 changed files with 106 additions and 44 deletions
|
|
@ -133,6 +133,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
useAmount: salaryOrg.useAmount,
|
useAmount: salaryOrg.useAmount,
|
||||||
remainingAmount: salaryOrg.remainingAmount,
|
remainingAmount: salaryOrg.remainingAmount,
|
||||||
totalAmountSpecial: sum,
|
totalAmountSpecial: sum,
|
||||||
|
totalBackup: salaryOrg.salaryProfiles.filter((x) => x.isReserve == true).length,
|
||||||
};
|
};
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
@ -308,16 +309,18 @@ 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({
|
if (salaryProfile.isReserve == false) {
|
||||||
where: {
|
const amountFullType = await this.salaryProfileRepository.count({
|
||||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
where: {
|
||||||
type: "FULL",
|
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||||
},
|
type: "FULL",
|
||||||
});
|
},
|
||||||
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
});
|
||||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
||||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
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)
|
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||||
.createQueryBuilder("salaryProfile")
|
.createQueryBuilder("salaryProfile")
|
||||||
|
|
@ -370,16 +373,18 @@ 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({
|
if (salaryProfile.isReserve == false) {
|
||||||
where: {
|
const amountFullType = await this.salaryProfileRepository.count({
|
||||||
salaryOrgId: salaryOrg.id,
|
where: {
|
||||||
type: "FULL",
|
salaryOrgId: salaryOrg.id,
|
||||||
},
|
type: "FULL",
|
||||||
});
|
},
|
||||||
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
});
|
||||||
salaryOrg.quantityUsed = amountFullType;
|
const calRemainQuota = salaryOrg.fifteenPercent - amountFullType;
|
||||||
salaryOrg.remainQuota = calRemainQuota;
|
salaryOrg.quantityUsed = amountFullType;
|
||||||
await this.salaryOrgRepository.save(salaryOrg);
|
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)
|
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||||
.createQueryBuilder("salaryProfile")
|
.createQueryBuilder("salaryProfile")
|
||||||
|
|
@ -409,7 +414,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
* @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น
|
* @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น
|
||||||
*/
|
*/
|
||||||
@Post("change/type")
|
@Post("change/type")
|
||||||
async changeType(@Body() body: { profileId: string; type: string }) {
|
async changeType(@Body() body: { profileId: string; type: string; isReserve: boolean }) {
|
||||||
const salaryProfile = await this.salaryProfileRepository.findOne({
|
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||||
where: { id: body.profileId },
|
where: { id: body.profileId },
|
||||||
|
|
@ -538,22 +543,25 @@ export class SalaryPeriodController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||||
}
|
}
|
||||||
salaryProfile.type = body.type;
|
salaryProfile.type = body.type;
|
||||||
|
salaryProfile.isReserve = body.isReserve;
|
||||||
await this.salaryProfileRepository.save(salaryProfile);
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
|
||||||
if (salaryProfile.salaryOrg) {
|
if (salaryProfile.salaryOrg) {
|
||||||
// หาจำนวน 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({
|
if (body.isReserve == false) {
|
||||||
where: {
|
const amountFullType = await this.salaryProfileRepository.count({
|
||||||
salaryOrgId: salaryProfile.salaryOrg.id,
|
where: {
|
||||||
type: "FULL",
|
salaryOrgId: salaryProfile.salaryOrg.id,
|
||||||
},
|
type: "FULL",
|
||||||
});
|
},
|
||||||
const calRemainQuota = salaryProfile.salaryOrg.fifteenPercent - amountFullType;
|
});
|
||||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
const calRemainQuota = salaryProfile.salaryOrg.fifteenPercent - amountFullType;
|
||||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||||
await this.salaryOrgRepository.save(salaryProfile.salaryOrg);
|
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)
|
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||||
.createQueryBuilder("salaryProfile")
|
.createQueryBuilder("salaryProfile")
|
||||||
|
|
@ -649,6 +657,43 @@ export class SalaryPeriodController extends Controller {
|
||||||
return new HttpSuccess({ data: salaryProfile, total });
|
return new HttpSuccess({ data: salaryProfile, total });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API แก้คุณสมบัติ
|
||||||
|
*
|
||||||
|
* @summary SLR_031 - แก้คุณสมบัติ #30
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Put("org/property/{id}")
|
||||||
|
async editProperty(
|
||||||
|
@Path() id: string,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
isPunish: boolean;
|
||||||
|
isSuspension: boolean;
|
||||||
|
isAbsent: boolean;
|
||||||
|
isLeave: boolean;
|
||||||
|
},
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
const salaryProfile = await this.salaryProfileRepository.findOne({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!salaryProfile) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการเพิ่มเงินเดือนของบุคคลนี้");
|
||||||
|
}
|
||||||
|
salaryProfile.isPunish = body.isPunish;
|
||||||
|
salaryProfile.isSuspension = body.isSuspension;
|
||||||
|
salaryProfile.isAbsent = body.isAbsent;
|
||||||
|
salaryProfile.isLeave = body.isLeave;
|
||||||
|
salaryProfile.lastUpdateUserId = request.user.sub;
|
||||||
|
salaryProfile.lastUpdateFullName = request.user.name;
|
||||||
|
salaryProfile.lastUpdatedAt = new Date();
|
||||||
|
await this.salaryProfileRepository.save(salaryProfile);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มคนเลื่อนเงินเดือนตามรอบ
|
* API เพิ่มคนเลื่อนเงินเดือนตามรอบ
|
||||||
*
|
*
|
||||||
|
|
@ -661,7 +706,7 @@ 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"],
|
relations: ["salaryPeriod", "salaryProfiles"],
|
||||||
where: {
|
where: {
|
||||||
id: requestBody.id,
|
id: requestBody.id,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -233,38 +233,45 @@ export class SalaryProfile extends EntityBase {
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ผลการประเมิน",
|
comment: "ผลการประเมินผลการปฏิบัติราชการ",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
result: string;
|
result: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ระยะเวลา",
|
comment: "ระยะเวลาการปฏิบัติราชการในรอบครึ่งปี",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
duration: string;
|
duration: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "การลงโทษ",
|
comment: "การลงโทษทางวินัย",
|
||||||
default: null,
|
default: false,
|
||||||
})
|
})
|
||||||
punish: string;
|
isPunish: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "พักราชการ",
|
comment: "พักราชการ",
|
||||||
default: null,
|
default: false,
|
||||||
})
|
})
|
||||||
retired: string;
|
isSuspension: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ขาดราชการ",
|
comment: "ขาดราชการ",
|
||||||
default: null,
|
default: false,
|
||||||
})
|
})
|
||||||
retired2: string;
|
isAbsent: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "วันลา",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isLeave: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
@ -273,6 +280,13 @@ export class SalaryProfile extends EntityBase {
|
||||||
})
|
})
|
||||||
isRetired: boolean;
|
isRetired: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "สำรอง",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isReserve: boolean;
|
||||||
|
|
||||||
@ManyToOne(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryProfiles)
|
@ManyToOne(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryProfiles)
|
||||||
@JoinColumn({ name: "salaryOrgId" })
|
@JoinColumn({ name: "salaryOrgId" })
|
||||||
salaryOrg: SalaryOrg;
|
salaryOrg: SalaryOrg;
|
||||||
|
|
@ -361,13 +375,16 @@ export class CreateSalaryProfile {
|
||||||
duration: string | null;
|
duration: string | null;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
punish: string | null;
|
isPunish: boolean;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
retired: string | null;
|
isSuspension: boolean;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
retired2: string | null;
|
isAbsent: boolean;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
isLeave: boolean;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
isRetired: boolean;
|
isRetired: boolean;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue