From ea1a0a37a6771feaca1cacb4845bc0c721e26ef5 Mon Sep 17 00:00:00 2001
From: tgcl21 <tgcl21@inf.ufpr.br>
Date: Fri, 16 May 2025 15:48:00 -0300
Subject: [PATCH 1/4] Fixed the the wrong total errors

---
 src/libs/routes_v1/instructionLevel.js | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/libs/routes_v1/instructionLevel.js b/src/libs/routes_v1/instructionLevel.js
index d3cb7d0c..aa083380 100644
--- a/src/libs/routes_v1/instructionLevel.js
+++ b/src/libs/routes_v1/instructionLevel.js
@@ -291,7 +291,6 @@ NivelInstrucao.get('/', rqf.parse(), rqf.build(),  (req, res, next) => {
         .field('nivel_de_instrucao', 'nivel')
         .field('round(sum(peso_domicilio_pessoas_com_cal), 0)', 'total')
         .field('ano_ref', 'year')
-        .where('nivel_de_instrucao <> 99')
         .where('faixa_etaria <> 99')
         .group('pnad_novo.ano_ref')
         .group('pnad_novo.nivel_de_instrucao')
-- 
GitLab


From a1a27edd3b3949da3028505d140bb8a4eb18d0f4 Mon Sep 17 00:00:00 2001
From: es23 <es23@inf.ufpr.br>
Date: Tue, 20 May 2025 10:22:51 -0300
Subject: [PATCH 2/4] fix income range null field

---
 src/libs/routes_v1/studentsReceivingAidTax.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/libs/routes_v1/studentsReceivingAidTax.js b/src/libs/routes_v1/studentsReceivingAidTax.js
index c4509cf8..b515e376 100644
--- a/src/libs/routes_v1/studentsReceivingAidTax.js
+++ b/src/libs/routes_v1/studentsReceivingAidTax.js
@@ -578,8 +578,21 @@ function matchQueries(queryPartial, queryTotal) {
     return match;
 }
 
+function whereCondition(req) {
+    let where = "";
+
+    const dims = req.query.dims;
+	if (dims && dims.includes("income_range")){
+		where += `pnad_novo.faixa_rendimento_aux_tx is not null`;
+	}
+
+    
+    return where;
+}
+
 studentsReceivingAidTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
     req.querySet = [];
+    let where = whereCondition(req);
     
     // Subquery para total_pop_maior_25 com filtros dinĂ¢micos
     let totalEstudantesQueRecebemAuxilio = req.sql.clone();
@@ -587,6 +600,7 @@ studentsReceivingAidTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) =
         .field("ano_ref", "year")
         .field("SUM(peso_domicilio_pessoas_com_cal)", "total")
         .where("recebeu_rendimentos_de_programa_bolsa_familia = 1")
+		.where(`${where}`)
         .where("frequenta_escola = 1")
         .where("ano_ref >= 2019")
         .group("ano_ref")
@@ -598,7 +612,9 @@ studentsReceivingAidTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) =
         totalEstudantes.from("pnad_novo")
         .field("ano_ref", "year")
         .field("SUM(peso_domicilio_pessoas_com_cal)", "total")
+		.where(`${where}`)
         .where("frequenta_escola = 1")
+        .where("ano_ref >= 2019")
         .group("ano_ref")
         .order("ano_ref");
 
-- 
GitLab


From f7240405b47b5de5f633ce5a92ae14623366ca39 Mon Sep 17 00:00:00 2001
From: es23 <es23@inf.ufpr.br>
Date: Wed, 21 May 2025 10:24:44 -0300
Subject: [PATCH 3/4] fix age range filter

---
 src/libs/convert/ageRangeAll.js               | 2 +-
 src/libs/routes_v1/studentsReceivingAidTax.js | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/libs/convert/ageRangeAll.js b/src/libs/convert/ageRangeAll.js
