diff --git a/database/model/transaction.go b/database/model/transaction.go index 2ab9a57..59f8d2c 100644 --- a/database/model/transaction.go +++ b/database/model/transaction.go @@ -5,6 +5,7 @@ import ( "encoding/csv" "encoding/hex" "errors" + "fmt" "io/ioutil" "regexp" "strconv" @@ -99,6 +100,10 @@ func (t *Transaction) MatchRule(rule CategoryRule) (bool, int) { } } + if match { + fmt.Printf("%+v\n", match) + } + return match, counter } diff --git a/frontend/js/App.vue b/frontend/js/App.vue index 3b9c9e1..ed68623 100644 --- a/frontend/js/App.vue +++ b/frontend/js/App.vue @@ -41,7 +41,7 @@ import {BNavItem} from 'bootstrap-vue-next' class="me-2" :class="route.meta.icon" > - {{ route.name }} + {{ route.meta.label }} diff --git a/frontend/js/components/crud/DataList.vue b/frontend/js/components/crud/DataList.vue new file mode 100644 index 0000000..8376cce --- /dev/null +++ b/frontend/js/components/crud/DataList.vue @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/js/components/crud/FormView.vue b/frontend/js/components/crud/FormView.vue new file mode 100644 index 0000000..64df27b --- /dev/null +++ b/frontend/js/components/crud/FormView.vue @@ -0,0 +1,28 @@ + + + + + + + diff --git a/frontend/js/components/crud/FormWidget.vue b/frontend/js/components/crud/FormWidget.vue new file mode 100644 index 0000000..11d06ec --- /dev/null +++ b/frontend/js/components/crud/FormWidget.vue @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/js/components/crud/Header.vue b/frontend/js/components/crud/Header.vue index 74daf36..5149be5 100644 --- a/frontend/js/components/crud/Header.vue +++ b/frontend/js/components/crud/Header.vue @@ -1,6 +1,6 @@ - + {{ title }} @@ -15,3 +15,13 @@ import {defineProps} from 'vue' defineProps(['title']) + + diff --git a/frontend/js/router/index.js b/frontend/js/router/index.js index 3c39232..07da0f8 100644 --- a/frontend/js/router/index.js +++ b/frontend/js/router/index.js @@ -5,44 +5,116 @@ const router = createRouter({ routes: [ { path: '/', - name: 'Tableau de bord', - meta: {icon: ['fa-solid', 'fa-chart-line']}, + name: 'dashboard', + meta: {label: 'Tableau de bord', icon: ['fa-solid', 'fa-chart-line']}, component: () => import('../views/DashboardView.vue'), }, { path: '/transactions', - name: 'Transactions', - meta: {icon: ['fa-solid', 'fa-money-bill-transfer']}, - component: () => import('../views/TransactionsView.vue'), + name: 'transactions', + meta: {label: 'Transactions', icon: ['fa-solid', 'fa-money-bill-transfer']}, + component: () => import('../views/transaction/ListView.vue'), }, { path: '/users', - name: 'Utilisateurs', - meta: {icon: ['fa-solid', 'fa-users']}, - component: () => import('../views/UsersView.vue'), + component: () => import('../views/ComponentView.vue'), + children: [ + { + path: '', + name: 'users', + meta: {label: 'Utilisateurs', icon: ['fa-solid', 'fa-users']}, + component: () => import('../views/user/ListView.vue'), + }, + { + path: '/user/edit/:id', + name: 'user_edit', + meta: {label: 'Utilisateur'}, + component: () => import('../views/user/EditView.vue'), + }, + { + path: '/user/create', + name: 'user_create', + meta: {label: 'Nouvel utilisateur'}, + component: () => import('../views/user/CreateView.vue'), + }, + ] }, { path: '/categories', - name: 'Catégories', - meta: {icon: ['fa-solid', 'fa-list']}, - component: () => import('../views/CategoriesView.vue'), + component: () => import('../views/ComponentView.vue'), + children: [ + { + path: '', + name: 'categories', + meta: {label: 'Catégories', icon: ['fa-solid', 'fa-list']}, + component: () => import('../views/category/ListView.vue'), + }, + { + path: '/category/edit/:id', + name: 'category_edit', + meta: {label: 'Catégorie'}, + component: () => import('../views/category/EditView.vue'), + }, + { + path: '/category/create', + name: 'category_create', + meta: {label: 'Nouvelle catégorie'}, + component: () => import('../views/category/CreateView.vue'), + }, + ] }, { path: '/bank_accounts', - name: 'Comptes bancaires', - meta: {icon: ['fa-solid', 'fa-piggy-bank']}, - component: () => import('../views/BankAccountsView.vue'), + component: () => import('../views/ComponentView.vue'), + children: [ + { + path: '', + name: 'bank_accounts', + meta: {label: 'Comptes bancaires', icon: ['fa-solid', 'fa-piggy-bank']}, + component: () => import('../views/bank_account/ListView.vue'), + }, + { + path: '/bank_account/edit/:id', + name: 'bank_account_edit', + meta: {label: 'Compte bancaire'}, + component: () => import('../views/bank_account/EditView.vue'), + }, + { + path: '/bank_account/create', + name: 'bank_account_create', + meta: {label: 'Nouveau compte bancaire'}, + component: () => import('../views/bank_account/CreateView.vue'), + }, + ] }, { path: '/saving_accounts', - name: 'Comptes épargnes', - meta: {icon: ['fa-solid', 'fa-piggy-bank']}, - component: () => import('../views/SavingAccountsView.vue'), + component: () => import('../views/ComponentView.vue'), + children: [ + { + path: '', + name: 'saving_accounts', + meta: {label: 'Comptes épargnes', icon: ['fa-solid', 'fa-piggy-bank']}, + component: () => import('../views/saving_account/ListView.vue'), + }, + { + path: '/saving_account/edit/:id', + name: 'saving_account_edit', + meta: {label: 'Compte bancaire'}, + component: () => import('../views/saving_account/EditView.vue'), + }, + { + path: '/saving_account/create', + name: 'saving_account_create', + meta: {label: 'Nouveau compte épargne'}, + component: () => import('../views/saving_account/CreateView.vue'), + }, + ] }, { path: '/files', - name: 'Fichiers', - meta: {icon: ['fa-solid', 'fa-table']}, + name: 'files', + meta: {label: 'Fichiers', icon: ['fa-solid', 'fa-table']}, component: () => import('../views/FilesView.vue'), }, ], diff --git a/frontend/js/views/BankAccountsView.vue b/frontend/js/views/BankAccountsView.vue deleted file mode 100644 index 0867e2f..0000000 --- a/frontend/js/views/BankAccountsView.vue +++ /dev/null @@ -1,319 +0,0 @@ - - - - - - Ajouter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Supprimer - - - Annuler - OK - - - - - - - diff --git a/frontend/js/views/CategoriesView.vue b/frontend/js/views/CategoriesView.vue deleted file mode 100644 index 8de39d8..0000000 --- a/frontend/js/views/CategoriesView.vue +++ /dev/null @@ -1,648 +0,0 @@ - - - - - - - - Appliquer les règles - - Ajouter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Ajouter règle - - Supprimer - - - Annuler - OK - - - - - - - diff --git a/frontend/js/views/ComponentView.vue b/frontend/js/views/ComponentView.vue new file mode 100644 index 0000000..98240ae --- /dev/null +++ b/frontend/js/views/ComponentView.vue @@ -0,0 +1,3 @@ + + + diff --git a/frontend/js/views/SavingAccountsView.vue b/frontend/js/views/SavingAccountsView.vue deleted file mode 100644 index 68d8770..0000000 --- a/frontend/js/views/SavingAccountsView.vue +++ /dev/null @@ -1,369 +0,0 @@ - - - - - - Ajouter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Supprimer - - - Annuler - OK - - - - - - - diff --git a/frontend/js/views/UsersView.vue b/frontend/js/views/UsersView.vue deleted file mode 100644 index 8c0c6d1..0000000 --- a/frontend/js/views/UsersView.vue +++ /dev/null @@ -1,352 +0,0 @@ - - - - - - Ajouter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Supprimer - - - Annuler - OK - - - - - - - diff --git a/frontend/js/views/bank_account/CreateView.vue b/frontend/js/views/bank_account/CreateView.vue new file mode 100644 index 0000000..1686848 --- /dev/null +++ b/frontend/js/views/bank_account/CreateView.vue @@ -0,0 +1,122 @@ + + + + + + Retour + Enregistrer + + + + + + + + + {{ form.error }} + + + + + + + + + + + diff --git a/frontend/js/views/bank_account/EditView.vue b/frontend/js/views/bank_account/EditView.vue new file mode 100644 index 0000000..489c398 --- /dev/null +++ b/frontend/js/views/bank_account/EditView.vue @@ -0,0 +1,156 @@ + + + Chargement... + + + + + + + Retour + Enregistrer + Supprimer + + + + + + + + + {{ form.error }} + + + + + + + + + + + diff --git a/frontend/js/views/bank_account/ListView.vue b/frontend/js/views/bank_account/ListView.vue new file mode 100644 index 0000000..256e3ec --- /dev/null +++ b/frontend/js/views/bank_account/ListView.vue @@ -0,0 +1,125 @@ + + + + + + Ajouter + + + + + + + + + + + + + + diff --git a/frontend/js/views/category/CreateView.vue b/frontend/js/views/category/CreateView.vue new file mode 100644 index 0000000..8edb7e4 --- /dev/null +++ b/frontend/js/views/category/CreateView.vue @@ -0,0 +1,173 @@ + + + + + + Retour + Enregistrer + + + + + + + + + {{ form.error }} + + + + + + + + + + + diff --git a/frontend/js/views/category/EditView.vue b/frontend/js/views/category/EditView.vue new file mode 100644 index 0000000..99f2dba --- /dev/null +++ b/frontend/js/views/category/EditView.vue @@ -0,0 +1,300 @@ + + + Chargement... + + + + + + + Retour + Ajouter règle + Enregistrer + Supprimer + + + + + + + + + {{ form.error }} + + + + + + + + + + + + + + + + + + diff --git a/frontend/js/views/category/ListView.vue b/frontend/js/views/category/ListView.vue new file mode 100644 index 0000000..3f7ed29 --- /dev/null +++ b/frontend/js/views/category/ListView.vue @@ -0,0 +1,156 @@ + + + + + + + + Appliquer les règles + + Ajouter + + + + + + + + + + + + + + diff --git a/frontend/js/views/saving_account/CreateView.vue b/frontend/js/views/saving_account/CreateView.vue new file mode 100644 index 0000000..f5706f0 --- /dev/null +++ b/frontend/js/views/saving_account/CreateView.vue @@ -0,0 +1,132 @@ + + + + + + Retour + Enregistrer + + + + + + + + + {{ form.error }} + + + + + + + + + + + diff --git a/frontend/js/views/saving_account/EditView.vue b/frontend/js/views/saving_account/EditView.vue new file mode 100644 index 0000000..7c3eb15 --- /dev/null +++ b/frontend/js/views/saving_account/EditView.vue @@ -0,0 +1,166 @@ + + + Chargement... + + + + + + + Retour + Enregistrer + Supprimer + + + + + + + + + {{ form.error }} + + + + + + + + + + + diff --git a/frontend/js/views/saving_account/ListView.vue b/frontend/js/views/saving_account/ListView.vue new file mode 100644 index 0000000..642ff5d --- /dev/null +++ b/frontend/js/views/saving_account/ListView.vue @@ -0,0 +1,125 @@ + + + + + + Ajouter + + + + + + + + + + + + + + diff --git a/frontend/js/views/TransactionsView.vue b/frontend/js/views/transaction/ListView.vue similarity index 61% rename from frontend/js/views/TransactionsView.vue rename to frontend/js/views/transaction/ListView.vue index 43cea1f..63e63c1 100644 --- a/frontend/js/views/TransactionsView.vue +++ b/frontend/js/views/transaction/ListView.vue @@ -3,7 +3,7 @@ fluid class="p-0" > - + - - + - - - - - - - - - - - - - - - - - - - - - - + - - - Libellé - {{ info.label }} - - - Libellé simplifié - {{ info.short_label }} - - - Référence - {{ info.reference }} - - - Informations - {{ info.information }} - - - Type d'opération - {{ info.operation_type }} - - - Débit - {{ info.debit }} - - - Crédit - {{ info.credit }} - - - Date - {{ renderDate(info.date) }} - - - Comptabilisée le - {{ renderDate(info.accounted_at) }} - - - Catégorie banque{{ info.bank_category }} - - - Sous-catégorie banque - {{ info.bank_sub_category }} - - - Catégorie - - - + @@ -168,6 +59,7 @@ + - - - - - - - + @@ -230,6 +91,19 @@ + + + + @@ -253,22 +127,24 @@ import { BFormFile, } from 'bootstrap-vue-next' -import SortButton from './../components/SortButton.vue' -import Filters from './../components/Filters.vue' -import Header from './../components/crud/Header.vue' -import Pager from './../components/crud/Pager.vue' +import Header from '../../components/crud/Header.vue' +import Filters from '../../components/Filters.vue' +import Pager from '../../components/crud/Pager.vue' +import FormView from '../../components/crud/FormView.vue' +import ShowView from './ShowView.vue' +import DataList from '../../components/crud/DataList.vue' import {ref, onMounted, watch} from 'vue' -import {getStorage, saveStorage} from '../lib/storage' +import {getStorage, saveStorage} from '../../lib/storage' +import {createRequestOptions} from '../../lib/request' +import {useRouter, useRoute} from 'vue-router' +import {queryFilters, appendRequestQueryFilters} from '../../lib/filter' import { renderDate, renderCategory, renderBankAccount, renderEuro, renderLabelWithSum, -} from '../lib/renderers' -import {queryFilters, appendRequestQueryFilters} from '../lib/filter' -import {useRoute} from 'vue-router' -import {createRequestOptions} from '../lib/request' +} from '../../lib/renderers' const endpoint = `/api/transaction` const order = ref(getStorage(`${endpoint}:order`)) @@ -283,24 +159,13 @@ const infoShow = ref(false) const info = ref(null) const filters = ref(getStorage(`${endpoint}:filters`) ?? []) const filtersShow = ref(false) +const router = useRouter() let route = null -watch(order, (v) => saveStorage(`${endpoint}:order`, v, 'order')) -watch(sort, (v) => saveStorage(`${endpoint}:sort`, v, 'sort')) -watch(page, (v) => saveStorage(`${endpoint}:page`, v, 'page')) -watch(limit, (v) => saveStorage(`${endpoint}:limit`, v, 'limit')) -watch(filters, (v) => saveStorage(`${endpoint}:filters`, v, 'filters')) - -const doInfo = (item) => { - info.value = item - infoShow.value = true -} - -const doUpdateFilters = (a) => { - saveStorage(`${endpoint}:filters`, a, 'filters') - filters.value = a - refresh() -} +watch(order, (v) => saveStorage(`${endpoint}:order`, v)) +watch(sort, (v) => saveStorage(`${endpoint}:sort`, v)) +watch(page, (v) => saveStorage(`${endpoint}:page`, v)) +watch(limit, (v) => saveStorage(`${endpoint}:limit`, v)) const refresh = () => { let query = { @@ -311,9 +176,12 @@ const refresh = () => { limit: limit.value, } - query = appendRequestQueryFilters(query, route) + query = appendRequestQueryFilters(query, endpoint) - fetch(`${endpoint}?${new URLSearchParams(query)}`, createRequestOptions()) + fetch( + `${endpoint}?${new URLSearchParams(query)}`, + createRequestOptions() + ) .then((response) => { return response.json() }) @@ -327,6 +195,31 @@ const refresh = () => { }) } +const doShow = (item) => { + info.value = item + infoShow.value = true +} + +const doUpdateFilters = (a) => { + saveStorage(`${endpoint}:filters`, a, 'filters') + filters.value = a + refresh() +} + +const doSort = (key) => { + let nextSort = 'asc' + + if (order.value === key) { + nextSort = sort.value === 'asc' ? 'desc' : 'asc' + } + + order.value = key + sort.value = nextSort + page.value = 1 + + refresh() +} + const doAdd = () => { const data = {category_id: null, file: null, format: 'caisse_epargne'} @@ -413,20 +306,6 @@ const doSave = (e) => { }) } -const doSort = (key) => { - let nextSort = 'asc' - - if (order.value === key) { - nextSort = sort.value === 'asc' ? 'desc' : 'asc' - } - - order.value = key - sort.value = nextSort - page.value = 1 - - refresh() -} - const filtersFields = ref([ {key: 'label', type: 'string', label: 'Libellé'}, {key: 'debit', type: 'number', label: 'Débit'}, @@ -519,11 +398,5 @@ onMounted(() => { }) }) }) - - + diff --git a/frontend/js/views/transaction/ShowView.vue b/frontend/js/views/transaction/ShowView.vue new file mode 100644 index 0000000..a39383f --- /dev/null +++ b/frontend/js/views/transaction/ShowView.vue @@ -0,0 +1,73 @@ + + + + Libellé + {{ transaction.label }} + + + Libellé simplifié + {{ transaction.short_label }} + + + Référence + {{ transaction.reference }} + + + Informations + {{ transaction.transactionrmation }} + + + Type d'opération + {{ transaction.operation_type }} + + + Débit + {{ transaction.debit }} + + + Crédit + {{ transaction.credit }} + + + Date + {{ renderDate(transaction.date) }} + + + Comptabilisée le + {{ renderDate(transaction.accounted_at) }} + + + Catégorie banque{{ transaction.bank_category }} + + + Sous-catégorie banque + {{ transaction.bank_sub_category }} + + + Catégorie + + + + + + diff --git a/frontend/js/views/user/CreateView.vue b/frontend/js/views/user/CreateView.vue new file mode 100644 index 0000000..5e37690 --- /dev/null +++ b/frontend/js/views/user/CreateView.vue @@ -0,0 +1,125 @@ + + + + + + Retour + Enregistrer + + + + + + + + + + + + + + + + + diff --git a/frontend/js/views/user/EditView.vue b/frontend/js/views/user/EditView.vue new file mode 100644 index 0000000..4d0ea8e --- /dev/null +++ b/frontend/js/views/user/EditView.vue @@ -0,0 +1,168 @@ + + + Chargement... + + + + + + + Retour + Enregistrer + Supprimer + + + + + + + + + {{ form.error }} + + + + + + + + + + + diff --git a/frontend/js/views/user/ListView.vue b/frontend/js/views/user/ListView.vue new file mode 100644 index 0000000..2ea67ac --- /dev/null +++ b/frontend/js/views/user/ListView.vue @@ -0,0 +1,134 @@ + + + + + + Ajouter + + + + + + + + + + + + + +
Chargement...