เพิ่มฟิวคุณสมบัติบุคคล
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,
|
||||
remainingAmount: salaryOrg.remainingAmount,
|
||||
totalAmountSpecial: sum,
|
||||
totalBackup: salaryOrg.salaryProfiles.filter((x) => x.isReserve == true).length,
|
||||
};
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
|
|
@ -308,16 +309,18 @@ export class SalaryPeriodController extends Controller {
|
|||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
if (salaryProfile.isReserve == false) {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile?.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile?.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile?.salaryOrg);
|
||||
}
|
||||
} else if (salaryProfile.salaryOrg.salaryPeriod.period == "OCT") {
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
|
|
@ -370,16 +373,18 @@ export class SalaryPeriodController extends Controller {
|
|||
// หาจำนวน 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);
|
||||
if (salaryProfile.isReserve == false) {
|
||||
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")
|
||||
|
|
@ -409,7 +414,7 @@ export class SalaryPeriodController extends Controller {
|
|||
* @param {string} type ประเภทการเลื่อน NONE->ไม่ได้เลื่อน HAFT->ครึ่งขั้น FULL->1ขั้น FULLHAFT->1.5ขั้น
|
||||
*/
|
||||
@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({
|
||||
relations: ["salaryOrg", "salaryOrg.salaryPeriod"],
|
||||
where: { id: body.profileId },
|
||||
|
|
@ -538,22 +543,25 @@ export class SalaryPeriodController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทการเลื่อนขึ้นเงินเดือนไม่ถูกต้อง");
|
||||
}
|
||||
salaryProfile.type = body.type;
|
||||
salaryProfile.isReserve = body.isReserve;
|
||||
await this.salaryProfileRepository.save(salaryProfile);
|
||||
|
||||
if (salaryProfile.salaryOrg) {
|
||||
// หาจำนวน Quota คงเหลือ
|
||||
if (salaryProfile.salaryOrg.snapshot == "SNAP1") {
|
||||
if (salaryProfile.salaryOrg.salaryPeriod.period == "APR") {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile.salaryOrg);
|
||||
if (body.isReserve == false) {
|
||||
const amountFullType = await this.salaryProfileRepository.count({
|
||||
where: {
|
||||
salaryOrgId: salaryProfile.salaryOrg.id,
|
||||
type: "FULL",
|
||||
},
|
||||
});
|
||||
const calRemainQuota = salaryProfile.salaryOrg.fifteenPercent - amountFullType;
|
||||
salaryProfile.salaryOrg.quantityUsed = amountFullType;
|
||||
salaryProfile.salaryOrg.remainQuota = calRemainQuota;
|
||||
await this.salaryOrgRepository.save(salaryProfile.salaryOrg);
|
||||
}
|
||||
} else if (salaryProfile.salaryOrg.salaryPeriod.period == "OCT") {
|
||||
const sumAmountUse = await AppDataSource.getRepository(SalaryProfile)
|
||||
.createQueryBuilder("salaryProfile")
|
||||
|
|
@ -649,6 +657,43 @@ export class SalaryPeriodController extends Controller {
|
|||
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 เพิ่มคนเลื่อนเงินเดือนตามรอบ
|
||||
*
|
||||
|
|
@ -661,7 +706,7 @@ export class SalaryPeriodController extends Controller {
|
|||
@Request() request: { user: Record<string, any> },
|
||||
) {
|
||||
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||
relations: ["salaryPeriod"],
|
||||
relations: ["salaryPeriod", "salaryProfiles"],
|
||||
where: {
|
||||
id: requestBody.id,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -233,38 +233,45 @@ export class SalaryProfile extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ผลการประเมิน",
|
||||
comment: "ผลการประเมินผลการปฏิบัติราชการ",
|
||||
default: null,
|
||||
})
|
||||
result: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ระยะเวลา",
|
||||
comment: "ระยะเวลาการปฏิบัติราชการในรอบครึ่งปี",
|
||||
default: null,
|
||||
})
|
||||
duration: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "การลงโทษ",
|
||||
default: null,
|
||||
comment: "การลงโทษทางวินัย",
|
||||
default: false,
|
||||
})
|
||||
punish: string;
|
||||
isPunish: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "พักราชการ",
|
||||
default: null,
|
||||
default: false,
|
||||
})
|
||||
retired: string;
|
||||
isSuspension: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ขาดราชการ",
|
||||
default: null,
|
||||
default: false,
|
||||
})
|
||||
retired2: string;
|
||||
isAbsent: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "วันลา",
|
||||
default: false,
|
||||
})
|
||||
isLeave: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
|
|
@ -273,6 +280,13 @@ export class SalaryProfile extends EntityBase {
|
|||
})
|
||||
isRetired: boolean;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "สำรอง",
|
||||
default: false,
|
||||
})
|
||||
isReserve: boolean;
|
||||
|
||||
@ManyToOne(() => SalaryOrg, (salaryOrg) => salaryOrg.salaryProfiles)
|
||||
@JoinColumn({ name: "salaryOrgId" })
|
||||
salaryOrg: SalaryOrg;
|
||||
|
|
@ -361,13 +375,16 @@ export class CreateSalaryProfile {
|
|||
duration: string | null;
|
||||
|
||||
@Column()
|
||||
punish: string | null;
|
||||
isPunish: boolean;
|
||||
|
||||
@Column()
|
||||
retired: string | null;
|
||||
isSuspension: boolean;
|
||||
|
||||
@Column()
|
||||
retired2: string | null;
|
||||
isAbsent: boolean;
|
||||
|
||||
@Column()
|
||||
isLeave: boolean;
|
||||
|
||||
@Column()
|
||||
isRetired: boolean;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue