Debug: Tilføjet bedre logging til vTiger matching for at identificere problem
This commit is contained in:
parent
64935b5808
commit
0b6d286332
@ -87,11 +87,15 @@ async def sync_from_vtiger() -> Dict[str, Any]:
|
||||
|
||||
# Find existing Hub customer by CVR or normalized name
|
||||
existing = None
|
||||
match_method = None
|
||||
|
||||
if cvr:
|
||||
existing = execute_query(
|
||||
"SELECT id, name, vtiger_id FROM customers WHERE cvr_number = %s",
|
||||
(cvr,)
|
||||
)
|
||||
if existing:
|
||||
match_method = "CVR"
|
||||
|
||||
if not existing:
|
||||
# Match by normalized name
|
||||
@ -100,6 +104,7 @@ async def sync_from_vtiger() -> Dict[str, Any]:
|
||||
for customer in all_customers:
|
||||
if normalize_name(customer['name']) == normalized:
|
||||
existing = [customer]
|
||||
match_method = "navn"
|
||||
break
|
||||
|
||||
if existing:
|
||||
@ -111,7 +116,7 @@ async def sync_from_vtiger() -> Dict[str, Any]:
|
||||
(vtiger_id, existing[0]['id'])
|
||||
)
|
||||
linked_count += 1
|
||||
logger.info(f"🔗 Linket: {existing[0]['name']} → vTiger #{vtiger_id} (CVR: {cvr or 'navn-match'})")
|
||||
logger.info(f"🔗 Linket: {existing[0]['name']} → vTiger #{vtiger_id} (match: {match_method}, CVR: {cvr or 'ingen'})")
|
||||
elif current_vtiger_id != vtiger_id:
|
||||
# Update if different vTiger ID
|
||||
execute_query(
|
||||
@ -125,7 +130,7 @@ async def sync_from_vtiger() -> Dict[str, Any]:
|
||||
execute_query("UPDATE customers SET last_synced_at = NOW() WHERE id = %s", (existing[0]['id'],))
|
||||
else:
|
||||
not_found_count += 1
|
||||
logger.debug(f"⏭️ Ikke fundet i Hub: {name} (CVR: {cvr or 'ingen'})")
|
||||
logger.debug(f"⏭️ Ikke fundet i Hub: '{name}' (CVR: {cvr or 'ingen'}, normalized: '{normalize_name(name)}')")
|
||||
|
||||
logger.info(f"✅ vTiger link sync fuldført: {linked_count} nye linket, {updated_count} opdateret, {not_found_count} ikke fundet af {len(accounts)} totalt")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user