From 741c615e2ea3044ea6e1e9767c239f537cbc3105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vi=CC=81ctor=20Falco=CC=81n?= Date: Wed, 8 Jul 2026 17:02:23 +0200 Subject: [PATCH] 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. --- resources/js/hooks/use-dashboard-data.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/js/hooks/use-dashboard-data.ts b/resources/js/hooks/use-dashboard-data.ts index 8dbb362f..0501e299 100644 --- a/resources/js/hooks/use-dashboard-data.ts +++ b/resources/js/hooks/use-dashboard-data.ts @@ -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