Fix [Bug] คำนวนระยะเวลาดำรงตำแหน่งในสายงาน, ระยะเวลาดำรงตำแหน่งตามระดับ และทางการบริหารของคนที่พ้นจากราชการ #137
This commit is contained in:
parent
ea74db7005
commit
42cc69cbbe
5 changed files with 131 additions and 22 deletions
|
|
@ -29,6 +29,8 @@ import permission from "../interfaces/permission";
|
|||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { Command } from "../entities/Command";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import Extension from "../interfaces/extension";
|
||||
|
||||
@Route("api/v1/org/profile-employee/salary")
|
||||
@Tags("ProfileSalary")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -141,8 +143,16 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [
|
||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||
let _currentDate = CURRENT_DATE[0].today;
|
||||
if (profile && profile?.isLeave) {
|
||||
_currentDate = profile && profile.leaveDate
|
||||
? Extension.toDateOnlyString(profile.leaveDate)
|
||||
: _currentDate
|
||||
}
|
||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||
profile.id,
|
||||
_currentDate
|
||||
]);
|
||||
const _position = position.length > 0 ? position[0] : [];
|
||||
const mapPosition =
|
||||
|
|
@ -173,8 +183,9 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
||||
profile.id,
|
||||
_currentDate
|
||||
]);
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const mapPosLevel =
|
||||
|
|
@ -216,8 +227,22 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
|
||||
@Get("tenure/{profileId}")
|
||||
public async getPositionTenure(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?)", [
|
||||
const _profile = await this.profileRepo.findOne({
|
||||
where: { id: profileId }
|
||||
})
|
||||
if (!_profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const CURRENT_DATE = await AppDataSource.query("SELECT CURRENT_DATE() as today");
|
||||
let _currentDate = CURRENT_DATE[0].today;
|
||||
if (_profile && _profile?.isLeave) {
|
||||
_currentDate = _profile && _profile.leaveDate
|
||||
? Extension.toDateOnlyString(_profile.leaveDate)
|
||||
: _currentDate
|
||||
}
|
||||
const position = await AppDataSource.query("CALL GetProfileEmployeeSalaryPosition(?, ?)", [
|
||||
profileId,
|
||||
_currentDate
|
||||
]);
|
||||
const _position = position.length > 0 ? position[0] : [];
|
||||
const mapPosition =
|
||||
|
|
@ -248,8 +273,9 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
[] as { name: string; days: number; year: number; month: number; day: number }[],
|
||||
);
|
||||
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?)", [
|
||||
const posLevel = await AppDataSource.query("CALL GetProfileEmployeeSalaryLevel(?, ?)", [
|
||||
profileId,
|
||||
_currentDate
|
||||
]);
|
||||
const _posLevel = posLevel.length > 0 ? posLevel[0] : [];
|
||||
const mapPosLevel =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue