From 9aa8ed095eb1f573991daa464a5dccd3e4611ca3 Mon Sep 17 00:00:00 2001 From: Thomas Dickson Date: Thu, 14 Nov 2024 22:33:39 +1300 Subject: [PATCH] fix: make generating budget from year work for both income and expenses --- src/store/state/utils.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/store/state/utils.ts b/src/store/state/utils.ts index cbbf75a4..a11a0014 100644 --- a/src/store/state/utils.ts +++ b/src/store/state/utils.ts @@ -20,12 +20,15 @@ export const generateBudgetYear = (year: number): BudgetYear => ({ }); export const generateBudgetYearFromCurrent = (year: number, current: BudgetYear): BudgetYear => { - current.income = current.income.map((value) => { + function clearValues(value: BudgetGroup) { for (const budget of value.budgets) { budget.values = new Array(12).fill(0); } return value; - }); + } + + current.income = current.income.map(clearValues); + current.expenses = current.expenses.map(clearValues); return { year,