diff --git a/CHANGELOG.fr.md b/CHANGELOG.fr.md index 60e63aa..f61f2db 100644 --- a/CHANGELOG.fr.md +++ b/CHANGELOG.fr.md @@ -2,6 +2,9 @@ ## [Non publié] +### Ajouté +- Budget : colonne du total annuel de l'année précédente comme base de référence (#16) + ## [0.6.3] ### Ajouté diff --git a/CHANGELOG.md b/CHANGELOG.md index 491f0f9..8d86bb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased] +### Added +- Budget: previous year annual total column as baseline reference (#16) + ## [0.6.3] ### Added diff --git a/src/components/budget/BudgetTable.tsx b/src/components/budget/BudgetTable.tsx index 09651b6..aa7e7f7 100644 --- a/src/components/budget/BudgetTable.tsx +++ b/src/components/budget/BudgetTable.tsx @@ -193,6 +193,7 @@ export default function BudgetTable({ rows, onUpdatePlanned, onSplitEvenly }: Bu // Column totals with sign convention (only count leaf rows to avoid double-counting parents) const monthTotals: number[] = Array(12).fill(0); let annualTotal = 0; + let prevYearTotal = 0; for (const row of rows) { if (row.is_parent) continue; // skip parent subtotals to avoid double-counting const sign = signFor(row.category_type); @@ -200,9 +201,10 @@ export default function BudgetTable({ rows, onUpdatePlanned, onSplitEvenly }: Bu monthTotals[m] += row.months[m] * sign; } annualTotal += row.annual * sign; + prevYearTotal += row.prev_year_annual * sign; } - const totalCols = 14; // category + annual + 12 months + const totalCols = 15; // category + prev year + annual + 12 months if (rows.length === 0) { return ( @@ -243,6 +245,9 @@ export default function BudgetTable({ rows, onUpdatePlanned, onSplitEvenly }: Bu {row.category_name} +