Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed Mar 23, 2024
1 parent 9fe979c commit a7b2479
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 34 deletions.
1 change: 1 addition & 0 deletions service-node-koa/app/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ new ApiBuilder({router}).path(b => {
b.get(findRecorrenciaRequest)
b.put(updateRecorrenciaRequest)
b.del(delRecorrenciaRequest)
b.get("/lancamentos", ctx => ctx.body = "TBD")
})
});
});
Expand Down
2 changes: 1 addition & 1 deletion web-app-vue/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.5">
<title>Redline Finance</title>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions web-app-vue/src/components/categoria/lista-categorias.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ const salvar = async (categoria) => {
await cState.sincronizarCategorias()
}
onMounted(() => {
cState.sincronizarCategorias()
onMounted(async () => {
await cState.sincronizarCategorias()
})
</script>
<style scoped></style>
2 changes: 1 addition & 1 deletion web-app-vue/src/components/conta/detalhe-conta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
prepend-inner-icon="mdi-calendar-alert"
></v-text-field>
<v-text-field
v-if="contaEdit.tipo_conta_id == 3"
v-if="contaEdit.tipo_conta_id == 3 || contaEdit.tipo_conta_id == 2"
:rules="[numberRule]"
type="number"
v-model="contaEdit.limite"
Expand Down
16 changes: 8 additions & 8 deletions web-app-vue/src/components/conta/lista-contas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ const contas = computed(() =>
})
)
onMounted(() => {
cState.sincronizarContas()
onMounted(async () => {
await cState.sincronizarContas()
})
const saveConta = (conta) => {
cState.salvarConta(conta)
cState.sincronizarContas()
const saveConta = async (conta) => {
await cState.salvarConta(conta)
await cState.sincronizarContas()
}
const removeConta = (conta) => {
if (confirm('confirmar deletar conta?')) cState.removeConta(conta)
cState.sincronizarContas()
const removeConta = async (conta) => {
if (confirm('confirmar deletar conta?')) await cState.removeConta(conta)
await cState.sincronizarContas()
}
</script>
14 changes: 6 additions & 8 deletions web-app-vue/src/components/recorrencia/detalhe-recorrencia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,12 @@ const reset = () => ({
const rec = reactive(reset())
const parcelas = computed({
get() {
if (rec.tipo_recorrencia_id == 1)
return 1 + differenceInMonths(prepareDate(rec.final), prepareDate(rec.inicial)) // mensal
else if (rec.tipo_recorrencia_id == 2)
return 1 + differenceInYears(prepareDate(rec.final), prepareDate(rec.inicial)) // anual
else return 1 + differenceInDays(prepareDate(rec.final), prepareDate(rec.inicial)) // diária
}
const parcelas = computed(() => {
if (rec.tipo_recorrencia_id == 1)
return 1 + differenceInMonths(prepareDate(rec.final), prepareDate(rec.inicial)) // mensal
else if (rec.tipo_recorrencia_id == 2)
return 1 + differenceInYears(prepareDate(rec.final), prepareDate(rec.inicial)) // anual
else return 1 + differenceInDays(prepareDate(rec.final), prepareDate(rec.inicial)) // diária
})
const categoria = computed(() => {
Expand Down
3 changes: 3 additions & 0 deletions web-app-vue/src/components/recorrencia/list-recorrencia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const recorrencias = computed(() => {
const doSave = async (rec) => {
await recorrenciaStore.salvarRecorrencia(rec)
if(rec.id && confirm("deseja gerar os lançamentos da recorrência novamente?")) {
await recorrenciaStore.gerarLancamentos(rec)
}
}
const doDel = async (rec) => {
Expand Down
25 changes: 14 additions & 11 deletions web-app-vue/src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ export const delCategoria = async ({ id, categoria }) =>
export const lisTiposMovimentacao = async () => await get({ uri: '/tipo-movimentacao' })

export const listMovimentacoes = async ({
tipo_movimentacao_id = undefined,
categoria_id = undefined,
dataInicio = undefined,
conta_id = undefined,
dataFim = undefined,
efetivada = undefined,
offset = 0,
limit = 50,
id,
q = ''
}) =>
tipo_movimentacao_id = undefined,
categoria_id = undefined,
dataInicio = undefined,
conta_id = undefined,
dataFim = undefined,
efetivada = undefined,
offset = 0,
limit = 50,
id,
q = ''
}) =>
await get({
uri: uriParams({
uri: `/${id}/movimentacao`,
Expand Down Expand Up @@ -182,3 +182,6 @@ export const findRecorrencia = async ({ id, recorrencia_id }) =>

export const delRecorrencia = async ({ id, recorrencia_id }) =>
await del({ uri: `/${id}/recorrencia/${recorrencia_id}` })

export const geraLancamentosRecorrencia = async ({ id, recorrencia_id }) =>
await get({ uri: `/${id}/recorrencia/${recorrencia_id}/lancamentos` })
12 changes: 9 additions & 3 deletions web-app-vue/src/stores/recorrenciaStore.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineStore } from 'pinia'
import { reactive } from 'vue'
import { useUserStore } from '@/stores/userStore'
import {getRedLine, setRedLine} from '@/services/redLine'
import { getRedLine, setRedLine } from '@/services/redLine'
import {
delRecorrencia,
delRecorrencia, geraLancamentosRecorrencia,
insertRecorrencia,
listRecorrencias,
listTiposRecorrencia,
Expand Down Expand Up @@ -50,5 +50,11 @@ export const useRecorrenciaStore = defineStore('recorrencia-store', () => {
await sincronizarRecorrencia()
}

return { store, sincronizarRecorrencia, salvarRecorrencia, excluirRecorrencia }
const gerarLancamentos = async (recorrencia) => {
const { id } = uState.userData
await geraLancamentosRecorrencia({ id, recorrencia_id: recorrencia.id })
console.log(recorrencia)
}

return { store, sincronizarRecorrencia, salvarRecorrencia, excluirRecorrencia, gerarLancamentos }
})

0 comments on commit a7b2479

Please sign in to comment.