From 896147bd288e895f28cf99c19b182e0bceaaa3e4 Mon Sep 17 00:00:00 2001 From: NguyenND Date: Wed, 3 Jun 2026 09:37:16 -0400 Subject: [PATCH] 06/03 Optimize code --- app/routes/dashboard.py | 3 ++- app/templates/dashboard/index.html | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/routes/dashboard.py b/app/routes/dashboard.py index d796150..2eee385 100644 --- a/app/routes/dashboard.py +++ b/app/routes/dashboard.py @@ -7,7 +7,7 @@ from app.models.transaction import Transaction from app.models.category import Category from app.services.fx_service import get_today_rate, get_rate_history, force_refresh from app.services.ai_service import get_latest_daily_insight -from app.services.account_service import get_total_assets, get_total_liabilities +from app.services.account_service import get_total_assets, get_total_liabilities, recalc_all from datetime import date, datetime, timedelta import calendar @@ -62,6 +62,7 @@ def index(): net_cash_flow = float(total_income) - float(total_expense) # ── Accounts ───────────────────────────────────── + recalc_all() accounts = Account.query.filter_by(is_active=True).order_by(Account.name).all() total_assets = get_total_assets() total_liabilities = get_total_liabilities() diff --git a/app/templates/dashboard/index.html b/app/templates/dashboard/index.html index e1db06d..56e5c71 100644 --- a/app/templates/dashboard/index.html +++ b/app/templates/dashboard/index.html @@ -197,7 +197,17 @@
{{ acct.account_type | replace('_',' ') | title }}
+ {% if acct.account_type == 'credit_card' %} + {% set cc_owed = [0, -acct.balance] | max %} +
+ + {% if cc_owed > 0 %}-{% endif %}{{ cc_owed | currency }} + +
owed
+
+ {% else %} {{ acct.balance | currency }} + {% endif %} {% endfor %}