diff --git a/src/app/simulator/pqr/services/pqr.service.ts b/src/app/simulator/pqr/services/pqr.service.ts index 7ad3c9a026efa0a272f4a5bd2b8a69671bf9da1f..ef860aa8d14845e4d9d236a17c73dcb32d911db8 100644 --- a/src/app/simulator/pqr/services/pqr.service.ts +++ b/src/app/simulator/pqr/services/pqr.service.ts @@ -85,7 +85,7 @@ export class PqrService { return this.workJourneyTeacherService.getData(); case CareerAndRemunerationTeachersComponent: - return this.careerAndRemunerationTeachersService.getData(); + return this.careerAndRemunerationTeachersService.getData(true); case InfrastructureSchoolBuildingsComponent: return this.infrastructureSchoolBuildingsService.getData(true); diff --git a/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.ts b/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.ts index 6978dfabb7c697cab28a5f84d25d61f995541906..ed9928af75a08e4be89fd9d43540c4666a529ede 100644 --- a/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.ts +++ b/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.ts @@ -39,7 +39,7 @@ export class CareerAndRemunerationTeachersComponent extends BaseNavigableCompone } processData(): Observable<CareerAndRemunerationTeachers> { - return this.careerAndRemunerationTeachersService.getData(); + return this.careerAndRemunerationTeachersService.getData(this.pqrMode); } processSessionData(sessionData: CareerAndRemunerationTeachers): void { @@ -68,11 +68,13 @@ export class CareerAndRemunerationTeachersComponent extends BaseNavigableCompone } ngDoCheck(): void { - if (this.data.teacherFormationLevels && this.data.teacherFormationLevels.levels.length > 0) { - if (this.data.teacherFormationLevels.levels[0].diagnostic !== undefined) { - if (!_.isEqual(this.data.teacherFormationLevels.levels, this.prevTeacherFormationLevels)) { - this.careerAndRemunerationTeachersService.processTotals(this.data); - this.prevTeacherFormationLevels = _.cloneDeep(this.data.teacherFormationLevels.levels); + if (!this.pqrMode) { + if (this.data.teacherFormationLevels && this.data.teacherFormationLevels.levels.length > 0) { + if (this.data.teacherFormationLevels.levels[0].diagnostic !== undefined) { + if (!_.isEqual(this.data.teacherFormationLevels.levels, this.prevTeacherFormationLevels)) { + this.careerAndRemunerationTeachersService.processTotals(this.data); + this.prevTeacherFormationLevels = _.cloneDeep(this.data.teacherFormationLevels.levels); + } } } } diff --git a/src/app/simulator/quality-conditions/career-and-remuneration-teachers/services/career-and-remuneration-teachers.service.ts b/src/app/simulator/quality-conditions/career-and-remuneration-teachers/services/career-and-remuneration-teachers.service.ts index 0147ee568971836767b036d51b0b5e9700347719..d47cabb565883b1012c4addfbc2f92124e14faad 100644 --- a/src/app/simulator/quality-conditions/career-and-remuneration-teachers/services/career-and-remuneration-teachers.service.ts +++ b/src/app/simulator/quality-conditions/career-and-remuneration-teachers/services/career-and-remuneration-teachers.service.ts @@ -27,7 +27,7 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS constructor(private httpService: HttpService, private utilitiesService: UtilitiesService, private sessionService: SessionService, private currentYearService: CurrentYearService) { } - getData(): Observable<CareerAndRemunerationTeachers> { + getData(pqrMode: boolean = false): Observable<CareerAndRemunerationTeachers> { const simulationYears = this.getSimulationYears(); const careerAndRemunerationTeachers: CareerAndRemunerationTeachers = new CareerAndRemunerationTeachers({ years: simulationYears }); @@ -49,11 +49,15 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS } careerAndRemunerationTeachers.teacherFormationLevels = teacherFormationLevels; - return this.getDiagnostic().pipe( - map((diagnostics) => { - this.setPercTeacherDistributionCareerLevel(careerAndRemunerationTeachers, diagnostics); - return careerAndRemunerationTeachers; - })); + if (!pqrMode) { + return this.getDiagnostic().pipe( + map((diagnostics) => { + this.setPercTeacherDistributionCareerLevel(careerAndRemunerationTeachers, diagnostics); + return careerAndRemunerationTeachers; + })); + } else { + return of(careerAndRemunerationTeachers); + } })); })); } @@ -125,7 +129,7 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS const totalPercentageOfYear: number = this.utilitiesService.roundNumber((teacherFormationLevelOfYear.percTeacherDistributionCareerLevel.map((percDistributionLevel: TeacherDistributionCareerLevel) => percDistributionLevel.percentage).reduce((a, b) => { - return b ? a + b : a; + return a + b; })), 2); careerAndRemunerationTeachers.totals.push(new TeacherDistributionCareerLevel({ year: year, percentage: totalPercentageOfYear * 1e0 / 1e0 })); @@ -261,9 +265,9 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS const yearsSimulation: Array<number> = this.utilitiesService.getSimulationYears(); for (let i = 0; i < data.teacherFormationLevels.levels.length; i++) { - data.teacherFormationLevels.levels[i].diagnostic = undefined; + data.teacherFormationLevels.levels[i].diagnostic = 0; data.teacherFormationLevels.levels[i].percTeacherDistributionCareerLevel = yearsSimulation.map(yearSimulation => - new TeacherDistributionCareerLevel({ year: yearSimulation, percentage: undefined })); + new TeacherDistributionCareerLevel({ year: yearSimulation, percentage: 0 })); } } @@ -275,14 +279,13 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS const totalPercentageOfYear: number = this.utilitiesService.roundNumber(((teacherFormationLevelOfYear.percTeacherDistributionCareerLevel.map((percDistributionLevel: TeacherDistributionCareerLevel) => percDistributionLevel.percentage).reduce((a, b) => { - return b ? a + b : a; + return a + b; }))), 2); if (totalPercentageOfYear !== 100) { let formation = _.find(careerAndRemunerationTeachers.teacherFormationLevels.levels, l => l.formationLevel.id === FormationLevelEnum.Superior); - - if (formation === undefined || formation === null) { + if (formation.diagnostic === 0) { formation = _.find(careerAndRemunerationTeachers.teacherFormationLevels.levels, l => l.formationLevel.id === FormationLevelEnum.Medio); }