อนุมัติเงินเดือน
This commit is contained in:
parent
c680dcd6a8
commit
c22dd4ecf2
3 changed files with 192 additions and 9 deletions
|
|
@ -134,6 +134,7 @@ export class SalaryPeriodController extends Controller {
|
||||||
remainingAmount: salaryOrg.remainingAmount,
|
remainingAmount: salaryOrg.remainingAmount,
|
||||||
totalAmountSpecial: sum,
|
totalAmountSpecial: sum,
|
||||||
totalBackup: salaryOrg.salaryProfiles.filter((x) => x.isReserve == true).length,
|
totalBackup: salaryOrg.salaryProfiles.filter((x) => x.isReserve == true).length,
|
||||||
|
status: salaryOrg.status,
|
||||||
};
|
};
|
||||||
return new HttpSuccess(data);
|
return new HttpSuccess(data);
|
||||||
}
|
}
|
||||||
|
|
@ -1319,17 +1320,55 @@ export class SalaryPeriodController extends Controller {
|
||||||
const SalaryPeriod = await this.salaryPeriodRepository.findOne({
|
const SalaryPeriod = await this.salaryPeriodRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
if (!SalaryPeriod) {
|
if (!SalaryPeriod)
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
|
|
||||||
|
if (SalaryPeriod?.period == "SPECIAL") {
|
||||||
|
const SalaryOrg = await this.salaryOrgRepository.find({
|
||||||
|
where: { salaryPeriodId: SalaryPeriod.id },
|
||||||
|
relations: ["salaryProfiles"],
|
||||||
|
});
|
||||||
|
const salaryProfile = SalaryOrg.find((x) => x.salaryProfiles.length > 0);
|
||||||
|
if (salaryProfile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้");
|
||||||
|
|
||||||
|
await this.salaryOrgRepository.remove(SalaryOrg);
|
||||||
|
await this.salaryPeriodRepository.remove(SalaryPeriod);
|
||||||
|
return new HttpSuccess();
|
||||||
|
} else {
|
||||||
|
const SalaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { salaryPeriodId: SalaryPeriod.id },
|
||||||
|
});
|
||||||
|
if (SalaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้");
|
||||||
|
|
||||||
|
await this.salaryPeriodRepository.remove(SalaryPeriod);
|
||||||
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
const SalaryOrg = await this.salaryOrgRepository.findOne({
|
}
|
||||||
where: { salaryPeriodId: SalaryPeriod.id },
|
|
||||||
});
|
/**
|
||||||
if (SalaryOrg) {
|
* API รายการรอบเงินเดือน(active)
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้");
|
*
|
||||||
}
|
*
|
||||||
await this.salaryPeriodRepository.remove(SalaryPeriod);
|
*/
|
||||||
return new HttpSuccess();
|
@Get("active")
|
||||||
|
async GetListsSalaryPeriodActive() {
|
||||||
|
const salaryPeriod = await AppDataSource.getRepository(SalaryPeriod)
|
||||||
|
.createQueryBuilder("salaryPeriod")
|
||||||
|
.where({ isActive: true })
|
||||||
|
.select([
|
||||||
|
"salaryPeriod.id",
|
||||||
|
"salaryPeriod.period",
|
||||||
|
"salaryPeriod.isActive",
|
||||||
|
"salaryPeriod.isClose",
|
||||||
|
"salaryPeriod.effectiveDate",
|
||||||
|
"salaryPeriod.status",
|
||||||
|
"salaryPeriod.year",
|
||||||
|
"salaryPeriod.revisionId",
|
||||||
|
])
|
||||||
|
.orderBy("salaryPeriod.effectiveDate", "DESC")
|
||||||
|
.getMany();
|
||||||
|
|
||||||
|
return new HttpSuccess(salaryPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1922,4 +1961,118 @@ export class SalaryPeriodController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API เจ้าหน้าที่ส่ง ผอ
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
*/
|
||||||
|
@Get("officer/approve/{orgId}")
|
||||||
|
async OfficerApprove(@Path() orgId: string) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { id: orgId },
|
||||||
|
});
|
||||||
|
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
|
if (salaryOrg.status != "PENDING")
|
||||||
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
||||||
|
|
||||||
|
salaryOrg.status = "WAITHEAD1";
|
||||||
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ผอ ส่ง สกจ
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
*/
|
||||||
|
@Get("head/approve/{orgId}")
|
||||||
|
async HeadApprove(@Path() orgId: string) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { id: orgId },
|
||||||
|
});
|
||||||
|
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
|
if (salaryOrg.status != "WAITHEAD1")
|
||||||
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
||||||
|
|
||||||
|
salaryOrg.status = "WAITOWNER1";
|
||||||
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API สกจ อนุมัติ
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
*/
|
||||||
|
@Get("owner/approve/{orgId}")
|
||||||
|
async OwnerApprove(@Path() orgId: string) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { id: orgId },
|
||||||
|
});
|
||||||
|
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
|
if (salaryOrg.status != "WAITOWNER1")
|
||||||
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
||||||
|
|
||||||
|
salaryOrg.status = "REPORT";
|
||||||
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API สกจ ส่ง ผอ
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
*/
|
||||||
|
@Put("owner/comment/{orgId}")
|
||||||
|
async WaitOwnerApprove(
|
||||||
|
@Path() orgId: string,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
titleRecommend: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { id: orgId },
|
||||||
|
});
|
||||||
|
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
|
if (salaryOrg.status != "WAITOWNER1")
|
||||||
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
||||||
|
|
||||||
|
salaryOrg.status = "WAITHEAD2";
|
||||||
|
salaryOrg.ownerRecommend = body.titleRecommend;
|
||||||
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ผอ ส่ง เจ้าหน้าที่
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param {string} orgId Guid, *Id รอบเงินเดือน
|
||||||
|
*/
|
||||||
|
@Put("head/comment/{orgId}")
|
||||||
|
async WaitHeadApprove(
|
||||||
|
@Path() orgId: string,
|
||||||
|
@Body()
|
||||||
|
body: {
|
||||||
|
titleRecommend: string;
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
const salaryOrg = await this.salaryOrgRepository.findOne({
|
||||||
|
where: { id: orgId },
|
||||||
|
});
|
||||||
|
if (!salaryOrg) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลรอบผังเงินเดือนนี้");
|
||||||
|
if (salaryOrg.status != "WAITOFFICER2")
|
||||||
|
throw new HttpError(HttpStatusCode.INTERNAL_SERVER_ERROR, "ยังไม่ไม่สามารถอนุมัติได้");
|
||||||
|
|
||||||
|
salaryOrg.status = "REPORT";
|
||||||
|
salaryOrg.headRecommend = body.titleRecommend;
|
||||||
|
await this.salaryOrgRepository.save(salaryOrg);
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,20 @@ export class SalaryOrg extends EntityBase {
|
||||||
})
|
})
|
||||||
remainingAmount: number;
|
remainingAmount: number;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "คำแนะนำ สกจ",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
ownerRecommend: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "คำแนะนำ ผอ",
|
||||||
|
length: 255,
|
||||||
|
})
|
||||||
|
headRecommend: string;
|
||||||
|
|
||||||
@ManyToOne(() => SalaryPeriod, (salaryPeriod) => salaryPeriod.salaryOrgs)
|
@ManyToOne(() => SalaryPeriod, (salaryPeriod) => salaryPeriod.salaryOrgs)
|
||||||
@JoinColumn({ name: "salaryPeriodId" })
|
@JoinColumn({ name: "salaryPeriodId" })
|
||||||
salaryPeriod: SalaryPeriod;
|
salaryPeriod: SalaryPeriod;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableSalaryOrgAddRecommend1710426604127 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableSalaryOrgAddRecommend1710426604127'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` ADD \`ownerRecommend\` varchar(255) NULL COMMENT 'คำแนะนำ สกจ'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` ADD \`headRecommend\` varchar(255) NULL COMMENT 'คำแนะนำ ผอ'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` DROP COLUMN \`headRecommend\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`salaryOrg\` DROP COLUMN \`ownerRecommend\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue