06/03 Optimize codes, fix Schwab Account

This commit is contained in:
2026-06-03 14:21:39 -04:00
parent 5c8854a65a
commit f59f9aa44c
2 changed files with 24 additions and 7 deletions
+5
View File
@@ -282,6 +282,11 @@ def sync_snapshot(schwab_account_id):
if not sa.pfm_account_id:
flash('Map this account to a PFM account first.', 'warning')
return redirect(url_for('schwab.index'))
# Always use the currently active connection — the stored connection_id on the
# account record may reference an older connection after a reconnect.
active_conn = SchwabConnection.query.filter_by(is_active=True).first()
if active_conn:
sa.connection = active_conn
try:
bal_updated, pos_synced = sync_account_snapshot(sa)
flash(