fix(analysis): use compound inflation calculation instead of linear sum

This commit is contained in:
Jose Selesan
2026-08-27 12:52:48 -03:00
parent d24f3ce872
commit 1fee87a4ce

View File

@@ -258,14 +258,16 @@ export function MonthlyVariationTable() {
const accumulatedInflation = rows.reduce<number | null>((acc, row) => {
if (row.inflation === null) return acc;
return (acc ?? 0) + row.inflation;
const factor = 1 + row.inflation / 100;
return (acc ?? 1) * factor;
}, null);
return {
BELO: totalVariation(oldest.BELO.current, newest.BELO.current),
BLUE: totalVariation(oldest.BLUE.current, newest.BLUE.current),
BNA: totalVariation(oldest.BNA.current, newest.BNA.current),
inflation: accumulatedInflation,
inflation:
accumulatedInflation !== null ? (accumulatedInflation - 1) * 100 : null,
period: `${oldest.label} – ${newest.label}`,
};
}, [rows]);