Skip to content
Snippets Groups Projects
Commit 07d44110 authored by Fernando Gbur dos Santos's avatar Fernando Gbur dos Santos
Browse files

Merge branch 'es23-superior-education-conclusion-tax' into 'development'

FIX - superior education conclusion tax

See merge request !475
parents 349c9c24 65880022
No related branches found
No related tags found
2 merge requests!476dev -> homologa,!475FIX - superior education conclusion tax
......@@ -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';
......
......@@ -111,7 +111,7 @@ superiorEducationConclusionTaxApp.get('/region', (req, res, next) => {
next();
}, response('region'));
superiorEducationConclusionTaxApp.get('/cap_code', (req, res, next) => {
superiorEducationConclusionTaxApp.get('/cap_code_pnad', (req, res, next) => {
req.result = []
for (let i = 11; i < 54; i++) {
if (id2str.capitalCode(i) !== 'Não informado') {
......@@ -120,10 +120,8 @@ superiorEducationConclusionTaxApp.get('/cap_code', (req, res, next) => {
});
}
}
req.result.push({id: 99, name: id2str.capitalCode(99)});
next();
}, response('cap_code'));
}, response('cap_code_pnad'));
superiorEducationConclusionTaxApp.get('/metro_code', (req, res, next) => {
req.result = []
......@@ -134,7 +132,6 @@ superiorEducationConclusionTaxApp.get('/metro_code', (req, res, next) => {
});
}
}
req.result.push({id: 99, name: id2str.metroCode(99)});
next();
}, response('metro_code'));
......@@ -160,6 +157,7 @@ superiorEducationConclusionTaxApp.get('/income_range', (req, res, next) => {
});
}
req.result.push({id: 10, name: id2str.incomeRange(10)});
next();
}, response('income_range'));
......@@ -242,16 +240,17 @@ superiorEducationConclusionTaxApp.get('/state', (req, res, next) => {
next();
}, response('state'));
superiorEducationConclusionTaxApp.get('/age_range', (req, res, next) => {
superiorEducationConclusionTaxApp.get('/age_range_all', (req, res, next) => {
req.result = []
for (let i = 1; i < 12; i++) {
for (let i = 7; i < 12; i++) {
req.result.push({
id: i, name: id2str.ageRangeAll(i)
});
}
console.log(req.result);
next();
}, response('age_range'));
}, response('age_range_all'));
superiorEducationConclusionTaxApp.get('/location', (req, res, next) => {
req.result = []
......@@ -444,10 +443,10 @@ rqf.addField({
field: 'sexo'
}
}).addValue({
name: 'cap_code',
name: 'cap_code_pnad',
table: 'pnad_novo',
tableField: 'cod_cap',
resultField: 'cap_code_id',
resultField: 'cap_code_pnad_id',
where: {
relation: '=',
type: 'integer',
......@@ -575,9 +574,28 @@ function matchQueries(queryPartial, queryTotal) {
return match;
}
function whereCondition(req) {
let where = "";
let filterId;
//const filters = req.query.filter.split(",");
const dims = req.query.dims;
if (dims && dims.includes("cap_code_pnad")){
where += `pnad_novo.cod_cap <> 99`;
}
if (dims && dims.includes("income_range")){
where += `pnad_novo.faixa_rendimento_aux_tx is not null`;
}
if (dims && dims.includes("age_range_superior")){
where += `pnad_novo.faixa_etaria > 6`;
}
return where;
}
superiorEducationConclusionTaxApp.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 totalPopMaior25ComSuperiorCompleto = req.sql.clone();
totalPopMaior25ComSuperiorCompleto.from("pnad_novo")
......@@ -586,9 +604,10 @@ superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res,
.where("idade_morador_31_03 >= 25")
.where("nivel_de_instruc_mais_elevad_para_o_fundam_com_duracao_9_anos = 7")
.where("ano_ref >= 2019")
.where(`${where}`)
.group("ano_ref")
.order("ano_ref");
// Subquery para total_pop_maior_25 com filtros dinâmicos
let totalPopMaior25 = req.sql.clone();
......@@ -597,14 +616,10 @@ superiorEducationConclusionTaxApp.get('/', rqf.parse(), rqf.build(), (req, res,
.field("SUM(peso_domicilio_pessoas_com_cal)", "total")
.where("idade_morador_31_03 >= 25")
.where("ano_ref >= 2019")
.where(`${where}`)
.group("ano_ref")
.order("ano_ref");
// if (req.query.dims && req.query.dims.includes("income_range")) {
// totalPopMaior19.where("faixa_rendimento_aux_tx is not null");
// totalPopEdBasMaior19.where("faixa_rendimento_aux_tx is not null");
// }
req.querySet.push(totalPopMaior25ComSuperiorCompleto);
req.querySet.push(totalPopMaior25);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment