From 8e2e67cc33c61f5a668653bed2b391cb61276bc7 Mon Sep 17 00:00:00 2001 From: nevisson <nevisson@gmail.com> Date: Sat, 13 Jul 2019 13:40:43 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20da=20distribui=C3=A7=C3=A3?= =?UTF-8?q?o=20dos=20percentuais=20na=20tela=20da=20carreira=20de=20profes?= =?UTF-8?q?sores.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entities/enums/formation-level.enum.ts | 7 +++ ...r-and-remuneration-teachers.component.html | 6 +- ...eer-and-remuneration-teachers.component.ts | 5 +- ...areer-and-remuneration-teachers.service.ts | 58 +++++++++++++++++-- .../services/item-cost.service.ts | 2 +- 5 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 src/app/shared/entities/enums/formation-level.enum.ts 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 00000000..01b1b7cb --- /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 bc7d5e34..7d0d2876 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 5104f211..6978dfab 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 2301ebb9..0147ee56 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 a4729e9d..4e36b10e 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; -- GitLab