06/02 Update Accounts page to separate Checking/Savings and Credit Card

This commit is contained in:
2026-06-02 11:30:32 -04:00
parent ae50e164cd
commit c429de7bcd
2 changed files with 76 additions and 11 deletions
+20 -5
View File
@@ -44,15 +44,30 @@ class AccountForm(FlaskForm):
submit = SubmitField('Save')
BANK_TYPES = {'checking', 'savings', 'cash', 'investment', 'crypto', 'other'}
@accounts_bp.route('/')
@login_required
def index():
accounts = Account.query.filter_by(is_active=True).order_by(Account.name).all()
# Recalc balances on page load
for a in accounts:
tab = request.args.get('tab', 'bank')
if tab not in ('bank', 'credit'):
tab = 'bank'
all_accounts = Account.query.filter_by(is_active=True).order_by(Account.name).all()
for a in all_accounts:
calc_balance(a.id)
accounts = Account.query.filter_by(is_active=True).order_by(Account.name).all()
return render_template('accounts/index.html', accounts=accounts)
all_accounts = Account.query.filter_by(is_active=True).order_by(Account.name).all()
bank_accounts = [a for a in all_accounts if a.account_type in BANK_TYPES]
credit_accounts = [a for a in all_accounts if a.account_type == 'credit_card']
accounts = credit_accounts if tab == 'credit' else bank_accounts
return render_template('accounts/index.html',
accounts=accounts,
tab=tab,
bank_count=len(bank_accounts),
credit_count=len(credit_accounts))
@accounts_bp.route('/new', methods=['GET', 'POST'])