diff --git a/src/libs/convert/incomeRange.js b/src/libs/convert/incomeRange.js new file mode 100644 index 0000000000000000000000000000000000000000..fee5189b4a4100e42940108ce3f173e655ef13ee --- /dev/null +++ b/src/libs/convert/incomeRange.js @@ -0,0 +1,40 @@ +/* +Copyright (C) 2024 Centro de Computacao Cientifica e Software Livre +Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR + +This file is part of simcaq-node. + +simcaq-node is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +simcaq-node is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +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 incomeRange(id) { + switch (id) { + case 1: + return 'Até 1/4 salário mÃnimo'; + case 2: + return 'Mais de 1/4 até 1/2 salário mÃnimo'; + case 3: + return 'Mais de 1/2 até 1 salário mÃnimo'; + case 4: + return 'De 1 a 2 salários mÃnimos'; + case 5: + return 'Mais de 2 até 3 salários mÃnimos'; + case 6: + return 'Mais de 3 até 5 salários mÃnimos'; + case 7: + return 'Mais de 5 salários mÃnimos'; + case 9: + return 'Não informado ou ignorado'; + } +}; diff --git a/src/libs/middlewares/id2str.js b/src/libs/middlewares/id2str.js index 7229c2b48e5b02b6e9d95099e24b60b1bda39c92..d15505d31fc165e79b4e2033b10eb6cecf02c184 100644 --- a/src/libs/middlewares/id2str.js +++ b/src/libs/middlewares/id2str.js @@ -113,6 +113,7 @@ const capitalCode = require(`${libs}/convert/capitalCode`); const regionCode = require(`${libs}/convert/regionCode`); const metroCode = require(`${libs}/convert/metroCode`); const modalityShift = require(`${libs}/convert/modalityShift`); +const incomeRange = require(`${libs}/convert/incomeRange`); const ids = { gender_id: gender, @@ -218,7 +219,8 @@ const ids = { cap_code_id: capitalCode, reg_code_id: regionCode, metro_code_id: metroCode, - modality_shift_id: modalityShift + modality_shift_id: modalityShift, + income_range_id: incomeRange }; function transform(removeId=false) { @@ -346,5 +348,6 @@ module.exports = { capitalCode, regionCode, metroCode, - modalityShift + modalityShift, + incomeRange }; diff --git a/src/libs/routes_v1/newPnad.js b/src/libs/routes_v1/newPnad.js index 05ab151a4beeaaaf3f01aa9ff2e13242d16f2170..a2b13aa0bfa834c1d7f284356842a57dbe190096 100644 --- a/src/libs/routes_v1/newPnad.js +++ b/src/libs/routes_v1/newPnad.js @@ -195,7 +195,7 @@ PnadNovoApp.get('/new_pnad_ethnic_group', (req, res, next) => { next(); }, response('new_pnad_ethnic_group')); -PnadNovoApp.get('bolsa_familia', (req, res, next) => { +PnadNovoApp.get('/bolsa_familia', (req, res, next) => { req.result = [] for (let i = 1; i < 3; i++) { req.result.push({ @@ -206,6 +206,17 @@ PnadNovoApp.get('bolsa_familia', (req, res, next) => { next(); }, response('bolsa_familia')); +PnadNovoApp.get('/modality', (req, res, next) => { + req.result = [] + for (let i = 1; i < 4; i++) { + req.result.push({ + id: i, name: id2str.modality(i) + }); + } + req.result.push({id: 99, name: id2str.modality(99)}); + next(); +}, response('modality')); + rqf.addField({ name: 'filter', field: false, @@ -368,7 +379,7 @@ rqf.addField({ name: 'income_range', table: 'pnad_novo', tableField: 'faixa_rendimento', - resultField: 'income_range', + resultField: 'income_range_id', where: { relation: '=', type: 'integer',