Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-02-29 14:53:34 +07:00
commit 43a8c8c8f0
3 changed files with 44 additions and 20 deletions

View file

@ -433,7 +433,7 @@ export class SalaryPeriodController extends Controller {
if (body.type == "NONE") {
salaryProfile.amountSpecial = 0;
salaryProfile.amountUse = 0;
salaryProfile.positionSalaryAmount = salaryProfile.amount;
salaryProfile.positionSalaryAmount = salaryProfile.amount == null ? 0 : salaryProfile.amount;
} else if (body.type == "PENDING") {
salaryProfile.amountSpecial = 0;
salaryProfile.amountUse = 0;
@ -485,7 +485,14 @@ export class SalaryPeriodController extends Controller {
@Put("org/{id}")
async GetListsSalaryProfile(
@Path() id: string,
@Body() body: { page: number; pageSize: number; keyword?: string; type: string },
@Body()
body: {
page: number;
pageSize: number;
keyword?: string;
type?: any;
isRetire?: boolean | null;
},
) {
const salaryOrg = await this.salaryOrgRepository.findOne({
where: {
@ -497,11 +504,12 @@ export class SalaryPeriodController extends Controller {
}
const [salaryProfile, total] = await AppDataSource.getRepository(SalaryProfile)
.createQueryBuilder("profile")
.orWhere(
.andWhere(
new Brackets((qb) => {
qb.andWhere(body.type != null && body.type != "" ? "profile.type LIKE :type" : "1=1", {
type: `%${body.type.toUpperCase()}%`,
qb.andWhere(body.type != null && body.type != "" ? `profile.type LIKE :type` : "1=1", {
type: body.type == null ? "" : `%${body.type.toUpperCase()}%`,
})
.andWhere(body.isRetire != null ? `profile.isRetired = ${body.isRetire}` : "1=1")
.andWhere({
salaryOrgId: salaryOrg.id,
})
@ -564,6 +572,7 @@ export class SalaryPeriodController extends Controller {
const salaryOrgAll = await this.salaryOrgRepository.find({
where: {
salaryPeriodId: salaryOrg.salaryPeriodId,
snapshot: salaryOrg.snapshot,
},
});
if (!salaryOrgAll) {

View file

@ -111,31 +111,28 @@ export class SalaryProfile extends EntityBase {
comment: "เงินเดือนฐาน",
default: null,
})
amount: number;
amount: number | null;
@Column({
nullable: true,
type: "double",
comment: "เงินพิเศษ",
default: null,
default: 0,
})
amountSpecial: number;
@Column({
nullable: true,
type: "double",
comment: "จำนวนเงินที่ใช้เลื่อน",
default: null,
default: 0,
})
amountUse: number | null;
amountUse: number;
@Column({
nullable: true,
type: "double",
comment: "เงินเดือนหลังเลื่อน",
default: null,
default: 0,
})
positionSalaryAmount: number | null;
positionSalaryAmount: number;
@Column({
comment:
@ -325,7 +322,7 @@ export class CreateSalaryProfile {
posExecutive: string | null;
@Column()
amount: number;
amount: number | null;
@Column("uuid")
rootId: string | null;
@ -358,19 +355,19 @@ export class CreateSalaryProfile {
child4: string | null;
@Column()
result: string;
result: string | null;
@Column()
duration: string;
duration: string | null;
@Column()
punish: string;
punish: string | null;
@Column()
retired: string;
retired: string | null;
@Column()
retired2: string;
retired2: string | null;
@Column()
isRetired: boolean;

View file

@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableSalaryProfileAddIsretired11709189881087 implements MigrationInterface {
name = 'UpdateTableSalaryProfileAddIsretired11709189881087'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountSpecial\` \`amountSpecial\` double NOT NULL COMMENT 'เงินพิเศษ' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountUse\` \`amountUse\` double NOT NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน' DEFAULT '0'`);
await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`positionSalaryAmount\` \`positionSalaryAmount\` double NOT NULL COMMENT 'เงินเดือนหลังเลื่อน' DEFAULT '0'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`positionSalaryAmount\` \`positionSalaryAmount\` double NULL COMMENT 'เงินเดือนหลังเลื่อน'`);
await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountUse\` \`amountUse\` double NULL COMMENT 'จำนวนเงินที่ใช้เลื่อน'`);
await queryRunner.query(`ALTER TABLE \`salaryProfile\` CHANGE \`amountSpecial\` \`amountSpecial\` double NULL COMMENT 'เงินพิเศษ'`);
}
}