diff --git a/app/settings/frontend/settings.html b/app/settings/frontend/settings.html index 892712a..30a7493 100644 --- a/app/settings/frontend/settings.html +++ b/app/settings/frontend/settings.html @@ -1540,7 +1540,8 @@ async function syncFromEconomic() { const result = await response.json(); const details = [ `Behandlet: ${result.total_processed || 0}`, - `Matchet: ${result.matched || 0}`, + `Nye matchet: ${result.matched || 0}`, + `Verificeret: ${result.verified || 0}`, `Ikke matchet: ${result.not_matched || 0}` ].join(' | '); addSyncLogEntry( diff --git a/app/system/backend/sync_router.py b/app/system/backend/sync_router.py index 920481e..2ca3a13 100644 --- a/app/system/backend/sync_router.py +++ b/app/system/backend/sync_router.py @@ -326,6 +326,7 @@ async def sync_from_economic() -> Dict[str, Any]: logger.info(f"📥 Fetched {len(economic_customers)} customers from e-conomic ({page} pages)") matched_count = 0 + verified_count = 0 not_matched_count = 0 for eco_customer in economic_customers: @@ -346,7 +347,7 @@ async def sync_from_economic() -> Dict[str, Any]: matched = None if cvr: matched = execute_query( - "SELECT id, name FROM customers WHERE cvr_number = %s", + "SELECT id, name, economic_customer_number FROM customers WHERE cvr_number = %s", (cvr,) ) @@ -372,17 +373,17 @@ async def sync_from_economic() -> Dict[str, Any]: else: # Already has number, just update sync timestamp execute_query("UPDATE customers SET last_synced_at = NOW() WHERE id = %s", (matched[0]['id'],)) - logger.debug(f"✓ Verificeret: {matched[0]['name']} → #{customer_number}") + verified_count += 1 else: not_matched_count += 1 - logger.debug(f"❌ Ikke matchet: {name} (CVR: {cvr or 'ingen'})") logger.info(f"✅ e-conomic sync fuldført: {matched_count} matchet, {not_matched_count} ikke matchet af {len(economic_customers)} totalt") + nye matchet, {verified_count} verificeret, {not_matched_count} ikke matchet af {len(economic_customers)} totalt") return { "status": "success", "matched": matched_count, - "not_matched": not_matched_count, + "verified": verifiot_matched_count, "total_processed": len(economic_customers) }