fix SalaryEmployee ลบไฟล์ รวมไฟล์ เพิ่ม field

This commit is contained in:
AnandaTon 2024-05-16 15:03:29 +07:00
parent 42bad7b302
commit 3b5096c005
7 changed files with 55 additions and 920 deletions

View file

@ -277,7 +277,7 @@ export class OrganizationUnauthorizeController extends Controller {
.leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("employeePosMaster.positions", "positions")
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
.leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys")
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
.leftJoinAndSelect("current_holder.posType", "posType")
@ -370,9 +370,9 @@ export class OrganizationUnauthorizeController extends Controller {
}
const amount =
item.current_holder == null || item.current_holder.profileSalary.length == 0
item.current_holder == null || item.current_holder.profileSalarys.length == 0
? null
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
: item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);

View file

@ -73,9 +73,12 @@ export class ProfileEmployeeController extends Controller {
if (body.posTypeId && !(await this.posTypeRepo.findOneBy({ id: body.posTypeId }))) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
}
if (body.citizenId.length !== 13) {
throw new HttpError(HttpStatus.NOT_FOUND, "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก");
throw new HttpError(
HttpStatus.NOT_FOUND,
"กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก",
);
}
if (body.citizenId) {
@ -95,16 +98,16 @@ export class ProfileEmployeeController extends Controller {
citizenIdDigits[11] * 2;
const calStp2 = cal % 11;
let chkDigit = 11 - calStp2;
if(chkDigit === 10){
if (chkDigit === 10) {
chkDigit = 1;
}else if(chkDigit === 11){
} else if (chkDigit === 11) {
chkDigit = chkDigit % 10;
}
// else if(chkDigit === 11){
// chkDigit = cal % 10;
// }
if(citizenIdDigits[12] !== chkDigit){
if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
}
}
@ -155,7 +158,10 @@ export class ProfileEmployeeController extends Controller {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลประเภทตำแหน่งนี้");
}
if (body.citizenId && body.citizenId.length !== 13) {
throw new HttpError(HttpStatus.NOT_FOUND, "กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก");
throw new HttpError(
HttpStatus.NOT_FOUND,
"กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชนให้ครบ 13 หลัก",
);
}
if (body.citizenId) {
@ -175,16 +181,16 @@ export class ProfileEmployeeController extends Controller {
citizenIdDigits[11] * 2;
const calStp2 = cal % 11;
let chkDigit = 11 - calStp2;
if(chkDigit === 10){
if (chkDigit === 10) {
chkDigit = 1;
}else if(chkDigit === 11){
} else if (chkDigit === 11) {
chkDigit = chkDigit % 10;
}
// else if(chkDigit === 11){
// chkDigit = cal % 10;
// }
if(citizenIdDigits[12] !== chkDigit){
if (citizenIdDigits[12] !== chkDigit) {
throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
}
}
@ -1047,7 +1053,7 @@ export class ProfileEmployeeController extends Controller {
.leftJoinAndSelect("employeePosMaster.orgChild3", "orgChild3")
.leftJoinAndSelect("employeePosMaster.orgChild4", "orgChild4")
.leftJoinAndSelect("employeePosMaster.positions", "positions")
.leftJoinAndSelect("current_holder.profileSalary", "profileSalary")
.leftJoinAndSelect("current_holder.profileSalarys", "profileSalarys")
.leftJoinAndSelect("current_holder.profileDisciplines", "profileDisciplines")
.leftJoinAndSelect("current_holder.posLevel", "posLevel")
.leftJoinAndSelect("current_holder.posType", "posType")
@ -1145,9 +1151,9 @@ export class ProfileEmployeeController extends Controller {
}
const amount =
item.current_holder == null || item.current_holder.profileSalary.length == 0
item.current_holder == null || item.current_holder.profileSalarys.length == 0
? null
: item.current_holder.profileSalary.sort((a: any, b: any) => b.date - a.date)[0].amount;
: item.current_holder.profileSalarys.sort((a: any, b: any) => b.date - a.date)[0].amount;
let datePeriodStart = new Date(
`${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, "0")}-${String(new Date().getDate() + 1).padStart(2, "0")}T00:00:00.000Z`,
);

View file

@ -15,9 +15,9 @@ import {
import { AppDataSource } from "../database/data-source";
import {
CreateProfileSalaryEmployee,
ProfileSalaryEmployee,
ProfileSalary,
UpdateProfileSalaryEmployee,
} from "../entities/ProfileSalaryEmployee";
} from "../entities/ProfileSalary";
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
@ -31,13 +31,13 @@ import { LessThan, MoreThan } from "typeorm";
@Security("bearerAuth")
export class ProfileSalaryEmployeeController extends Controller {
private profileRepo = AppDataSource.getRepository(ProfileEmployee);
private salaryRepo = AppDataSource.getRepository(ProfileSalaryEmployee);
private salaryRepo = AppDataSource.getRepository(ProfileSalary);
private salaryHistoryRepo = AppDataSource.getRepository(ProfileSalaryHistory);
@Get("{profileId}")
public async getSalary(@Path() profileId: string) {
const record = await this.salaryRepo.find({
where: { profileId: profileId },
where: { profileEmployeeId: profileId },
order: { order: "ASC" },
});
return new HttpSuccess(record);
@ -56,22 +56,22 @@ export class ProfileSalaryEmployeeController extends Controller {
@Request() req: RequestWithUser,
@Body() body: CreateProfileSalaryEmployee,
) {
if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
const profile = await this.profileRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const dest_item = await this.salaryRepo.findOne({
where: { profileId: body.profileId },
where: { profileId: body.profileEmployeeId },
order: { order: "DESC" },
});
const data = new ProfileSalaryEmployee();
const data = new ProfileSalary();
const meta = {
order: dest_item == null ? 1 : dest_item.order + 1,