From 395a2d95353a63426e92ae114c10ff9f0b64b92a Mon Sep 17 00:00:00 2001 From: NguyenND Date: Wed, 3 Jun 2026 10:21:14 -0400 Subject: [PATCH] 06/03 Optimize codes, move account action buttons to Accounts page --- app/routes/accounts.py | 11 ++- app/routes/teller.py | 3 + app/templates/accounts/index.html | 104 ++++++++++++++++++++- app/templates/teller/index.html | 149 ++++-------------------------- 4 files changed, 132 insertions(+), 135 deletions(-) diff --git a/app/routes/accounts.py b/app/routes/accounts.py index d204c6d..02d69fe 100644 --- a/app/routes/accounts.py +++ b/app/routes/accounts.py @@ -83,12 +83,21 @@ def index(): ).group_by(Transaction.account_id).all() monthly_charges = {row[0]: float(row[1]) for row in rows} + # Teller account mapping: pfm_account_id → TellerAccount + from app.models.teller_enrollment import TellerAccount + teller_accounts = TellerAccount.query.filter( + TellerAccount.pfm_account_id.in_([a.id for a in all_accounts]), + TellerAccount.is_active == True, + ).all() + teller_map = {ta.pfm_account_id: ta for ta in teller_accounts} + return render_template('accounts/index.html', accounts=accounts, tab=tab, bank_count=len(bank_accounts), credit_count=len(credit_accounts), - monthly_charges=monthly_charges) + monthly_charges=monthly_charges, + teller_map=teller_map) @accounts_bp.route('/new', methods=['GET', 'POST']) diff --git a/app/routes/teller.py b/app/routes/teller.py index 7c62b3e..d9d338e 100644 --- a/app/routes/teller.py +++ b/app/routes/teller.py @@ -294,6 +294,9 @@ def full_resync(teller_account_id): f'Next sync will fetch the last 90 days — duplicates will be skipped automatically.', 'info' ) + next_url = request.form.get('next', '') + if next_url and next_url.startswith('/'): + return redirect(next_url) return redirect(url_for('teller.index')) diff --git a/app/templates/accounts/index.html b/app/templates/accounts/index.html index 85812ef..8579892 100644 --- a/app/templates/accounts/index.html +++ b/app/templates/accounts/index.html @@ -25,6 +25,7 @@ {% if accounts %}
{% for acct in accounts %} + {% set ta = teller_map.get(acct.id) %}
@@ -35,7 +36,12 @@
-
{{ acct.name }}
+
+ {{ acct.name }} + {% if ta %} + Teller + {% endif %} +
{{ acct.account_type | replace('_',' ') | title }}
@@ -56,19 +62,18 @@
{% if tab == 'bank' %} -
+
{{ acct.balance | currency }}
{% endif %} {% if tab == 'credit' %} - {% set owed = [0, -acct.balance] | max %} {% set charges = monthly_charges.get(acct.id, 0) %}
Amount Owed
-
+
{% if owed > 0 %}-{% endif %}{{ owed | currency }}
@@ -85,7 +90,7 @@
{{ acct.notes }}
{% endif %} - + {% if tab == 'credit' %}
{% endif %} + + {% if ta %} +
+ + + Sync + +
+ + + +
+
+ {% if ta.last_sync_date %} +
+ Last synced {{ ta.last_sync_date.strftime('%b %d') }} +
+ {% endif %} + {% endif %} +
{% endfor %} @@ -137,3 +173,61 @@ {% endif %} {% endblock %} + +{% block extra_js %} + +{% endblock %} diff --git a/app/templates/teller/index.html b/app/templates/teller/index.html index 2f5cdbf..d59e47d 100644 --- a/app/templates/teller/index.html +++ b/app/templates/teller/index.html @@ -3,15 +3,6 @@ {% block page_title %}Bank Connections{% endblock %} {% block topbar_actions %} -{% if enrollments %} -
- - -
-{% endif %} +
{% for ta in accounts %}
-
-
+
+
-
-
- {{ ta.account_name }} - {% if ta.pfm_account %} - {# Balance display — updated in-place by refreshBalance() #} - - {{ ta.pfm_account.balance | currency }} - - {% if ta.last_sync_date %} - - synced {{ ta.last_sync_date.strftime('%b %d') }} - - {% endif %} - {% endif %} -
+
+
{{ ta.account_name }}
{{ ta.account_subtype | replace('_',' ') | title }} {% if ta.pfm_account %} - · {{ ta.pfm_account.name }} + · linked to {{ ta.pfm_account.name }} {% else %} - · Not mapped + · Not mapped {% endif %}
-
- {% if ta.pfm_account %} - - - Sync - -
- - -
- {% else %} - Map Account - {% endif %} -
+ {% if not ta.pfm_account %} + Map Account + {% endif %}
{% endfor %} - - - {% if accounts | selectattr('pfm_account_id') | list %} -
-
- - -
-
- {% endif %}
{% endfor %} @@ -121,6 +69,7 @@
No banks connected

Connect your US bank accounts to automatically sync transactions and balances. + Once connected, use the Accounts page to sync transactions and refresh balances.