fix commandCode
This commit is contained in:
parent
0732071da0
commit
d9799e642f
1 changed files with 81 additions and 35 deletions
|
|
@ -24,7 +24,7 @@ import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
|
|||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { In, LessThan, MoreThan } from "typeorm";
|
||||
import { In, LessThan, IsNull, MoreThan } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { Command } from "../entities/Command";
|
||||
|
|
@ -47,7 +47,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
where: { profileEmployeeId: profile.id, commandCode: In(["5", "6", "7"]) },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -60,7 +60,28 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profile.id },
|
||||
where: [
|
||||
{
|
||||
profileEmployeeId: profile.id,
|
||||
commandCode: In([
|
||||
"0",
|
||||
"9",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"8",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
"16",
|
||||
]),
|
||||
},
|
||||
{ profileEmployeeId: profile.id, commandCode: IsNull() },
|
||||
],
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -87,7 +108,28 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
where: [
|
||||
{
|
||||
profileEmployeeId: profileId,
|
||||
commandCode: In([
|
||||
"0",
|
||||
"9",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"8",
|
||||
"10",
|
||||
"11",
|
||||
"12",
|
||||
"13",
|
||||
"14",
|
||||
"15",
|
||||
"16",
|
||||
]),
|
||||
},
|
||||
{ profileEmployeeId: profileId, commandCode: IsNull() },
|
||||
],
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -131,7 +173,9 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [profile.id]);
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [
|
||||
profile.id,
|
||||
]);
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const mapPosLevel =
|
||||
_posLevel.length > 1
|
||||
|
|
@ -204,7 +248,9 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [profileId]);
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [
|
||||
profileId,
|
||||
]);
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const mapPosLevel =
|
||||
_posLevel.length > 1
|
||||
|
|
@ -248,7 +294,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
let _workflow = await new permission().Workflow(req, profileId, "SYS_WAGE");
|
||||
if (_workflow == false) await new permission().PermissionGet(req, "SYS_WAGE");
|
||||
const record = await this.salaryRepo.find({
|
||||
where: { profileEmployeeId: profileId },
|
||||
where: { profileEmployeeId: profileId, commandCode: In(["5", "6", "7"]) },
|
||||
order: { order: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -318,9 +364,9 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
lastUpdatedAt: new Date(),
|
||||
};
|
||||
if (body.commandCode && !body.commandName) {
|
||||
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
|
||||
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
|
||||
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
|
||||
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ";
|
||||
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||
}
|
||||
Object.assign(data, { ...body, ...meta });
|
||||
const history = new ProfileSalaryHistory();
|
||||
|
|
@ -359,10 +405,10 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
order: { order: "DESC" },
|
||||
});
|
||||
const before = null;
|
||||
let _posNumCodeSit: string = ""
|
||||
let _posNumCodeSitAbb: string = ""
|
||||
let _posNumCodeSit: string = "";
|
||||
let _posNumCodeSitAbb: string = "";
|
||||
const _command = await this.commandRepository.findOne({
|
||||
where: { id: body.commandId ?? "" }
|
||||
where: { id: body.commandId ?? "" },
|
||||
});
|
||||
if (_command) {
|
||||
if (_command?.isBangkok?.toLocaleUpperCase() == "OFFICE") {
|
||||
|
|
@ -371,35 +417,35 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
isDeputy: true,
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false
|
||||
}
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
},
|
||||
relations: ["orgRevision"]
|
||||
})
|
||||
relations: ["orgRevision"],
|
||||
});
|
||||
_posNumCodeSit = orgRootDeputy ? orgRootDeputy?.orgRootName : "สำนักปลัดกรุงเทพมหานคร";
|
||||
_posNumCodeSitAbb = orgRootDeputy ? orgRootDeputy?.orgRootShortName : "สนป.";
|
||||
}
|
||||
else if (_command?.isBangkok?.toLocaleUpperCase() == "BANGKOK") {
|
||||
_posNumCodeSit = "กรุงเทพมหานคร"
|
||||
_posNumCodeSitAbb = "กทม."
|
||||
}
|
||||
else {
|
||||
} else if (_command?.isBangkok?.toLocaleUpperCase() == "BANGKOK") {
|
||||
_posNumCodeSit = "กรุงเทพมหานคร";
|
||||
_posNumCodeSitAbb = "กทม.";
|
||||
} else {
|
||||
let _profileAdmin = await this.profileGovementRepo.findOne({
|
||||
where: {
|
||||
where: {
|
||||
keycloak: _command?.createdUserId.toString(),
|
||||
current_holders: {
|
||||
orgRevision: {
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false
|
||||
}
|
||||
}
|
||||
orgRevisionIsDraft: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
relations: ["current_holders", "current_holders.orgRevision", "current_holders.orgRoot"]
|
||||
relations: ["current_holders", "current_holders.orgRevision", "current_holders.orgRoot"],
|
||||
});
|
||||
_posNumCodeSit = _profileAdmin?.current_holders
|
||||
.find(x => x.orgRoot.orgRootName)?.orgRoot.orgRootName ?? ""
|
||||
_posNumCodeSitAbb = _profileAdmin?.current_holders
|
||||
.find(x => x.orgRoot.orgRootShortName)?.orgRoot.orgRootShortName ?? ""
|
||||
_posNumCodeSit =
|
||||
_profileAdmin?.current_holders.find((x) => x.orgRoot.orgRootName)?.orgRoot.orgRootName ??
|
||||
"";
|
||||
_posNumCodeSitAbb =
|
||||
_profileAdmin?.current_holders.find((x) => x.orgRoot.orgRootShortName)?.orgRoot
|
||||
.orgRootShortName ?? "";
|
||||
}
|
||||
}
|
||||
const data = new ProfileSalary();
|
||||
|
|
@ -451,9 +497,9 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
const before = structuredClone(record);
|
||||
const history = new ProfileSalaryHistory();
|
||||
if (body.commandCode && !body.commandName) {
|
||||
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ"
|
||||
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ"
|
||||
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ"
|
||||
if (body.commandCode == "7") body.commandName = "เงินพิเศษอื่น ๆ";
|
||||
else if (body.commandCode == "6") body.commandName = "เลื่อนเงินเดือนกรณีอื่น ๆ";
|
||||
else if (body.commandCode == "5") body.commandName = "เลื่อนเงินเดือนตามปกติ";
|
||||
}
|
||||
Object.assign(record, body);
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue