06/03 Optimize codes, fix transactions import functions

This commit is contained in:
2026-06-03 10:44:36 -04:00
parent faacd4d91a
commit 3ce779ccfd
3 changed files with 79 additions and 10 deletions
+8 -4
View File
@@ -200,10 +200,14 @@ def parse_transaction(teller_txn, pfm_account_id, category_id_map):
if counterparty and counterparty.upper() != description.upper():
description = counterparty
# Map Teller category to PFM category
teller_cat = (details.get('category') or '').lower()
pfm_cat_name = CATEGORY_MAP.get(teller_cat, 'Other')
category_id = category_id_map.get(pfm_cat_name)
# Auto-categorize: keyword match on description first (most accurate),
# then fall back to Teller's own category field.
from app.services.bank_import_service import auto_categorize
pfm_cat_name = auto_categorize(description)
if not pfm_cat_name:
teller_cat = (details.get('category') or '').lower()
pfm_cat_name = CATEGORY_MAP.get(teller_cat, '')
category_id = category_id_map.get(pfm_cat_name) if pfm_cat_name else None
return {
'teller_id': teller_txn['id'],