Merge branch 'develop' of github.com:Frappet/hrms-api-org into develop
This commit is contained in:
commit
5eb46baeeb
4 changed files with 79 additions and 2 deletions
|
|
@ -78,6 +78,7 @@ async function main() {
|
||||||
const profileSalaryController = new ProfileSalaryController();
|
const profileSalaryController = new ProfileSalaryController();
|
||||||
await profileSalaryController.cronjobTenurePositionOfficer();
|
await profileSalaryController.cronjobTenurePositionOfficer();
|
||||||
await profileSalaryController.cronjobTenureLevelOfficer();
|
await profileSalaryController.cronjobTenureLevelOfficer();
|
||||||
|
await profileSalaryController.cronjobTenureExecutivePositionOfficer();
|
||||||
await profileSalaryController.cronjobTenurePositionEmployee();
|
await profileSalaryController.cronjobTenurePositionEmployee();
|
||||||
await profileSalaryController.cronjobTenureLevelEmployee();
|
await profileSalaryController.cronjobTenureLevelEmployee();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,11 @@ import { TenurePositionOfficer } from "../entities/TenurePositionOfficer";
|
||||||
import { TenureLevelOfficer } from "../entities/TenureLevelOfficer";
|
import { TenureLevelOfficer } from "../entities/TenureLevelOfficer";
|
||||||
import { TenurePositionEmployee } from "../entities/TenurePositionEmployee";
|
import { TenurePositionEmployee } from "../entities/TenurePositionEmployee";
|
||||||
import { TenureLevelEmployee } from "../entities/TenureLevelEmployee";
|
import { TenureLevelEmployee } from "../entities/TenureLevelEmployee";
|
||||||
|
import { TenurePositionExecutiveOfficer } from "../entities/TenurePositionExecutiveOfficer";
|
||||||
import { Command } from "../entities/Command";
|
import { Command } from "../entities/Command";
|
||||||
import { OrgRoot } from "../entities/OrgRoot";
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
|
import { Position } from "../entities/Position";
|
||||||
@Route("api/v1/org/profile/salary")
|
@Route("api/v1/org/profile/salary")
|
||||||
@Tags("ProfileSalary")
|
@Tags("ProfileSalary")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -41,8 +44,11 @@ export class ProfileSalaryController extends Controller {
|
||||||
private positionEmployeeRepo = AppDataSource.getRepository(TenurePositionEmployee);
|
private positionEmployeeRepo = AppDataSource.getRepository(TenurePositionEmployee);
|
||||||
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
|
private levelOfficerRepo = AppDataSource.getRepository(TenureLevelOfficer);
|
||||||
private levelEmployeeRepo = AppDataSource.getRepository(TenureLevelEmployee);
|
private levelEmployeeRepo = AppDataSource.getRepository(TenureLevelEmployee);
|
||||||
|
private positionExecutiveOfficerRepo = AppDataSource.getRepository(TenurePositionExecutiveOfficer);
|
||||||
private commandRepository = AppDataSource.getRepository(Command);
|
private commandRepository = AppDataSource.getRepository(Command);
|
||||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||||
|
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||||
|
private positionRepo = AppDataSource.getRepository(Position);
|
||||||
|
|
||||||
@Get("TenurePositionOfficer")
|
@Get("TenurePositionOfficer")
|
||||||
public async cronjobTenurePositionOfficer() {
|
public async cronjobTenurePositionOfficer() {
|
||||||
|
|
@ -229,6 +235,64 @@ export class ProfileSalaryController extends Controller {
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get("TenurePositionExecutiveOfficer")
|
||||||
|
public async cronjobTenureExecutivePositionOfficer() {
|
||||||
|
await this.positionExecutiveOfficerRepo.clear();
|
||||||
|
const profile = await this.profileRepo.find();
|
||||||
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
select: ["id"],
|
||||||
|
where: {
|
||||||
|
orgRevisionIsDraft: false,
|
||||||
|
orgRevisionIsCurrent: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
for await (const x of profile) {
|
||||||
|
const position = await this.positionRepo.findOne({
|
||||||
|
where: {
|
||||||
|
positionIsSelected: true,
|
||||||
|
posMaster: {
|
||||||
|
orgRevisionId: orgRevision?.id,
|
||||||
|
current_holderId: x.id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
order: { createdAt: "DESC" },
|
||||||
|
relations: {
|
||||||
|
posExecutive: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const positionExecutive = await AppDataSource.query("CALL GetProfileSalaryExecutive(?)", [x.id]);
|
||||||
|
const _position = positionExecutive.length > 0 ? positionExecutive[0] : [];
|
||||||
|
const mapPosition =
|
||||||
|
_position.length > 1
|
||||||
|
? _position.slice(1).map((curr: any, index: number) => ({
|
||||||
|
days_diff: curr.days_diff,
|
||||||
|
positionExecutive: _position[index]?.positionExecutive,
|
||||||
|
}))
|
||||||
|
: [];
|
||||||
|
const _posExecutiveName = position?.posExecutive?.posExecutiveName;
|
||||||
|
const calDayDiff = mapPosition
|
||||||
|
.filter((curr: any) => _posExecutiveName && curr.positionExecutive == _posExecutiveName)
|
||||||
|
.reduce(
|
||||||
|
(acc: any, curr: any) => {
|
||||||
|
acc.days_diff += Number(curr.days_diff) || 0;
|
||||||
|
acc.positionExecutive = curr.positionExecutive;
|
||||||
|
return acc;
|
||||||
|
},
|
||||||
|
{ days_diff: 0, positionExecutive: null },
|
||||||
|
);
|
||||||
|
const mapData: any = {
|
||||||
|
profileId: x.id,
|
||||||
|
positionExecutiveName: calDayDiff.positionExecutive,
|
||||||
|
days_diff: calDayDiff.days_diff,
|
||||||
|
Years: (calDayDiff.days_diff / 365.2524).toFixed(4),
|
||||||
|
Months: ((calDayDiff.days_diff / 30.4375) % 12).toFixed(4),
|
||||||
|
Days: (calDayDiff.days_diff % 30.4375).toFixed(4),
|
||||||
|
};
|
||||||
|
await this.positionExecutiveOfficerRepo.save(mapData);
|
||||||
|
}
|
||||||
|
return new HttpSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
@Get("user")
|
@Get("user")
|
||||||
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
|
public async getSalaryUser(@Request() request: { user: Record<string, any> }) {
|
||||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ export class ReportController extends Controller {
|
||||||
} else if (tenureType != "" && tenureType == "level") {
|
} else if (tenureType != "" && tenureType == "level") {
|
||||||
tenureTypeCondition = "registryOfficer.levelYears BETWEEN :tenureMin AND :tenureMax";
|
tenureTypeCondition = "registryOfficer.levelYears BETWEEN :tenureMin AND :tenureMax";
|
||||||
} else if (tenureType != "" && tenureType == "posExecutive") {
|
} else if (tenureType != "" && tenureType == "posExecutive") {
|
||||||
tenureTypeCondition = "registryOfficer.levelYears BETWEEN :tenureMin AND :tenureMax";
|
tenureTypeCondition = "registryOfficer.posExecutiveYears BETWEEN :tenureMin AND :tenureMax";
|
||||||
}
|
}
|
||||||
|
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
|
const [lists, total] = await AppDataSource.getRepository(viewRegistryOfficer)
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,14 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
vctlo.Days,
|
vctlo.Days,
|
||||||
vctlo.profileId
|
vctlo.profileId
|
||||||
FROM tenureLevelOfficer vctlo
|
FROM tenureLevelOfficer vctlo
|
||||||
|
),
|
||||||
|
PositionExecutiveDate AS (
|
||||||
|
SELECT
|
||||||
|
vcteo.Years,
|
||||||
|
vcteo.Months,
|
||||||
|
vcteo.Days,
|
||||||
|
vcteo.profileId
|
||||||
|
FROM tenurePositionExecutiveOfficer vcteo
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
p.id as profileId,
|
p.id as profileId,
|
||||||
|
|
@ -168,7 +176,10 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
vcto.Days,
|
vcto.Days,
|
||||||
vctlo.Years AS levelYears,
|
vctlo.Years AS levelYears,
|
||||||
vctlo.Months AS levelMonths,
|
vctlo.Months AS levelMonths,
|
||||||
vctlo.Days AS levelDays
|
vctlo.Days AS levelDays,
|
||||||
|
vcteo.Years AS posExecutiveYears,
|
||||||
|
vcteo.Months AS posExecutiveMonths,
|
||||||
|
vcteo.Days AS posExecutiveDays
|
||||||
FROM profile p
|
FROM profile p
|
||||||
LEFT JOIN posLevel ON p.posLevelId = posLevel.id
|
LEFT JOIN posLevel ON p.posLevelId = posLevel.id
|
||||||
LEFT JOIN posType ON p.posTypeId = posType.id
|
LEFT JOIN posType ON p.posTypeId = posType.id
|
||||||
|
|
@ -179,6 +190,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
||||||
LEFT JOIN Fields fies ON p.id = fies.profileId
|
LEFT JOIN Fields fies ON p.id = fies.profileId
|
||||||
LEFT JOIN PositionDate vcto ON p.id = vcto.profileId
|
LEFT JOIN PositionDate vcto ON p.id = vcto.profileId
|
||||||
LEFT JOIN PositionLevelDate vctlo ON p.id = vctlo.profileId
|
LEFT JOIN PositionLevelDate vctlo ON p.id = vctlo.profileId
|
||||||
|
LEFT JOIN PositionExecutiveDate vcteo ON p.id = vcteo.profileId
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class viewRegistryOfficer {
|
export class viewRegistryOfficer {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue