diff --git a/src/libs/routes/classroomCount.js b/src/libs/routes/classroomCount.js index 458117dbb59a9e10fdedd39dbd86b83dfd1bda70..b36b2fbac511898c3124a18d6cfcd4af08d089da 100644 --- a/src/libs/routes/classroomCount.js +++ b/src/libs/routes/classroomCount.js @@ -1050,8 +1050,6 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeachingHours = req.teachingHours[educationLevelId-1].shifts; - let journey = req.teacherJourney.journeyTotal * req.teacherJourney.journeyWithInteraction/100; - if(educationLevelId === 1) { // Devido a divisão da creche é necessário tratá-la separadamente. educationLevel.classes_school_year.forEach((schoolYear) => { // Aplicamos os cálculos para os anos da creche let teachingTimeFullPeriod = schoolYear.full_period_classes * currentTeachingHours[2].value * req.schoolDays[educationLevelId-1].value; @@ -1060,9 +1058,19 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.urban : req.educationSchoolYear[schoolYear.school_year_id].teacherByClass.country; - let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherFullPeriod = 0; + let numberOfTeacherNight = 0; + let numberOfTeacherDay = 0; + lastCity.percentage_teacher_career.forEach(career => { + let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) + let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; + numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage/100; + }) + numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); + numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); + numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); schoolYear.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod, @@ -1150,9 +1158,19 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { let currentTeacherByClass = (location.location_id === 1) ? req.educationSchoolYear[educationLevelId].teacherByClass.urban : req.educationSchoolYear[educationLevelId].teacherByClass.country; - let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2)); - let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2)); + let numberOfTeacherFullPeriod = 0; + let numberOfTeacherNight = 0; + let numberOfTeacherDay = 0; + lastCity.percentage_teacher_career.forEach(career => { + let journeyObj = req.teacherFormation.find(formation => formation.idFormationLevel === career.formation_level_id) + let journey = journeyObj.journeyWithInteraction/100 * journeyObj.journeyTotal; + numberOfTeacherFullPeriod += (teachingTimeFullPeriod / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherNight += (teachingTimeNight / journey) * currentTeacherByClass * career.percentage/100; + numberOfTeacherDay += (teachingTimeDay / journey) * currentTeacherByClass * career.percentage/100; + }) + numberOfTeacherFullPeriod = parseFloat(numberOfTeacherFullPeriod.toFixed(2)); + numberOfTeacherNight = parseFloat(numberOfTeacherNight.toFixed(2)); + numberOfTeacherDay = parseFloat(numberOfTeacherDay.toFixed(2)); educationLevel.teacherNumber = { total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod,