Skip to content

Commit

Permalink
fix: fixed wrong json return from sefaz ncm api
Browse files Browse the repository at this point in the history
fix #583
  • Loading branch information
LucasAlencarCosta committed Feb 19, 2024
1 parent aa3ae93 commit 8d027b7
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions services/sefaz/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,28 @@ function parseObject(obj) {
return newDate.toISOString().slice(0, 10);
};

const newObj = Object.fromEntries(
const convertKeysToLowerCase = Object.fromEntries(
Object.entries(obj).map(([k, v]) => [k.toLowerCase(), v])
);
newObj.data_fim = formatDate(newObj.data_fim);
newObj.data_inicio = formatDate(newObj.data_inicio);

const {
tipo_ato_ini: tipoAtoIni,
numero_ato_ini: numeroAtoIni,
ano_ato_ini: anoAtoIni,
data_inicio: dataInicio,
data_fim: dataFim,
...rest
} = convertKeysToLowerCase;

const newObj = {
...rest,
data_inicio: formatDate(dataInicio),
data_fim: formatDate(dataFim),
tipo_ato: tipoAtoIni,
numero_ato: numeroAtoIni,
ano_ato: anoAtoIni,
};

return newObj;
}

Expand Down

0 comments on commit 8d027b7

Please sign in to comment.