fix(dashboard): show account card balance as net worth contribution

The card must keep liabilities negative (existing behaviour, covered by
deriveAccountMetrics tests); only the asset sign was buggy. Use
netWorthContribution instead of the raw balance so loans/credit cards stay
negative while a negative asset (e.g. overdrawn checking) is no longer
flipped positive.
This commit is contained in:
Víctor Falcón 2026-07-08 17:02:23 +02:00
parent 58354f9778
commit 741c615e2e
1 changed files with 5 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { useLocale } from '@/hooks/use-locale';
import { netWorthContribution } from '@/lib/chart-calculations';
import { Account, AccountType, Bank } from '@/types/account';
import { Category } from '@/types/category';
import { formatMonthFromYearMonth } from '@/utils/date';
@ -74,7 +75,10 @@ export function deriveAccountMetrics(
date: formatMonthFromYearMonth(point.month as string, locale),
value:
typeof point[account.id] === 'number'
? (point[account.id] as number)
? netWorthContribution(
account.type,
point[account.id] as number,
)
: 0,
investedAmount:
investedKey in point