index 1ad1c54e..ebc2336a 100644
--- a/src/libs/convert/ageRangeAll.js
+++ b/src/libs/convert/ageRangeAll.js
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
 along with simcaq-node.  If not, see <https://www.gnu.org/licenses/>.
 */
 
-module.exports = function ageRange(id) {
+module.exports = function ageRangeAll(id) {
     switch (id) {
         case 1:
         return '0 a 3 anos';
diff --git a/src/libs/routes_v1/studentsReceivingAidTax.js b/src/libs/routes_v1/studentsReceivingAidTax.js
index b515e376..16547bfd 100644
--- a/src/libs/routes_v1/studentsReceivingAidTax.js
+++ b/src/libs/routes_v1/studentsReceivingAidTax.js
@@ -242,7 +242,7 @@ studentsReceivingAidTaxApp.get('/state', (req, res, next) => {
     next();
 }, response('state'));
 
-studentsReceivingAidTaxApp.get('/age_range', (req, res, next) => {
+studentsReceivingAidTaxApp.get('/age_range_all', (req, res, next) => {
     req.result = []
     for (let i = 1; i < 12; i++) {
         req.result.push({
@@ -251,7 +251,7 @@ studentsReceivingAidTaxApp.get('/age_range', (req, res, next) => {
     }
 
     next();
-}, response('age_range'));
+}, response('age_range_all'));
 
 studentsReceivingAidTaxApp.get('/location', (req, res, next) => {
     req.result = []
@@ -618,7 +618,6 @@ studentsReceivingAidTaxApp.get('/', rqf.parse(), rqf.build(), (req, res, next) =
         .group("ano_ref")
         .order("ano_ref");
 
-
     req.querySet.push(totalEstudantesQueRecebemAuxilio);
     req.querySet.push(totalEstudantes);
 
-- 
GitLab


From 877de5b65ab37df70734f25153d6b64a1c38c263 Mon Sep 17 00:00:00 2001
From: Joao Pedro <jpv.ramalho2013@gmail.com>
Date: Thu, 22 May 2025 09:24:54 -0300
Subject: [PATCH 4/4] [fix] arredondando para duas casas decimais

---
 src/libs/routes_v1/expenses.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/libs/routes_v1/expenses.js b/src/libs/routes_v1/expenses.js
index 36248659..624609e8 100644
--- a/src/libs/routes_v1/expenses.js
+++ b/src/libs/routes_v1/expenses.js
@@ -126,13 +126,13 @@ ExpensesApp.get('/', rqf.parse(), rqf.build(),  (req, res, next) => {
         .field('despesas.ano_censo', 'year')
         .field('despesas.ano_censo', 'total_ano')
         .field('despesas.nome_ente', 'total_nome_ente')
-        .field('despesas.despesas', 'total_despesas')
+        .field('round(despesas.despesas,2)', 'total_despesas')
         .field('matriculas_publica', 'total_matriculas_publica')
         .field('matriculas_publicas_mais_conveniada', 'total_matriculas_publicas_mais_conveniada')
-        .field('gasto_aluno_ano_publica', 'total_gasto_aluno_ano_publica')
-        .field('gasto_aluno_mes_publica', 'total_gasto_aluno_mes_publica')
-        .field('gasto_aluno_ano_publica_mais_conveniada', 'total_gasto_aluno_ano_publica_mais_conveniada')
-        .field('gasto_aluno_mes_publica_mais_conveniada', 'total_gasto_aluno_mes_publica_mais_conveniada')
+        .field('round(gasto_aluno_ano_publica,2)', 'total_gasto_aluno_ano_publica')
+        .field('round(gasto_aluno_mes_publica,2)', 'total_gasto_aluno_mes_publica')
+        .field('round(gasto_aluno_ano_publica_mais_conveniada,2)', 'total_gasto_aluno_ano_publica_mais_conveniada')
+        .field('round(gasto_aluno_mes_publica_mais_conveniada,2)', 'total_gasto_aluno_mes_publica_mais_conveniada')
         .where(`${whereCondition}`)
         .order('despesas.ano_censo')
     }
-- 
GitLab