fix(analysis): use compound inflation calculation instead of linear sum
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user