mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-05-19 08:48:48 +02:00
Fix roiEarned crash when chart data has fewer than 12 entries
All checks were successful
Deploy to VPS / deploy (push) Successful in 14s
All checks were successful
Deploy to VPS / deploy (push) Successful in 14s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -324,15 +324,18 @@ export default function Pensions() {
|
||||
// Use real rendimientos from the API
|
||||
acc[key] = Math.round(snap.rendimientos);
|
||||
} else {
|
||||
// Fallback: approximate from hardcoded data
|
||||
// Fallback: approximate from chart data
|
||||
const fund = FUNDS[key];
|
||||
if (fund.isDividend) {
|
||||
const len = chartData.length;
|
||||
if (len >= 2 && fund.isDividend) {
|
||||
acc[key] = Math.max(0, Math.round(
|
||||
chartData[11][key] - chartData[10][key] - fund.monthlyContribution,
|
||||
chartData[len - 1][key] - chartData[len - 2][key] - fund.monthlyContribution,
|
||||
));
|
||||
} else {
|
||||
} else if (len > 0) {
|
||||
const activeMonths = chartData.filter((d) => d[key] > 0).length;
|
||||
acc[key] = Math.round(fund.startBalance * (fund.annualRate / 100) * (activeMonths / 12));
|
||||
} else {
|
||||
acc[key] = 0;
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
|
||||
Reference in New Issue
Block a user