diff --git a/CHANGELOG.fr.md b/CHANGELOG.fr.md index 60e63aa..7066584 100644 --- a/CHANGELOG.fr.md +++ b/CHANGELOG.fr.md @@ -2,6 +2,9 @@ ## [Non publié] +### Ajouté +- Tableau de budget : colonne du total de l'année précédente affichée comme première colonne de données pour servir de référence (#16) + ## [0.6.3] ### Ajouté diff --git a/CHANGELOG.md b/CHANGELOG.md index 491f0f9..edd44d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## [Unreleased] +### Added +- Budget table: previous year total column displayed as first data column for baseline reference (#16) + ## [0.6.3] ### Added diff --git a/src/components/budget/BudgetTable.tsx b/src/components/budget/BudgetTable.tsx index 09651b6..c7666c3 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.previousYearTotal * 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} +