#867 (13)
This commit is contained in:
parent
ba00ce14d2
commit
3fcce9c15c
1 changed files with 11 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import { Command } from "../entities/Command";
|
||||
import { ProfileSalary } from "../entities/ProfileSalary";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { ProfileEmployee } from "../entities/ProfileEmployee";
|
||||
export function calculateAge(start: Date, end = new Date()) {
|
||||
if (start.getTime() > end.getTime()) return null;
|
||||
|
||||
|
|
@ -86,11 +87,19 @@ export async function calculateGovAge(profileId: string, type: string) {
|
|||
|
||||
return { years, months, days };
|
||||
};
|
||||
const profile = await AppDataSource.getRepository(Profile).findOne({
|
||||
let profile:any;
|
||||
profile = await AppDataSource.getRepository(Profile).findOne({
|
||||
where:{
|
||||
id:profileId
|
||||
}
|
||||
})
|
||||
if(isEmployee){
|
||||
profile = await AppDataSource.getRepository(ProfileEmployee).findOne({
|
||||
where:{
|
||||
id:profileId
|
||||
}
|
||||
})
|
||||
}
|
||||
// const firstStartDate = new Date(records[0].date);
|
||||
const firstStartDate = profile?.dateAppoint ? profile?.dateAppoint : new Date();
|
||||
const firstEndDate = endDateFristRec ? new Date(endDateFristRec.dateGovernment) : new Date();
|
||||
|
|
@ -100,7 +109,7 @@ export async function calculateGovAge(profileId: string, type: string) {
|
|||
months: totalMonths1,
|
||||
days: totalDays1,
|
||||
} = calculateDuration(firstStartDate, firstEndDate);
|
||||
|
||||
|
||||
const records_middle = await AppDataSource.getRepository(ProfileSalary).find({
|
||||
where: {
|
||||
[isEmployee ? "profileEmployeeId" : "profileId"]: profileId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue