diff --git a/src/components/box.vue b/src/components/box.vue
index d28e41b..df0540f 100644
--- a/src/components/box.vue
+++ b/src/components/box.vue
@@ -31,29 +31,16 @@ export default {
...mapGetters('config', [
'postes'
]),
+ ...mapGetters('datas', [
+ 'libelle_filter_rows'
+ ]),
poste () {
return this.postes[this.postename]
}
},
methods: {
filter_rows () {
- if (this.poste.words) {
- if (this.poste.invert) {
- return this.rows.filter(x => {
- return this.poste.words.every(v => {
- return x.Libellé.indexOf(v) < 0
- })
- })
- } else {
- return this.rows.filter(x => {
- return this.poste.words.some(v => {
- return x.Libellé.indexOf(v) >= 0
- })
- })
- }
- } else {
- return this.rows
- }
+ return this.libelle_filter_rows(this.poste.words, this.poste.invert)
},
total () {
return Math.round(
@@ -78,6 +65,7 @@ export default {
}
.icon {
flex: 40%;
+ align-self: center;
}
.amount {
flex: 50%;
diff --git a/src/store/modules/datas.js b/src/store/modules/datas.js
index d4cd93e..5b4951a 100644
--- a/src/store/modules/datas.js
+++ b/src/store/modules/datas.js
@@ -2,6 +2,10 @@ import { readdir, readFile } from 'fs'
import path from 'path'
import Papa from 'papaparse'
+var today = new Date()
+var monthAgo = new Date()
+monthAgo.setMonth(monthAgo.getMonth() - 1)
+
export default {
namespaced: true,
state: {
@@ -12,6 +16,8 @@ export default {
fields: []
}
},
+ start: monthAgo.toISOString().split('T')[0],
+ end: today.toISOString().split('T')[0]
},
getters: {
csvs: (state) => {
@@ -19,6 +25,40 @@ export default {
},
rows: (state) => {
return state.rows.data
+ },
+ spending_rows: (state, getters) => {
+ return getters.rows.filter(x => x.Montant < 0)
+ },
+ start: (state) => {
+ return state.start
+ },
+ end: (state) => {
+ return state.end
+ },
+ date_filter_rows: (state, getters) => {
+ var start = new Date(state.start)
+ var end = new Date(state.end)
+ return getters.spending_rows.filter(x => {
+ return (new Date(x.Date) >= start) & (new Date(x.Date) < end)
+ })
+ },
+ libelle_filter_rows: (state, getters) => (words, invert) => {
+ if (!words) {
+ return getters.date_filter_rows
+ }
+ if (invert) {
+ return getters.date_filter_rows.filter(x => {
+ return words.every(v => {
+ return x.Libellé.indexOf(v) < 0
+ })
+ })
+ } else {
+ return getters.date_filter_rows.filter(x => {
+ return words.some(v => {
+ return x.Libellé.indexOf(v) >= 0
+ })
+ })
+ }
}
},
mutations: {
@@ -31,6 +71,12 @@ export default {
},
APPEND_DATA: (state, { content }) => {
state.rows.push(content)
+ },
+ SET_START: (state, { start }) => {
+ state.start = start
+ },
+ SET_END: (state, { end }) => {
+ state.end = end
}
},
actions: {
@@ -65,6 +111,12 @@ export default {
context.commit('SET_DATA', { data: parsed })
}
})
- }
+ },
+ set_start (context, start) {
+ context.commit('SET_START', { start })
+ },
+ set_end (context, end) {
+ context.commit('SET_END', { end })
+ },
}
}
diff --git a/src/views/home.vue b/src/views/home.vue
index dc7f2d6..014f909 100644
--- a/src/views/home.vue
+++ b/src/views/home.vue
@@ -4,33 +4,31 @@
-
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
-
+