เพิ่มชื่อผัง

This commit is contained in:
Kittapath 2024-03-07 14:25:14 +07:00
parent 81f31d454e
commit aff5aa452e
4 changed files with 33 additions and 34 deletions

View file

@ -43,7 +43,7 @@ export class Salary extends Controller {
*/
@Post()
@Example({
salaryType: "string", //*ประเภทผัง (OFFICER->"ข้าราชการกรุงเทพมหานครสามัญ",EMPLOYEE->"ลูกจ้างประจำกรุงเทพมหานคร")
name: "string", //*ชื่อผัง
posTypeId: "string(Guid)", //*ระดับของตำแหน่ง
posLevelId: "string(Guid)", //*ประเภทของตำแหน่ง
isActive: "boolean", //*สถานะการใช้งาน
@ -62,11 +62,6 @@ export class Salary extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
}
const chk_salaryType = ["OFFICER", "EMPLOYEE"];
if (!chk_salaryType.includes(salarys.salaryType.toUpperCase())) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทผัง ไม่ถูกต้อง");
}
const chk_posTypeId = await this.poTypeRepository.findOne({
where: { id: salarys.posTypeId },
});
@ -83,7 +78,7 @@ export class Salary extends Controller {
const chk_3fields = await this.salaryRepository.findOne({
where: {
salaryType: salarys.salaryType,
name: salarys.name,
posTypeId: salarys.posTypeId,
posLevelId: salarys.posLevelId,
},
@ -91,7 +86,7 @@ export class Salary extends Controller {
if (chk_3fields && salarys.isActive) {
salarys.isActive = false;
}
salarys.salaryType = salarys.salaryType.toUpperCase();
salarys.name = salarys.name;
salarys.isSpecial = salarys.isSpecial;
salarys.createdUserId = request.user.sub;
salarys.createdFullName = request.user.name;
@ -113,7 +108,7 @@ export class Salary extends Controller {
*/
@Put("{id}")
@Example({
salaryType: "string", //*ประเภทผัง (OFFICER->"ข้าราชการกรุงเทพมหานครสามัญ",EMPLOYEE->"ลูกจ้างประจำกรุงเทพมหานคร")
name: "string", //*ชื่อผัง
posTypeId: "string(Guid)", //*ระดับของตำแหน่ง
posLevelId: "string(Guid)", //*ประเภทของตำแหน่ง
isActive: "boolean", //*สถานะการใช้งาน
@ -144,7 +139,7 @@ export class Salary extends Controller {
const chk_3fields = await this.salaryRepository.findOne({
where: {
salaryType: requestBody.salaryType,
name: requestBody.name,
posTypeId: requestBody.posTypeId,
posLevelId: requestBody.posLevelId,
isActive: true,
@ -160,11 +155,6 @@ export class Salary extends Controller {
await this.salaryRepository.save(chk_3fields);
}
const chk_salaryType = ["OFFICER", "EMPLOYEE"];
if (!chk_salaryType.includes(String(requestBody.salaryType).toUpperCase())) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ประเภทผัง ไม่ถูกต้อง");
}
const chk_posTypeId = await this.poTypeRepository.findOne({
where: { id: requestBody.posTypeId },
});
@ -233,7 +223,7 @@ export class Salary extends Controller {
*/
@Get("{id}")
@Example({
salaryType: "string", //*ประเภทผัง (OFFICER->"ข้าราชการกรุงเทพมหานครสามัญ",EMPLOYEE->"ลูกจ้างประจำกรุงเทพมหานคร")
name: "string", //*ชื่อผัง
posTypeId: "string(Guid)", //*ระดับของตำแหน่ง
posLevelId: "string(Guid)", //*ประเภทของตำแหน่ง
isActive: "boolean", //*สถานะการใช้งาน
@ -247,7 +237,7 @@ export class Salary extends Controller {
const salary = await this.salaryRepository.findOne({
where: { id: id },
select: [
"salaryType",
"name",
"isSpecial",
"posTypeId",
"posLevelId",
@ -289,7 +279,7 @@ export class Salary extends Controller {
if (keyword != undefined && keyword !== "") {
const filteredSalary = salary.filter(
(x) =>
x.salaryType?.toString().includes(keyword) ||
x.name?.toString().includes(keyword) ||
x.isSpecial?.toString().includes(keyword) || //new 20.02.67
x.posLevel_?.posLevelName?.toString().includes(keyword) ||
x.posType_?.posTypeName?.toString().includes(keyword) ||
@ -302,7 +292,7 @@ export class Salary extends Controller {
const formattedData = filteredSalary.map((item) => ({
id: item.id,
salaryType: item.salaryType,
name: item.name,
isSpecial: item.isSpecial,
posTypeId: item.posType_?.id,
posType: item.posType_?.posTypeName,
@ -320,7 +310,7 @@ export class Salary extends Controller {
const formattedData = salary.map((item) => ({
id: item.id,
salaryType: item.salaryType,
name: item.name,
isSpecial: item.isSpecial,
posTypeId: item.posType_?.id,
posType: item.posType_?.posTypeName,
@ -333,7 +323,6 @@ export class Salary extends Controller {
details: item.details,
}));
return new HttpSuccess({ data: formattedData, total });
}
/**

View file

@ -118,6 +118,9 @@ export class SalaryPeriodController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบรอบการขึ้นเงินเดือน");
}
const sum = salaryOrg.salaryProfiles.reduce((accumulator, object) => {
return accumulator + object.amountSpecial;
}, 0);
const data = {
total: salaryOrg.total,
fifteenPercent: salaryOrg.fifteenPercent,
@ -129,6 +132,7 @@ export class SalaryPeriodController extends Controller {
sixPercentSpentAmount: salaryOrg.sixPercentAmount - salaryOrg.spentAmount,
useAmount: salaryOrg.useAmount,
remainingAmount: salaryOrg.remainingAmount,
totalAmountSpecial: sum,
};
return new HttpSuccess(data);
}
@ -264,7 +268,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryHalf == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryHalf - salaryProfile.amount + salaryRanks.salaryHalfSpecial;
: salaryRanks.salaryHalf - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
} else if (salaryProfile.type == "FULL") {
@ -278,7 +282,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryFull == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryFull - salaryProfile.amount + salaryRanks.salaryFullSpecial;
: salaryRanks.salaryFull - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
} else if (salaryProfile.type == "FULLHAFT") {
@ -292,7 +296,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryFullHalf == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryFullHalf - salaryProfile.amount + salaryRanks.salaryFullHalfSpecial;
: salaryRanks.salaryFullHalf - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
} else {
@ -499,7 +503,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryHalf == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryHalf - salaryProfile.amount + salaryRanks.salaryHalfSpecial;
: salaryRanks.salaryHalf - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
} else if (body.type == "FULL") {
@ -513,7 +517,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryFull == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryFull - salaryProfile.amount + salaryRanks.salaryFullSpecial;
: salaryRanks.salaryFull - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
} else if (body.type == "FULLHAFT") {
@ -527,7 +531,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryFullHalf == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryFullHalf - salaryProfile.amount + salaryRanks.salaryFullHalfSpecial;
: salaryRanks.salaryFullHalf - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
} else {
@ -753,7 +757,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryHalf == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryHalf - salaryProfile.amount + salaryRanks.salaryHalfSpecial;
: salaryRanks.salaryHalf - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryHalf == null ? 0 : salaryRanks.salaryHalf;
} else if (salaryProfile.type == "FULL") {
@ -767,7 +771,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryFull == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryFull - salaryProfile.amount + salaryRanks.salaryFullSpecial;
: salaryRanks.salaryFull - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryFull == null ? 0 : salaryRanks.salaryFull;
} else if (salaryProfile.type == "FULLHAFT") {
@ -781,7 +785,7 @@ export class SalaryPeriodController extends Controller {
salaryRanks.salaryFullHalf == null ||
salaryProfile.amount == null
? 0
: salaryRanks.salaryFullHalf - salaryProfile.amount + salaryRanks.salaryFullHalfSpecial;
: salaryRanks.salaryFullHalf - salaryProfile.amount;
salaryProfile.positionSalaryAmount =
salaryRanks == null || salaryRanks.salaryFullHalf == null ? 0 : salaryRanks.salaryFullHalf;
} else {

View file

@ -16,6 +16,12 @@ export class SalaryPeriod extends EntityBase {
})
isActive: boolean;
@Column({
comment: "ปิดรอบ",
default: false,
})
isClose: boolean;
@Column({
nullable: true,
type: "datetime",

View file

@ -7,10 +7,10 @@ import { PosLevel } from "./PosLevel";
@Entity("salarys")
export class Salarys extends EntityBase {
@Column({
comment: "ประเภทผัง",
comment: "ชื่อผัง",
length: 255,
})
salaryType: string;
name: string;
@Column({
length: 40,
@ -81,7 +81,7 @@ export class Salarys extends EntityBase {
export class CreateSalary {
@Column()
salaryType: string;
name: string;
@Column("uuid")
posTypeId: string;
@ -110,7 +110,7 @@ export class CreateSalary {
export class UpdateSalary {
@Column()
salaryType: string;
name: string;
@Column("uuid")
posTypeId: string;