From e0bde0ef1a8077b31474de04dbde24d806c4b98b Mon Sep 17 00:00:00 2001 From: Leonardo Silveira Date: Sun, 9 Jun 2024 10:41:48 -0300 Subject: [PATCH] =?UTF-8?q?RED-85=20resolvido=20bug=20introduzido=20pelas?= =?UTF-8?q?=20transfer=C3=AAncias=20internas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service-node-koa/app/services/dashboard.mjs | 19 ++++++++++--------- web-app-vue/src/stores/dashboardStore.js | 2 ++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/service-node-koa/app/services/dashboard.mjs b/service-node-koa/app/services/dashboard.mjs index f7d3eb6..3893ee9 100644 --- a/service-node-koa/app/services/dashboard.mjs +++ b/service-node-koa/app/services/dashboard.mjs @@ -5,7 +5,7 @@ import { addMonths, addYears } from 'date-fns' export const getDashboard = async ({ usuario_id, inicio, fim }) => { inicio = new Date(inicio).toISOString() fim = new Date(fim).toISOString() - return { + const result = { receitaDespesaTotalPeriodo: unwrap(await receitaDespesaTotalPeriodo({ usuario_id, inicio, fim })), receitaDespesaEfetivadaPeriodo: unwrap(await receitaDespesaEfetivadaPeriodo({ usuario_id, inicio, fim })), despesaConta: unwrap(await despesaConta({ usuario_id, inicio, fim })), @@ -19,6 +19,7 @@ export const getDashboard = async ({ usuario_id, inicio, fim }) => { limites: unwrap(await limites({ usuario_id, inicio, fim })), planejamentos: unwrap(await planejamentos({ usuario_id, inicio, fim })) } + return result } async function receitaDespesaTotalPeriodo({ usuario_id, inicio, fim }) { @@ -27,12 +28,12 @@ async function receitaDespesaTotalPeriodo({ usuario_id, inicio, fim }) { from movimentacao where conta_id in (select id from conta where usuario_id = :usuario_id) and vencimento between :inicio and :fim - and interna <> true) - select 'Receita total' as label, sum(valor) as value, 'lightgreen' as color + and interna is not true) + select 'Receita total' as label, coalesce(sum(valor),0) as value, 'lightgreen' as color from data_frame where tipo_movimentacao_id = 1 union - select 'Despesa total' as label, sum(valor) as value, 'red' as color + select 'Despesa total' as label, coalesce(sum(valor),0) as value, 'red' as color from data_frame where tipo_movimentacao_id = 2 `, { usuario_id, inicio, fim }) @@ -45,7 +46,7 @@ async function receitaDespesaEfetivadaPeriodo({ usuario_id, inicio, fim }) { where conta_id in (select id from conta where usuario_id = :usuario_id) and vencimento between :inicio and :fim and efetivada is not null - and interna <> true) + and interna is not true) select 'Receita efetivada' as label, sum(valor) as value, 'lightgreen' as color from data_frame where tipo_movimentacao_id = 1 @@ -64,7 +65,7 @@ async function despesaConta({ usuario_id, inicio, fim }) { join movimentacao on conta.id = movimentacao.conta_id where usuario_id = :usuario_id and tipo_movimentacao_id = 2 - and interna <> true + and interna is not true and vencimento between :inicio and :fim) select descricao as label, cor as color, @@ -81,7 +82,7 @@ async function despesaCategoria({ usuario_id, inicio, fim }) { left join categoria on categoria.id = movimentacao.categoria_id where usuario_id = :usuario_id and tipo_movimentacao_id = 2 - and interna <> true + and interna is not true and vencimento between :inicio and :fim) select descricao as label, cor as color, @@ -99,7 +100,7 @@ async function receitaConta({ usuario_id, inicio, fim }) { join movimentacao on conta.id = movimentacao.conta_id where usuario_id = :usuario_id and tipo_movimentacao_id = 1 - and interna <> true + and interna is not true and vencimento between :inicio and :fim) select descricao as label, cor as color, @@ -116,7 +117,7 @@ async function receitaCategoria({ usuario_id, inicio, fim }) { left join categoria on categoria.id = movimentacao.categoria_id where usuario_id = :usuario_id and tipo_movimentacao_id = 1 - and interna <> true + and interna is not true and vencimento between :inicio and :fim) select descricao as label, cor as color, diff --git a/web-app-vue/src/stores/dashboardStore.js b/web-app-vue/src/stores/dashboardStore.js index 4212166..1d95101 100644 --- a/web-app-vue/src/stores/dashboardStore.js +++ b/web-app-vue/src/stores/dashboardStore.js @@ -12,7 +12,9 @@ export const useDashboardStore = defineStore('dashboard-store', () => { composicaoDespesas: [], composicaoReceitas: [], despesaCategoria: [], + receitaCategoria: [], despesaConta: [], + receitaConta: [], limites: [], receitaDespesaTotalPeriodo: [], receitaDespesaEfetivadaPeriodo: [],