Open source personal finance application
update 3.6.1
ilkomee943bd049032
diff --git a/components/dashboard/Dashboard.vue b/components/dashboard/Dashboard.vueindex 9b40f53d..d20bf752 100644--- a/components/dashboard/Dashboard.vue+++ b/components/dashboard/Dashboard.vue@@ -9,7 +9,6 @@ export default {computed: {isEmptyData () {const statCurrentPeriod = this.$store.getters['stat/statCurrentPeriod']- console.log(statCurrentPeriod)if (statCurrentPeriod.incomes.categoriesIds.length === 0 &&statCurrentPeriod.expenses.categoriesIds.length === 0 &&this.$store.getters['trns/selectedTrnsIdsWithDate'].length === 0) {@@ -19,7 +18,6 @@ export default {},periods () {- console.log(this.$store.state.chart.periods)return this.$store.state.chart.periods},diff --git a/components/layout/LayoutMobile.vue b/components/layout/LayoutMobile.vueindex c52db1e2..e3f2227e 100644--- a/components/layout/LayoutMobile.vue+++ b/components/layout/LayoutMobile.vue@@ -130,24 +130,12 @@ export default {},addPeriodOrGroup () {- if (this.periods[this.filterPeriod].grouped) {- this.$store.commit('chart/toogleChartPeriodView', { periodName: this.filterPeriod })- }-- this.periods[this.filterPeriod].grouped- ? this.$store.commit('chart/addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedGroups' })- : this.$store.commit('chart/addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })+ this.$store.commit('chart/addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })this.saveChartsPeriodsToLocalStorage()},removePeriodOrGroup () {- if (this.periods[this.filterPeriod].grouped) {- this.$store.commit('chart/toogleChartPeriodView', { periodName: this.filterPeriod })- }-- this.periods[this.filterPeriod].grouped- ? this.$store.commit('chart/removeElementsFromChart', { periodName: this.filterPeriod, periodType: 'showedGroups' })- : this.$store.commit('chart/removeElementsFromChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })+ this.$store.commit('chart/removeElementsFromChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })this.saveChartsPeriodsToLocalStorage()},@@ -455,10 +443,20 @@ export default {//- Period Selector//---------------------------.box__nav+ .tabItem(+ :class="{ _disable: $store.state.filter.period === 'all' || $store.getters['stat/isLastPeriodSelected'] }"+ @click="$store.dispatch('filter/setPeriodNext')"+ ): .mdi.mdi-chevron-left+.menuDots(@click="isShowPeriodsNames = true").menuDots__name: Date(:type="2").menuDots__dots: .mdi.mdi-dots-vertical+ .tabItem(+ :class="{ _disable: $store.state.filter.period === 'all' || $store.getters['stat/isFirstPeriodSelected'] }"+ @click="$store.dispatch('filter/setPeriodPrev')"+ ): .mdi.mdi-chevron-right+//- Filter//---------------------------.page__filter(v-if="isShowFilter")@@ -658,6 +656,7 @@ export default {background var(--c-bg-1).menuDots+ flex-grow 1cursor pointerdisplay flexalign-items centerdiff --git a/components/stat/StatChartLines.vue b/components/stat/StatChartLines.vueindex 3d2474aa..43ae0aa3 100644--- a/components/stat/StatChartLines.vue+++ b/components/stat/StatChartLines.vue@@ -56,7 +56,7 @@ export default {// diff periods from oldest trn and todayconst oldestTrnDate = this.$day(trns[this.$store.getters['trns/firstCreatedTrnId']].date).endOf(periodName)let periodsToShow = this.$day().endOf(periodName).diff(oldestTrnDate, periodName) + 1- const periodsWantToShow = chartPeriods[periodName].grouped ? chartPeriods[periodName].showedGroups : chartPeriods[periodName].showedPeriods+ const periodsWantToShow = chartPeriods[periodName].showedPeriodsperiodsToShow = periodsWantToShow >= periodsToShow ? periodsToShow : periodsWantToShowconst categories = []diff --git a/components/stat/StatChartsLine.vue b/components/stat/StatChartsLine.vuedeleted file mode 100644index 26e1be33..00000000--- a/components/stat/StatChartsLine.vue+++ /dev/null@@ -1,272 +0,0 @@-<script>-export default {- name: 'StatChartsLine2',-- computed: {- periods () {- return this.$store.state.chart.periods- },- filterPeriod () {- return this.$store.state.filter.period- },- activePeriodNumber () {- const statFromDate = this.$day().startOf(this.$store.state.filter.period)- return statFromDate.diff(this.$store.state.filter.date, this.$store.state.filter.period) + 1- },- periodsValues () {- const trns = this.$store.state.trns.items- const transferCategoryId = this.$store.getters['categories/transferCategoryId']- const trnsIds = this.$store.getters['trns/selectedTrnsIds']- const filterPeriod = this.$store.state.filter.period- const diff = this.getNumberShowedPeriods()-- const values = {}- for (let period = 0; period < diff; period++) {- const periodStartDate = this.$day().subtract(period, filterPeriod).startOf(filterPeriod)- const periodEndDate = this.$day().subtract(period, filterPeriod).endOf(filterPeriod)- const ids = trnsIds- .filter((trnId) => {- return trns[trnId].date >= periodStartDate &&- trns[trnId].date <= periodEndDate &&- trns[trnId].categoryId !== transferCategoryId- })-- values[periodStartDate.valueOf()] = {- date: periodStartDate.valueOf(),- ...this.$store.getters['trns/getTotalOfTrnsIds'](ids)- }- }-- return values- },- periodsGroupedValues () {- const filterPeriod = this.$store.state.filter.period- const periodsValues = this.periodsValues- const groupedBy = this.periods[filterPeriod].groupedBy- const groupedValues = {}-- for (const date in periodsValues) {- const periodStartDateValue = this.$day(parseInt(date)).startOf(groupedBy).valueOf()- const periodEndDateValue = this.$day(parseInt(date)).endOf(groupedBy).valueOf()-- if (date >= periodStartDateValue && date <= periodEndDateValue) {- groupedValues[periodStartDateValue]- ? groupedValues[periodStartDateValue].push({ date, ...periodsValues[date] })- : groupedValues[periodStartDateValue] = [{ date, ...periodsValues[date] }]- }- }-- return groupedValues- },- maxAmountValue () {- const periodsValues = this.periodsValues- let biggest = 0-- for (const date in periodsValues) {- const incomes = periodsValues[date].incomes- const expenses = periodsValues[date].expenses- if (incomes > biggest) { biggest = incomes }- if (expenses > biggest) { biggest = expenses }- }- return biggest- }- },-- created () {- this.defaultPeriods = this.$store.state.chart.periods- },-- methods: {- getNumberShowedPeriods () {- const filterPeriod = this.$store.state.filter.period- let diff = 0-- if (this.periods[filterPeriod].grouped) {- diff = this.getGroupedPeriods()- }- else {- this.activePeriodNumber > this.periods[filterPeriod].showedPeriods- ? diff = this.activePeriodNumber- : diff = this.periods[filterPeriod].showedPeriods- }- if (diff <= 0) { diff = 1 }- this.$store.dispatch('stat/setDiffPeriods', diff)-- return diff- },-- getGroupedPeriods () {- const filterPeriod = this.filterPeriod- const groupedBy = this.periods[filterPeriod].groupedBy- const showedGroups = this.periods[filterPeriod].showedGroups- let numberOfPeriods = 0-- // periods in current group- const getPeriodsInCurrentGroup = () => {- let currentGroupPeriods- if (filterPeriod === 'day') { currentGroupPeriods = parseInt(this.$day().format('D')) }- if (filterPeriod === 'week') { currentGroupPeriods = this.$day().week() - this.$day().startOf('month').week() + 1 }- if (filterPeriod === 'month') { currentGroupPeriods = parseInt(this.$day().format('MM')) }- return currentGroupPeriods- }-- // periods in prev group- const getPeriodsInPrevGroup = () => {- let prevGroupsPeriods = 0- for (let index = 1; index < showedGroups; index++) {- prevGroupsPeriods = prevGroupsPeriods + getPeriodsInPrevGroup2(index)- }- return prevGroupsPeriods- }-- const getPeriodsInPrevGroup2 = (hey) => {- const groupDateStart = this.$day().subtract(hey, groupedBy).startOf(groupedBy)- const groupDateEnd = this.$day().subtract(hey, groupedBy).endOf(groupedBy)-- let periodsInGroup = 0- filterPeriod === 'week'- ? periodsInGroup = groupDateEnd.week() - groupDateStart.week()- : periodsInGroup = groupDateEnd.diff(groupDateStart, filterPeriod) + 1-- return periodsInGroup- }-- const periodsInCurrentGroup = getPeriodsInCurrentGroup()-- showedGroups === 1- ? numberOfPeriods = periodsInCurrentGroup- : numberOfPeriods = periodsInCurrentGroup + getPeriodsInPrevGroup()-- // when view old data- if (this.activePeriodNumber >= numberOfPeriods) {- numberOfPeriods = periodsInCurrentGroup- let index = 1- while (this.activePeriodNumber >= numberOfPeriods) {- numberOfPeriods = numberOfPeriods + getPeriodsInPrevGroup2(index)- index++- }- }-- return numberOfPeriods- },-- formatGroupName (date, groupedBy) {- const dateValueOf = parseInt(date)- let format- switch (groupedBy) {- case 'month':- format = 'MMMM'- break- case 'year':- format = 'YYYY'- break- }- return this.$day(dateValueOf).format(format)- }- }-}-</script>--<template lang="pug">-.charts.swiper-no-swiping- template(v-if="$store.state.filter.period === 'all'")- .charts__allData Change period to see chart-- template(v-if="$store.state.filter.period !== 'all'")- .charts__content- //- grouped- template(v-if="periods[filterPeriod].grouped")- .charts__items._grouped- template(v-for="(periodGroups, groupDate) in periodsGroupedValues")- .chart-group(:class="{ _grouped: periods[filterPeriod].grouped }")- .chart-group__name(v-show="periods[filterPeriod].grouped")- template(v-if="periods[filterPeriod].grouped") {{ formatGroupName(groupDate, periods[filterPeriod].groupedBy) }}-- .chart-group__content- template(v-for="period in periodGroups")- ChartItem(- :key="period.date"- :maxAmountValue="maxAmountValue"- :period="period"- parentClassName=".charts__items")-- //- simple- template(v-else)- .charts__items- template(v-for="period in periodsValues")- ChartItem(- :key="period.date"- :maxAmountValue="maxAmountValue"- :period="period"- parentClassName=".charts__items")-</template>--<style lang="stylus" scoped>-@import "~assets/stylus/variables"--.charts- z-index 5- position relative-- +media-tablet()- padding $m6-- &__allData- opacity .7- display flex- align-items center- justify-content center- font-size 14px-- &__items- overflow hidden- overflow-x auto- display flex- flex-direction row-reverse- scrollbar()-- &._grouped- padding 0 $m4-- &__nav- z-index 2- position absolute- right $m7- bottom $m7--.chart-group- position relative- flex-grow 1- margin-left 20px- padding-left 20px- border-left 1px solid var(--c-bg-4)-- &:last-child- margin-left 0- padding-left 0- border 0-- &__name- opacity .7- position absolute- right 0- width 100%- height 42px- padding-top 0- padding-bottom $m4- font-secondary()- font-size 14px- text-align center- text-transform uppercase- white-space nowrap- letter-spacing .5px-- &__content- display flex- flex-direction row-reverse- padding-top 20px--.chart-space- &:last-child- min-width 40px-</style>diff --git a/components/stat/StatPc.vue b/components/stat/StatPc.vueindex 8c7e5887..dd0c252a 100644--- a/components/stat/StatPc.vue+++ b/components/stat/StatPc.vue@@ -16,10 +16,10 @@ export default {//------------------------------------------------.stat__itemtemplate(v-if="statCurrentPeriod.expenses.categoriesIds.length")- .stat__chart(v-if="$store.state.ui.catsChart === 'visible' && statCurrentPeriod.incomes.categoriesIds.length > 1")+ .stat__chart(v-if="$store.state.ui.catsChart === 'visible' && statCurrentPeriod.expenses.categoriesIds.length > 1")PeriodCatsChart(type="expenses")- .stat__pie(v-if="$store.state.ui.catsChartPie === 'visible' && statCurrentPeriod.incomes.categoriesIds.length > 1")+ .stat__pie(v-if="$store.state.ui.catsChartPie === 'visible' && statCurrentPeriod.expenses.categoriesIds.length > 1")StatChartPie(amountType="expenses").stat__cats(v-if="$store.state.ui.statItems === 'visible'")diff --git a/components/stat/cats/PeriodCatsChart.vue b/components/stat/cats/PeriodCatsChart.vueindex cb2c9ae8..72e26b18 100644--- a/components/stat/cats/PeriodCatsChart.vue+++ b/components/stat/cats/PeriodCatsChart.vue@@ -115,6 +115,7 @@ export default {min-width $m9&__popup+ z-index 5position absoluteleft 0bottom $m9diff --git a/components/stat/chart/ChartMenu.vue b/components/stat/chart/ChartMenu.vueindex 1101546f..683716b9 100644--- a/components/stat/chart/ChartMenu.vue+++ b/components/stat/chart/ChartMenu.vue@@ -26,16 +26,12 @@ export default {methods: {addPeriodOrGroup () {- this.periods[this.filterPeriod].grouped- ? this.$store.commit('chart/addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedGroups' })- : this.$store.commit('chart/addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })+ this.$store.commit('chart/addElementsToChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })this.saveChartsPeriodsToLocalStorage()},removePeriodOrGroup () {- this.periods[this.filterPeriod].grouped- ? this.$store.commit('chart/removeElementsFromChart', { periodName: this.filterPeriod, periodType: 'showedGroups' })- : this.$store.commit('chart/removeElementsFromChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })+ this.$store.commit('chart/removeElementsFromChart', { periodName: this.filterPeriod, periodType: 'showedPeriods' })this.saveChartsPeriodsToLocalStorage()},@@ -82,13 +78,11 @@ ContextMenu()ContextMenuItem(- v-if="(periods[filterPeriod].grouped && periods[filterPeriod].showedGroups > 1) || (!periods[filterPeriod].grouped && periods[filterPeriod].showedPeriods > 1)"+ v-if="periods[filterPeriod].showedPeriods > 1"icon="mdi mdi-minus":title="$t('chart.view.removePeriodButton')"@onClick="removePeriodOrGroup")- template(slot="desc")- template(v-if="periods[filterPeriod].grouped") {{ $t('chart.view.showed') }} {{ periods[filterPeriod].showedGroups }} {{ $t('chart.view.periodsName') }}- template(v-else) {{ $t('chart.view.showed') }} {{ periods[filterPeriod].showedPeriods }} {{ $t('chart.view.periodsName') }}+ template(slot="desc") {{ $t('chart.view.showed') }} {{ periods[filterPeriod].showedPeriods }} {{ $t('chart.view.periodsName') }}</template>diff --git a/components/summary/SummaryAverage.vue b/components/summary/SummaryAverage.vueindex 5d32413f..276d3080 100644--- a/components/summary/SummaryAverage.vue+++ b/components/summary/SummaryAverage.vue@@ -9,13 +9,6 @@ export default {statAverage () {return this.$store.getters['stat/statAverage']- },-- daysLeft () {- const filterDate = this.$store.state.filter.date- const filterPeriod = this.$store.state.filter.period- console.log(filterDate, filterPeriod)- return null}}}@@ -42,12 +35,6 @@ export default {:amount="statAverage.total":name="$t('money.averageTotal')")-- //- SummaryRowItem(- //- v-if="statAverage.expenses !== 0"- //- :amount="statAverage.expenses - statCurrentPeriod.expenses.total"- //- :name="(statAverage.expenses - statCurrentPeriod.expenses.total) > 0 ? 'Сохранено' : 'Перерасход'"- //- )</template><style lang="stylus" scoped>diff --git a/components/trnForm/TrnFormTrns.vue b/components/trnForm/TrnFormTrns.vueindex b4eabd51..c7cdc27d 100644--- a/components/trnForm/TrnFormTrns.vue+++ b/components/trnForm/TrnFormTrns.vue@@ -194,6 +194,9 @@ export default {margin-bottom (- $m5)border-radius 12px+ +media-laptop()+ margin-bottom $m7+.switcherposition relativeposition stickydiff --git a/package.json b/package.jsonindex 119d4269..24734d21 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "finapp",- "version": "3.6.0",+ "version": "3.6.1","scripts": {"dev": "cross-env NUXT_HOST=0.0.0.0 nuxt","build": "nuxt build",diff --git a/store/chart/actions.js b/store/chart/actions.jsindex 5d57b2df..a089fdb3 100644--- a/store/chart/actions.js+++ b/store/chart/actions.js@@ -3,26 +3,19 @@ import localforage from 'localforage'export default {async initChart ({ rootState, commit }) {const localPeriods = await localforage.getItem('finapp.chart.periods')- let showedGroups, showedPeriods+ let showedPeriodsif (!localPeriods) { return }for (const periodName in localPeriods) {if (!localPeriods[periodName]) { return }- Number.isInteger(localPeriods[periodName].showedGroups)- ? showedGroups = localPeriods[periodName].showedGroups- : showedGroups = rootState.chart.periods[periodName].showedGroups- if (!showedGroups || showedGroups <= 0) { showedGroups = 1 }-Number.isInteger(localPeriods[periodName].showedPeriods)? showedPeriods = localPeriods[periodName].showedPeriods: showedPeriods = rootState.chart.periods[periodName].showedPeriods- if (!showedGroups || showedPeriods <= 0) { showedPeriods = 1 }const periodValues = {...localPeriods[periodName],- showedGroups,showedPeriods}diff --git a/store/chart/index.js b/store/chart/index.jsindex 694f8aa5..404a10c2 100644--- a/store/chart/index.js+++ b/store/chart/index.js@@ -7,25 +7,21 @@ export const state = () => ({periods: {day: {groupedBy: 'month',- showedGroups: 14,showedPeriods: 14,grouped: false},week: {groupedBy: 'month',- showedGroups: 6,showedPeriods: 6,grouped: false},month: {groupedBy: 'year',- showedGroups: 6,showedPeriods: 6,grouped: false},year: {groupedBy: 'year',- showedGroups: 3,showedPeriods: 3,grouped: false}diff --git a/store/stat/getters.js b/store/stat/getters.jsindex d4193a85..bde15e1c 100644--- a/store/stat/getters.js+++ b/store/stat/getters.js@@ -9,7 +9,7 @@ export default {* @return {Number} return[date].expenses* @return {Number} return[date].total*/- statAverage (state, getters, rootState) {+ statAverage (state, getters) {const statPeriods = getters.statByPeriodslet incomes = 0