06/03 Optimize codes, fix transactions import functions
This commit is contained in:
@@ -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'],
|
||||
|
||||
Reference in New Issue
Block a user