Commit 5e5addbf authored by jvfpw18's avatar jvfpw18

Round results to 2 decimals in classroom_count instead of using ceil

parent 32901642
Pipeline #23508 failed with stage
in 9 minutes and 50 seconds
......@@ -640,20 +640,20 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
// Calcula o número de turmas parcial
// Turmas de período integral
educationLevel.enrollment.full_period_classes = Math.ceil((educationLevel.enrollment.total_enrollment_day * (currentIntegralOfferGoal/100)) / currentNumberStudentClass);
educationLevel.enrollment.full_period_classes = parseFloat(((educationLevel.enrollment.total_enrollment_day * (currentIntegralOfferGoal/100)) / currentNumberStudentClass).toFixed(2));
// Turmas diurnas (matrículas diurnas - matrículas integrais)
educationLevel.enrollment.day_classes = Math.ceil((educationLevel.enrollment.total_enrollment_day * (1 - currentIntegralOfferGoal/100)) / currentNumberStudentClass);
educationLevel.enrollment.day_classes = parseFloat(((educationLevel.enrollment.total_enrollment_day * (1 - currentIntegralOfferGoal/100)) / currentNumberStudentClass).toFixed(2));
// Turmas noturnas
educationLevel.enrollment.night_classes = Math.ceil((educationLevel.enrollment.total_enrollment_night / currentNumberStudentClass)) || 0;
educationLevel.enrollment.night_classes = parseFloat((educationLevel.enrollment.total_enrollment_night / currentNumberStudentClass).toFixed(2)) || 0;
// Total de salas
educationLevel.enrollment.total_classrooms_needed = (educationLevel.enrollment.full_period_classes + educationLevel.enrollment.day_classes/2);
if(educationLevel.enrollment.night_classes > (educationLevel.enrollment.day_classes/2)) educationLevel.enrollment.total_classrooms_needed += (educationLevel.enrollment.night_classes - (educationLevel.enrollment.day_classes/2));
educationLevel.enrollment.total_classrooms_needed = Math.ceil(educationLevel.enrollment.total_classrooms_needed);
educationLevel.enrollment.total_classrooms_needed = parseFloat(educationLevel.enrollment.total_classrooms_needed.toFixed(2));
let currentEnrollmentOfferDay;
......@@ -667,9 +667,9 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
// Projeção de matricula multiplicada pelo indice de distribuição de matriculas da localização.
if (req.projections && (currentEnrollmentOfferDay.enrollments !== undefined) ) {
educationLevel.enrollment.total_enrollment_day += Math.ceil((currentEnrollmentOfferDay.enrollments[yearCount].quantity - currentEnrollmentOfferDay.currentOffer)*enrollmentIdm.idm);
educationLevel.enrollment.total_enrollment_day += parseFloat(((currentEnrollmentOfferDay.enrollments[yearCount].quantity - currentEnrollmentOfferDay.currentOffer)*enrollmentIdm.idm).toFixed(2));
if (educationLevel.enrollment.total_enrollment_day < 0) educationLevel.enrollment.total_enrollment_day = 0;
educationLevel.enrollment.total_enrollment_night += (educationLevel.education_level_short_id > 2) ? Math.ceil((currentEnrollmentOfferNight.enrollments[yearCount].quantity - currentEnrollmentOfferNight.currentOffer)*enrollmentIdm.idm) : 0;
educationLevel.enrollment.total_enrollment_night += (educationLevel.education_level_short_id > 2) ? parseFloat(((currentEnrollmentOfferNight.enrollments[yearCount].quantity - currentEnrollmentOfferNight.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0;
if (educationLevel.enrollment.total_enrollment_night < 0) educationLevel.enrollment.total_enrollment_night = 0;
}
}
......@@ -696,20 +696,20 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
verifySchoolYear[location.location_id-1][currentSchoolYear.school_year_id] = 1;
let currentEnrollmentSchoolYear = currentEnrollmentOfferDay.seriesEnrollments[Math.trunc(currentSchoolYear.school_year_id/10) - 1];
currentSchoolYear.total_enrollment_day += (currentEnrollmentSchoolYear !== undefined) ? Math.ceil((currentEnrollmentSchoolYear.enrollments[yearCount].quantity - currentEnrollmentSchoolYear.currentOffer)*enrollmentIdm.idm) : 0;
currentSchoolYear.total_enrollment_day += (currentEnrollmentSchoolYear !== undefined) ? parseFloat(((currentEnrollmentSchoolYear.enrollments[yearCount].quantity - currentEnrollmentSchoolYear.currentOffer)*enrollmentIdm.idm).toFixed(2)) : 0;
if (currentSchoolYear.total_enrollment_day < 0) currentSchoolYear.total_enrollment_day = 0;
}
// Número de turmas parcial
currentSchoolYear.full_period_classes = Math.ceil((currentSchoolYear.total_enrollment_day * (currentIntegralOfferGoal/100)) / currentNumberStudentClass);
currentSchoolYear.full_period_classes = parseFloat(((currentSchoolYear.total_enrollment_day * (currentIntegralOfferGoal/100)) / currentNumberStudentClass).toFixed(2));
currentSchoolYear.day_classes = Math.ceil((currentSchoolYear.total_enrollment_day * (1 - currentIntegralOfferGoal/100)) / currentNumberStudentClass);
currentSchoolYear.day_classes = parseFloat(((currentSchoolYear.total_enrollment_day * (1 - currentIntegralOfferGoal/100)) / currentNumberStudentClass).toFixed(2));
// Total de salas
currentSchoolYear.total_classrooms_needed = (currentSchoolYear.full_period_classes + currentSchoolYear.day_classes/2);
currentSchoolYear.total_classrooms_needed = Math.ceil(currentSchoolYear.total_classrooms_needed);
currentSchoolYear.total_classrooms_needed = parseFloat(currentSchoolYear.total_classrooms_needed.toFixed(2));
function reducer(key) { return (sum, elem) => sum + elem[key]}
educationLevel.enrollment.total_enrollment_day = educationLevel.classes_school_year.reduce(reducer('total_enrollment_day'), 0);
......@@ -974,9 +974,9 @@ 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 = Math.ceil((teachingTimeFullPeriod / journey) * currentTeacherByClass);
let numberOfTeacherNight = Math.ceil((teachingTimeNight / journey) * currentTeacherByClass);
let numberOfTeacherDay = Math.ceil((teachingTimeDay / journey) * currentTeacherByClass);
let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2));
let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2));
let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2));
schoolYear.teacherNumber = {
total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod,
......@@ -1064,9 +1064,9 @@ 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 = Math.ceil((teachingTimeFullPeriod / journey) * currentTeacherByClass);
let numberOfTeacherNight = Math.ceil((teachingTimeNight / journey) * currentTeacherByClass);
let numberOfTeacherDay = Math.ceil((teachingTimeDay / journey) * currentTeacherByClass);
let numberOfTeacherFullPeriod = parseFloat(((teachingTimeFullPeriod / journey) * currentTeacherByClass).toFixed(2));
let numberOfTeacherNight = parseFloat(((teachingTimeNight / journey) * currentTeacherByClass).toFixed(2));
let numberOfTeacherDay = parseFloat(((teachingTimeDay / journey) * currentTeacherByClass).toFixed(2));
educationLevel.teacherNumber = {
total_teacher : numberOfTeacherDay + numberOfTeacherNight + numberOfTeacherFullPeriod,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment