Skip to content

Commit

Permalink
fix: make generating budget from year work for both income and expenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverth committed Nov 14, 2024
1 parent 54b5841 commit 9aa8ed0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/store/state/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9aa8ed0

Please sign in to comment.