Skip to content

Commit

Permalink
RED-85 resolvido bug introduzido pelas transferências internas
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed Jun 9, 2024
1 parent 74887d0 commit e0bde0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 10 additions & 9 deletions service-node-koa/app/services/dashboard.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })),
Expand All @@ -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 }) {
Expand All @@ -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 })
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions web-app-vue/src/stores/dashboardStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export const useDashboardStore = defineStore('dashboard-store', () => {
composicaoDespesas: [],
composicaoReceitas: [],
despesaCategoria: [],
receitaCategoria: [],
despesaConta: [],
receitaConta: [],
limites: [],
receitaDespesaTotalPeriodo: [],
receitaDespesaEfetivadaPeriodo: [],
Expand Down

0 comments on commit e0bde0e

Please sign in to comment.