06/02 Modified bank sync, records selectable

This commit is contained in:
2026-06-02 10:09:31 -04:00
parent 88cf1253fd
commit 04649530f7
2 changed files with 105 additions and 34 deletions
+17 -3
View File
@@ -199,16 +199,20 @@ def sync_preview_view(teller_account_id):
]
session['teller_account_id'] = teller_account_id
from app.models.category import Category
cat_map = {c.id: c.name for c in Category.query.filter_by(is_active=True).all()}
return render_template('teller/preview.html',
ta=ta,
preview=preview,
count=len(preview))
count=len(preview),
cat_map=cat_map)
@teller_bp.route('/sync/confirm', methods=['POST'])
@login_required
def sync_confirm():
"""Import the previewed transactions."""
"""Import selected previewed transactions with optional type overrides."""
raw = session.pop('teller_preview', [])
ta_id = session.pop('teller_account_id', None)
@@ -218,13 +222,23 @@ def sync_confirm():
ta = db.get_or_404(TellerAccount, ta_id)
# Reconstruct parsed list with date objects
selected_ids = set(request.form.getlist('selected'))
from datetime import date as date_cls
parsed = []
for r in raw:
if selected_ids and r['teller_id'] not in selected_ids:
continue
r['date'] = date_cls.fromisoformat(r['date'])
override = request.form.get(f'type_{r["teller_id"]}')
if override in ('income', 'expense'):
r['transaction_type'] = override
parsed.append(r)
if not parsed:
flash('No transactions selected. Nothing was imported.', 'warning')
return redirect(url_for('teller.index'))
imported, skipped = import_transactions(parsed, ta)
flash(f'Imported {imported} transaction(s) from {ta.account_name}. '
f'Skipped {skipped} duplicate(s).', 'success')