diff --git a/src/app/shared/entities/enums/formation-level.enum.ts b/src/app/shared/entities/enums/formation-level.enum.ts new file mode 100644 index 0000000000000000000000000000000000000000..01b1b7cba6f62d954efe9aceeaf3b366275cea38 --- /dev/null +++ b/src/app/shared/entities/enums/formation-level.enum.ts @@ -0,0 +1,7 @@ +export enum FormationLevelEnum { + Medio = 2, + Superior = 4, + Especializacao = 6, + Mestrado = 7, + Doutorado = 8 +} diff --git a/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.html b/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.html index bc7d5e3418a3ef809425e2699aa0ddcb925b7a3e..7d0d2876907f3e7bde5f7d7c178ff2891993f88f 100644 --- a/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.html +++ b/src/app/simulator/quality-conditions/career-and-remuneration-teachers/career-and-remuneration-teachers.component.html @@ -91,9 +91,9 @@ </td> <ng-container *ngIf="!pqrMode"> <td *ngFor="let percentageDistribution of teacherFormationLevel.percTeacherDistributionCareerLevel"> - <input type="text" class="form-control percentage diagnostic-value" maxlength="4" + <input type="text" class="form-control percentage diagnostic-value" maxlength="6" [(ngModel)]="percentageDistribution.percentage" [disabled]="!pqrAdminMode && pqrMode" currencyMask - [options]="{ prefix: '', suffix: '%', align: 'right', precision: 0, thousands: '.', decimal: ',' }"> + [options]="{ prefix: '', suffix: '%', align: 'right', precision: 1, thousands: '.', decimal: ',' }"> </td> </ng-container> </tr> @@ -113,4 +113,4 @@ </div> <app-inconsistency *ngIf="!pqrMode" [inconsistencies]="inconsistencies"></app-inconsistency> </div> -</div> \ No newline at end of file +</div> 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 5104f2115140beadcb66fc41ee4d653deec045d6..6978dfabb7c697cab28a5f84d25d61f995541906 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 @@ -97,7 +97,10 @@ export class CareerAndRemunerationTeachersComponent extends BaseNavigableCompone sumDiagnostic() { let total: number = 0; if (this.data.teacherFormationLevels !== undefined) { - total = this.data.teacherFormationLevels.levels.reduce((prevVal, elem) => prevVal + elem.diagnostic, 0); + total = this.data.teacherFormationLevels.levels.reduce((prevVal, elem) => { + return elem.diagnostic ? prevVal + elem.diagnostic : prevVal; + } + , 0); } return total; } 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 2301ebb93bff8af19c85b9f6b74dfd16febf551a..0147ee568971836767b036d51b0b5e9700347719 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 @@ -18,6 +18,7 @@ import { SourceInformationEnum } from './../../../../shared/entities/enums/sourc import { Footnote } from './../../../../shared/components/footnote/entities/footnote'; import { HttpService } from '../../../../shared/services/http/http.service'; import { CurrentYearService } from '../../../shared/services/current-year/current-year.service'; +import { FormationLevelEnum } from './../../../../shared/entities/enums/formation-level.enum'; @Injectable({ providedIn: 'root' @@ -116,16 +117,18 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS processTotals(careerAndRemunerationTeachers: CareerAndRemunerationTeachers): void { - const simulationsYears: Array<Number> = careerAndRemunerationTeachers.years; careerAndRemunerationTeachers.totals = new Array<TeacherDistributionCareerLevel>(); for (const year of careerAndRemunerationTeachers.years) { const teacherFormationLevelOfYear: TeacherFormationLevel = this.getTeacherFormationLevelOfYear(careerAndRemunerationTeachers, year); const totalPercentageOfYear: number = - teacherFormationLevelOfYear.percTeacherDistributionCareerLevel.map((percDistributionLevel: TeacherDistributionCareerLevel) => percDistributionLevel.percentage).reduce((a, b) => a + b); + this.utilitiesService.roundNumber((teacherFormationLevelOfYear.percTeacherDistributionCareerLevel.map((percDistributionLevel: TeacherDistributionCareerLevel) => + percDistributionLevel.percentage).reduce((a, b) => { + return b ? a + b : a; + })), 2); - careerAndRemunerationTeachers.totals.push(new TeacherDistributionCareerLevel({ year: year, percentage: Math.round(totalPercentageOfYear * 1e0) / 1e0 })); + careerAndRemunerationTeachers.totals.push(new TeacherDistributionCareerLevel({ year: year, percentage: totalPercentageOfYear * 1e0 / 1e0 })); } } @@ -166,6 +169,7 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS const newDiagnostic: Array<any> = new Array<any>(); let totalTeacherLevel: number = 0; + this.clearDiagnosticAndPercTeacherDistributionCareerLevel(data); for (let i = 0; i < diagnostics.length; i++) { let educationTypeId: Number; @@ -198,7 +202,7 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS } const tdc: Array<TeacherDistributionCareerLevel> = new Array<TeacherDistributionCareerLevel>(); - const percentageValue = parseFloat(((objData.diagnostic * 100) / totalTeacherLevel).toFixed(0)); + const percentageValue = this.utilitiesService.roundNumber(((objData.diagnostic * 100) / totalTeacherLevel), 1); for (const year of data.years) { tdc.push({ year: year, percentage: percentageValue }); @@ -211,6 +215,7 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS const total: Array<TeacherDistributionCareerLevel> = new Array<TeacherDistributionCareerLevel>(); data.totals = total; + this.verifyAndSetPercents(data); this.processTotals(data); } @@ -251,4 +256,49 @@ export class CareerAndRemunerationTeachersService implements NavigableComponentS return this.utilitiesService.getSimulationYears(!this.utilitiesService.isFullPqrRoute() ? 0 : UtilitiesService.maxSimulationTime); } + private clearDiagnosticAndPercTeacherDistributionCareerLevel(data: CareerAndRemunerationTeachers) { + + 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].percTeacherDistributionCareerLevel = yearsSimulation.map(yearSimulation => + new TeacherDistributionCareerLevel({ year: yearSimulation, percentage: undefined })); + } + } + + private verifyAndSetPercents(careerAndRemunerationTeachers: CareerAndRemunerationTeachers): void { + + for (const year of careerAndRemunerationTeachers.years) { + const teacherFormationLevelOfYear: TeacherFormationLevel = this.getTeacherFormationLevelOfYear(careerAndRemunerationTeachers, year); + + const totalPercentageOfYear: number = + this.utilitiesService.roundNumber(((teacherFormationLevelOfYear.percTeacherDistributionCareerLevel.map((percDistributionLevel: TeacherDistributionCareerLevel) => + percDistributionLevel.percentage).reduce((a, b) => { + return b ? a + b : a; + }))), 2); + + if (totalPercentageOfYear !== 100) { + + let formation = _.find(careerAndRemunerationTeachers.teacherFormationLevels.levels, l => l.formationLevel.id === FormationLevelEnum.Superior); + + if (formation === undefined || formation === null) { + formation = _.find(careerAndRemunerationTeachers.teacherFormationLevels.levels, l => l.formationLevel.id === FormationLevelEnum.Medio); + } + + for (let i = 0; i < careerAndRemunerationTeachers.teacherFormationLevels.levels.length; i++) { + const level = careerAndRemunerationTeachers.teacherFormationLevels.levels[i]; + + for (let j = 0; j < level.percTeacherDistributionCareerLevel.length; j++) { + const percentage: number = level.percTeacherDistributionCareerLevel[j].percentage; + if (level.formationLevel.id === formation.formationLevel.id && percentage !== undefined) { + level.percTeacherDistributionCareerLevel[j].percentage = + totalPercentageOfYear < 100 ? percentage + (100 - totalPercentageOfYear) : percentage - (totalPercentageOfYear - 100); + } + } + } + } + } + } + } diff --git a/src/app/simulator/shared/services/calculate-student-cost/services/item-cost.service.ts b/src/app/simulator/shared/services/calculate-student-cost/services/item-cost.service.ts index a4729e9d0fbc0091d6885ba7fcbbb60ed8119047..4e36b10e21129b246c53c5422125f0fb1968967a 100644 --- a/src/app/simulator/shared/services/calculate-student-cost/services/item-cost.service.ts +++ b/src/app/simulator/shared/services/calculate-student-cost/services/item-cost.service.ts @@ -466,7 +466,7 @@ export class ItemCostService { const teacherNumber: number = totalTeacherNumberByStage.careerLevelsByYear[j].teacherNumberTotal; const teacherNumberShiftPartial: number = totalTeacherNumberByStage.careerLevelsByYear[j].teacherNumberShiftPartial; const teacherNumberShiftIntegral: number = totalTeacherNumberByStage.careerLevelsByYear[j].teacherNumberShiftIntegral; - const percTeacherDistributionCareerLevel: number = percTeacherDistribution.percentage; + const percTeacherDistributionCareerLevel: number = percTeacherDistribution.percentage !== undefined ? percTeacherDistribution.percentage : 0; let priceIndiceValue: number = 0;