Skip to content

Commit

Permalink
fix: create new budget groups instead of overriding existing ones
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverth committed Nov 22, 2024
1 parent a210936 commit 1f1d243
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/store/state/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ export const generateBudgetYear = (year: number): BudgetYear => ({
});

export const generateBudgetYearFromCurrent = (year: number, current: BudgetYear): BudgetYear => {
function clearValues(value: BudgetGroup) {
function clearValues(value: BudgetGroup): BudgetGroup {
const newBudgetGroup = {
name: value.name,
id: uuid(),
budgets: []
};
for (const budget of value.budgets) {
budget.values = new Array(12).fill(0);
newBudgetGroup.budgets.push(generateBudget(budget.name));
}
return value;
return newBudgetGroup;
}

return {
Expand Down

0 comments on commit 1f1d243

Please sign in to comment.