Skip to content

Commit

Permalink
works on RED-15 / RED-82
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed May 18, 2024
1 parent 8821815 commit b6963e0
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 44 deletions.
51 changes: 45 additions & 6 deletions service-node-koa/app/services/dashboard.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,30 @@ export const getDashboard = async ({ usuario_id, inicio, fim }) => {
composicaoReceitas: unwrap(await composicaoReceitas({ usuario_id, inicio, fim })),
saldos: await saldos({ usuario_id, inicio, fim }),
vencimentos: unwrap(await vencimentos({ usuario_id, inicio, fim })),
limites: [],
limites: [
{
name: 'name',
series: [1, 2, 3, 4, 4],
color: '#6376DD',
type: 'line',
shape: 'circle',
useArea: true,
useProgression: true,
dataLabels: true,
smooth: true,
useTag: 'none'
},
{
name: 'name',
series: [3, 3, 3, 3, 3],
color: '#d24141',
type: 'line',
shape: 'square',
dataLabels: true,
smooth: true,
useTag: 'none'
}
],
planejamentos: []
}
}
Expand Down Expand Up @@ -209,13 +232,13 @@ async function vencimentos({ usuario_id, inicio, fim }) {
where conta_id in (select id from conta where usuario_id = :usuario_id)
and vencimento between :inicio and :fim),
em_atraso as (select count(*) as contas
from data_frame
where efetivada is null
and vencimento <= CURRENT_TIMESTAMP),
a_vencer as (select count(*) as contas
from data_frame
where efetivada is null
and vencimento <= CURRENT_TIMESTAMP),
a_vencer as (select count(*) as contas
from data_frame
where efetivada is null
and vencimento >= CURRENT_TIMESTAMP),
and vencimento >= CURRENT_TIMESTAMP),
quitadas as (select count(*) as contas
from data_frame
where efetivada is not null)
Expand All @@ -227,6 +250,22 @@ async function vencimentos({ usuario_id, inicio, fim }) {
return result
}

async function limites({ usuario_id, inicio, fim }) {
return knex.raw(`
select c.descricao as label,
m.vencimento as vencimento,
c.cor as color,
(m.valor * (case m.tipo_movimentacao_id when 1 then 1 when 2 then -1 else 1 end)) as value,
c.limite as redline
from conta c
join movimentacao m on c.id = m.conta_id
where m.vencimento between :inicio and :fim
and c.usuario_id = :usuario_id
and c.tipo_conta_id in (2, 3)
`, { usuario_id, inicio, fim })
}

/**
* knex.raw behaves differently when on sqlite or postgres
*
Expand Down
8 changes: 4 additions & 4 deletions web-app-vue/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web-app-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"vue": "^3.4.27",
"vue-data-ui": "^2.1.64",
"vue-router": "^4.3.0",
"vuetify": "^3.5.17"
"vuetify": "^3.6.6"
},
"devDependencies": {
"@mdi/font": "^7.2.96",
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/src/pages/conta/detalhe-conta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
:rules="[numberRule]"
type="number"
v-model="contaEdit.limite"
label="Limite"
:label="contaEdit.tipo_conta_id == 2 ? 'Cheque especial' : 'Limite' "
prepend-inner-icon="mdi-cash-100"
></v-text-field>
<v-container>
Expand Down
35 changes: 5 additions & 30 deletions web-app-vue/src/pages/dashboard/controles-dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<!-- situação dos limites (linhas no plano com a REDLINE do limite da conta / cartão)-->
<v-expansion-panel-title>Limites</v-expansion-panel-title>
<v-expansion-panel-text>
<VueDataUi component="VueUiXy" :config="lineChartConfig" :dataset="dataset" />
<VueDataUi component="VueUiXy" :config="lineChartConfig" :dataset="limites" />
</v-expansion-panel-text>
</v-expansion-panel>
<v-expansion-panel value="planejamentos">
Expand All @@ -179,7 +179,7 @@
<style scoped></style>
<script setup>
import { endOfMonth, startOfMonth } from 'date-fns'
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { VueDataUi } from 'vue-data-ui'
import ChipPeriodo from '@/pages/shared/chip-periodo.vue'
import { useDashboardStore } from '@/stores/dashboardStore'
Expand Down Expand Up @@ -301,34 +301,9 @@ const planejamentos = computed(() => {
return dashboardState.store.dashboard?.planejamentos
})
const dataset = ref([
{
name: 'name',
series: [1, 2, 3, 4, 4],
color: '#6376DD',
type: 'line',
shape: 'circle',
useArea: true,
useProgression: true,
dataLabels: true,
smooth: true,
dashed: false,
useTag: 'none'
},
{
name: 'name',
series: [3, 3, 3, 3, 3],
color: '#d24141',
type: 'line',
shape: 'circle',
useArea: false,
useProgression: false,
dataLabels: true,
smooth: true,
dashed: false,
useTag: 'none'
}
])
watch([inicio, fim], async ([inicio, fim]) => {
await dashboardState.sincronizarDashboard(inicio, fim)
})
onMounted(async () => {
await dashboardState.sincronizarDashboard(inicio.value, fim.value)
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/src/services/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NovaMovimentacaoPage from '@/pages/movimentacao/nova-movimentacao-page.vu
import CategoriasPage from '@/pages/categoria/categorias-page.vue'
import ConfigPage from '@/pages/configuracao/config-page.vue'
// import DashboardPage from "@/pages/dashboard/dashboard-page.vue"
const DashboardPage = import("@/pages/dashboard/dashboard-page.vue")
const DashboardPage = () => import("@/pages/dashboard/dashboard-page.vue")
import PlanejamentoPage from '@/pages/planejamento/planejamento-page.vue'
import RecorrenciasPage from '@/pages/recorrencia/recorrencias-page.vue'
import ContasPage from '@/pages/conta/contas-page.vue'
Expand Down
7 changes: 6 additions & 1 deletion web-app-vue/src/stores/dashboardStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ export const useDashboardStore = defineStore('dashboard-store', () => {

const store = reactive({
dashboard: getRedLine()?.dashboard || {
composicaoDespesas: [],
composicaoReceitas: [],
despesaCategoria: [],
despesaConta: [],
limites: [],
receitaDespesaTotalPeriodo: [],
receitaDespesaEfetivadaPeriodo: [],
saldos: {},
vencimentos:{}
vencimentos: {}
}
})

Expand Down

0 comments on commit b6963e0

Please sign in to comment.