From 224f6bc303dd4c0af850774f641a18396232da86 Mon Sep 17 00:00:00 2001 From: Simon Reinisch Date: Wed, 1 May 2024 15:08:50 +0200 Subject: [PATCH] fix: use current year as reference for all-time panels --- src/app/pages/dashboard/all-time/AllTime.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/pages/dashboard/all-time/AllTime.vue b/src/app/pages/dashboard/all-time/AllTime.vue index 825c38b..674856c 100644 --- a/src/app/pages/dashboard/all-time/AllTime.vue +++ b/src/app/pages/dashboard/all-time/AllTime.vue @@ -45,8 +45,9 @@ const cards = computed((): Card[] => { maximumFractionDigits: 2 }); - const lastYear = state.years.at(-2); - const currentYear = state.years.at(-1); + const year = new Date().getFullYear(); + const lastYear = state.years.find((v) => v.year === year - 1); + const currentYear = state.years.find((v) => v.year === year); const lastYearIncome = lastYear?.income ? sum(totals(lastYear.income)) : 0; const lastYearExpenses = lastYear?.expenses ? sum(totals(lastYear.expenses)) : 0;