diff --git a/.prettierrc.json b/.prettierrc.json index 6e00b35..280fb28 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,5 @@ { - "bracketSpacing": false, + "bracketSpacing": true, "bracketSameLine": false, "semi": false, "singleQuote": true, 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..317c35b 100644 --- a/frontend/js/App.vue +++ b/frontend/js/App.vue @@ -1,6 +1,6 @@ @@ -29,7 +29,7 @@ import {BNavItem} from 'bootstrap-vue-next' '/files', '/users', ]" - v-slot="{href, route, navigate, isActive, isExactActive}" + v-slot="{ href, route, navigate, isActive, isExactActive }" :to="url" custom > @@ -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/chart/capital.js b/frontend/js/chart/capital.js index 91e8cb5..22d92f2 100644 --- a/frontend/js/chart/capital.js +++ b/frontend/js/chart/capital.js @@ -1,4 +1,4 @@ -import {isInRange} from '../lib/dateFilter' +import { isInRange } from '../lib/dateFilter' const getDate = (value, precision) => { const d = new Date(value) @@ -79,4 +79,4 @@ const compute = (transactions, precision, dateFrom, dateTo) => { return config } -export {compute} +export { compute } diff --git a/frontend/js/chart/debitAverage.js b/frontend/js/chart/debitAverage.js index e9cc245..f205cf6 100644 --- a/frontend/js/chart/debitAverage.js +++ b/frontend/js/chart/debitAverage.js @@ -1,4 +1,4 @@ -import {isInRange} from '../lib/dateFilter' +import { isInRange } from '../lib/dateFilter' const getDate = (value) => { const d = new Date(value) @@ -64,7 +64,8 @@ const compute = (transactions, dateFrom, dateTo, order) => { const monthsValues = Object.values(data[i].months) - data[i].monthAverage = monthsValues.reduce((a, b) => a + b, 0) / monthsValues.length + data[i].monthAverage = + monthsValues.reduce((a, b) => a + b, 0) / monthsValues.length } data = Object.values(data).sort((a, b) => { @@ -82,4 +83,4 @@ const compute = (transactions, dateFrom, dateTo, order) => { return data } -export {compute} +export { compute } diff --git a/frontend/js/chart/diffCreditDebit.js b/frontend/js/chart/diffCreditDebit.js index 6cd8fb8..4014313 100644 --- a/frontend/js/chart/diffCreditDebit.js +++ b/frontend/js/chart/diffCreditDebit.js @@ -1,4 +1,4 @@ -import {isInRange} from '../lib/dateFilter' +import { isInRange } from '../lib/dateFilter' const getDate = (value) => { const d = new Date(value) @@ -68,4 +68,4 @@ const compute = (transactions, dateFrom, dateTo) => { return config } -export {compute} +export { compute } diff --git a/frontend/js/chart/distribution.js b/frontend/js/chart/distribution.js index c4b88d7..4a845eb 100644 --- a/frontend/js/chart/distribution.js +++ b/frontend/js/chart/distribution.js @@ -1,4 +1,4 @@ -import {isInRange} from '../lib/dateFilter' +import { isInRange } from '../lib/dateFilter' const getDate = (value) => { const d = new Date(value) @@ -164,4 +164,4 @@ const computeDoughnut = ( } } -export {computeDoughnut, computeBar} +export { computeDoughnut, computeBar } diff --git a/frontend/js/chart/monthThreshold.js b/frontend/js/chart/monthThreshold.js index 08ef841..b543983 100644 --- a/frontend/js/chart/monthThreshold.js +++ b/frontend/js/chart/monthThreshold.js @@ -1,4 +1,4 @@ -import {isInRange} from '../lib/dateFilter' +import { isInRange } from '../lib/dateFilter' const getDate = (value) => { const d = new Date(value) @@ -41,12 +41,7 @@ const compute = (transactions, cats, dateFrom, dateTo) => { datas[date] = {} } - if ( - !Object.hasOwn( - datas[date], - value.category.id.toString(), - ) - ) { + if (!Object.hasOwn(datas[date], value.category.id.toString())) { datas[date][value.category.id.toString()] = 0 } @@ -73,4 +68,4 @@ const compute = (transactions, cats, dateFrom, dateTo) => { return datas } -export {compute} +export { compute } diff --git a/frontend/js/chart/savingAccount.js b/frontend/js/chart/savingAccount.js index fc970e4..8d24a8f 100644 --- a/frontend/js/chart/savingAccount.js +++ b/frontend/js/chart/savingAccount.js @@ -27,4 +27,4 @@ const compute = (accounts) => { } } -export {compute} +export { compute } diff --git a/frontend/js/components/Filters.vue b/frontend/js/components/Filters.vue index 53bb7c3..28dacd6 100644 --- a/frontend/js/components/Filters.vue +++ b/frontend/js/components/Filters.vue @@ -86,8 +86,13 @@ diff --git a/frontend/js/components/crud/DataList.vue b/frontend/js/components/crud/DataList.vue new file mode 100644 index 0000000..8274a27 --- /dev/null +++ b/frontend/js/components/crud/DataList.vue @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/js/components/crud/FormView.vue b/frontend/js/components/crud/FormView.vue new file mode 100644 index 0000000..6c60931 --- /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..8553eed --- /dev/null +++ b/frontend/js/components/crud/FormWidget.vue @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/frontend/js/components/crud/Header.vue b/frontend/js/components/crud/Header.vue index 74daf36..f3f6f27 100644 --- a/frontend/js/components/crud/Header.vue +++ b/frontend/js/components/crud/Header.vue @@ -1,17 +1,30 @@ - + {{ title }} - + + + diff --git a/frontend/js/components/crud/Pager.vue b/frontend/js/components/crud/Pager.vue index 5301c3e..78e49be 100644 --- a/frontend/js/components/crud/Pager.vue +++ b/frontend/js/components/crud/Pager.vue @@ -20,8 +20,8 @@ diff --git a/frontend/js/components/dashboard/SavingAccounts.vue b/frontend/js/components/dashboard/SavingAccounts.vue index 6783ccd..f806a00 100644 --- a/frontend/js/components/dashboard/SavingAccounts.vue +++ b/frontend/js/components/dashboard/SavingAccounts.vue @@ -12,10 +12,10 @@ 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/DashboardView.vue b/frontend/js/views/DashboardView.vue index 400d830..e22eb63 100644 --- a/frontend/js/views/DashboardView.vue +++ b/frontend/js/views/DashboardView.vue @@ -49,14 +49,19 @@ > {{ i.label }} @@ -101,7 +106,10 @@ - + Chargement... @@ -109,10 +117,10 @@ diff --git a/frontend/js/views/FilesView.vue b/frontend/js/views/FilesView.vue index 0c4b32b..7aa4844 100644 --- a/frontend/js/views/FilesView.vue +++ b/frontend/js/views/FilesView.vue @@ -175,7 +175,7 @@ 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..694d2c9 --- /dev/null +++ b/frontend/js/views/bank_account/CreateView.vue @@ -0,0 +1,128 @@ + + + + + + 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..9f78915 --- /dev/null +++ b/frontend/js/views/bank_account/EditView.vue @@ -0,0 +1,174 @@ + + + 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..ac53fe0 --- /dev/null +++ b/frontend/js/views/bank_account/ListView.vue @@ -0,0 +1,128 @@ + + + + + + Ajouter + + + + + + + + + + + + + + diff --git a/frontend/js/views/category/CreateView.vue b/frontend/js/views/category/CreateView.vue new file mode 100644 index 0000000..e111f07 --- /dev/null +++ b/frontend/js/views/category/CreateView.vue @@ -0,0 +1,180 @@ + + + + + + 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..9134f9b --- /dev/null +++ b/frontend/js/views/category/EditView.vue @@ -0,0 +1,338 @@ + + + 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..3dd76b1 --- /dev/null +++ b/frontend/js/views/category/ListView.vue @@ -0,0 +1,162 @@ + + + + + + + + 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..6732276 --- /dev/null +++ b/frontend/js/views/saving_account/CreateView.vue @@ -0,0 +1,138 @@ + + + + + + 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..05fcee0 --- /dev/null +++ b/frontend/js/views/saving_account/EditView.vue @@ -0,0 +1,184 @@ + + + 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..b52fb11 --- /dev/null +++ b/frontend/js/views/saving_account/ListView.vue @@ -0,0 +1,128 @@ + + + + + + Ajouter + + + + + + + + + + + + + + diff --git a/frontend/js/views/TransactionsView.vue b/frontend/js/views/transaction/ListView.vue similarity index 56% rename from frontend/js/views/TransactionsView.vue rename to frontend/js/views/transaction/ListView.vue index 43cea1f..1c4625f 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 +62,7 @@ + - - - - - - - + @@ -230,6 +94,19 @@ + + + + @@ -253,22 +130,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 {ref, onMounted, watch} from 'vue' -import {getStorage, saveStorage} from '../lib/storage' +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 { 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 +162,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,7 +179,7 @@ const refresh = () => { limit: limit.value, } - query = appendRequestQueryFilters(query, route) + query = appendRequestQueryFilters(query, endpoint) fetch(`${endpoint}?${new URLSearchParams(query)}`, createRequestOptions()) .then((response) => { @@ -327,8 +195,33 @@ 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'} + const data = { category_id: null, file: null, format: 'caisse_epargne' } fetch(`/api/bank_account?order=label`, createRequestOptions()) .then((response) => { @@ -363,8 +256,8 @@ const doAdd = () => { key: 'format', widget: 'select', options: [ - {value: 'caisse_epargne', text: "Caisse d'épargne"}, - {value: 'revolut', text: 'Revolut'}, + { value: 'caisse_epargne', text: "Caisse d'épargne" }, + { value: 'revolut', text: 'Revolut' }, ], }, { @@ -389,13 +282,16 @@ const doSave = (e) => { payload.append('file', form.value.data.file) payload.append('format', form.value.data.format) - fetch(`/api/transactions`, createRequestOptions({ - method: form.value.method, - headers: { - Accept: 'application/json', - }, - body: payload, - })) + fetch( + `/api/transactions`, + createRequestOptions({ + method: form.value.method, + headers: { + Accept: 'application/json', + }, + body: payload, + }), + ) .then((response) => { return response.json() }) @@ -413,28 +309,14 @@ 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'}, - {key: 'credit', type: 'number', label: 'Crédit'}, - {key: 'date', type: 'date', label: 'Date'}, - {key: 'operation_type', type: 'string', label: 'Type'}, - {key: 'category_id', type: 'select', label: 'Catégorie', options: []}, - {key: 'bank_account_id', type: 'select', label: 'Compte', options: []}, + { key: 'label', type: 'string', label: 'Libellé' }, + { key: 'debit', type: 'number', label: 'Débit' }, + { key: 'credit', type: 'number', label: 'Crédit' }, + { key: 'date', type: 'date', label: 'Date' }, + { key: 'operation_type', type: 'string', label: 'Type' }, + { key: 'category_id', type: 'select', label: 'Catégorie', options: [] }, + { key: 'bank_account_id', type: 'select', label: 'Compte', options: [] }, ]) const fields = [ @@ -520,10 +402,3 @@ onMounted(() => { }) }) - - diff --git a/frontend/js/views/transaction/ShowView.vue b/frontend/js/views/transaction/ShowView.vue new file mode 100644 index 0000000..6e2b236 --- /dev/null +++ b/frontend/js/views/transaction/ShowView.vue @@ -0,0 +1,66 @@ + + + + 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..4e5686d --- /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..7bddeb2 --- /dev/null +++ b/frontend/js/views/user/EditView.vue @@ -0,0 +1,186 @@ + + + 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..f659c76 --- /dev/null +++ b/frontend/js/views/user/ListView.vue @@ -0,0 +1,133 @@ + + + + + + Ajouter + + + + + + + + + + + + + + diff --git a/frontend/scss/main.scss b/frontend/scss/main.scss index 71afbe8..ba4dd74 100644 --- a/frontend/scss/main.scss +++ b/frontend/scss/main.scss @@ -2,7 +2,7 @@ $white: #ffffff; $theme-colors: ( 'navBg': #f5f6f7, - 'navText': #47516B, + 'navText': #47516b, 'navActiveBg': #3072c7, 'light': #f1c3a2, 'dark': #07070b, @@ -21,10 +21,10 @@ $nav-pills-link-active-bg: map-get($theme-colors, 'navActiveBg'); @import '~bootstrap/scss/bootstrap'; @import '~bootstrap-vue-next/dist/bootstrap-vue-next.css'; @import '~@fortawesome/fontawesome-free/css/all.css'; -@import "@fontsource/ubuntu/300.css"; +@import '@fontsource/ubuntu/300.css'; body { - font-family: "Ubuntu"; + font-family: 'Ubuntu'; } $light-grey: #f5f6f7; @@ -34,21 +34,13 @@ $light-grey: #f5f6f7; } #login-form { - background: linear-gradient( - -45deg, - #f1f1f1 50%, - #e1e1e1 100% - ); + background: linear-gradient(-45deg, #f1f1f1 50%, #e1e1e1 100%); .card { - background: linear-gradient( - -45deg, - #f1f1f1 50%, - #e1e1e1 100% - ); + background: linear-gradient(-45deg, #f1f1f1 50%, #e1e1e1 100%); } - color: #47516B; + color: #47516b; } .cursor { @@ -114,11 +106,13 @@ $nav-size-sm: 50px; } tr { - td:first-child, th:first-child { + td:first-child, + th:first-child { padding-left: 1rem; } - td:last-child, th:last-child { + td:last-child, + th:last-child { padding-right: 1rem; } @@ -204,7 +198,16 @@ $nav-size-sm: 50px; } .header { - background-image: linear-gradient(45deg, #fafafa 25%, #f5f6f7 25%, #f5f6f7 50%, #fafafa 50%, #fafafa 75%, #f5f6f7 75%, #f5f6f7 100%); + background-image: linear-gradient( + 45deg, + #fafafa 25%, + #f5f6f7 25%, + #f5f6f7 50%, + #fafafa 50%, + #fafafa 75%, + #f5f6f7 75%, + #f5f6f7 100% + ); background-size: 56.57px 56.57px; - color: #47516B; + color: #47516b; }
Chargement...