Add verified count to e-conomic sync (separate new matches from existing verifications)
This commit is contained in:
parent
030071e8d5
commit
8b71524437
@ -1540,7 +1540,8 @@ async function syncFromEconomic() {
|
|||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
const details = [
|
const details = [
|
||||||
`Behandlet: ${result.total_processed || 0}`,
|
`Behandlet: ${result.total_processed || 0}`,
|
||||||
`Matchet: ${result.matched || 0}`,
|
`Nye matchet: ${result.matched || 0}`,
|
||||||
|
`Verificeret: ${result.verified || 0}`,
|
||||||
`Ikke matchet: ${result.not_matched || 0}`
|
`Ikke matchet: ${result.not_matched || 0}`
|
||||||
].join(' | ');
|
].join(' | ');
|
||||||
addSyncLogEntry(
|
addSyncLogEntry(
|
||||||
|
|||||||
@ -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)")
|
logger.info(f"📥 Fetched {len(economic_customers)} customers from e-conomic ({page} pages)")
|
||||||
|
|
||||||
matched_count = 0
|
matched_count = 0
|
||||||
|
verified_count = 0
|
||||||
not_matched_count = 0
|
not_matched_count = 0
|
||||||
|
|
||||||
for eco_customer in economic_customers:
|
for eco_customer in economic_customers:
|
||||||
@ -346,7 +347,7 @@ async def sync_from_economic() -> Dict[str, Any]:
|
|||||||
matched = None
|
matched = None
|
||||||
if cvr:
|
if cvr:
|
||||||
matched = execute_query(
|
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,)
|
(cvr,)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -372,17 +373,17 @@ async def sync_from_economic() -> Dict[str, Any]:
|
|||||||
else:
|
else:
|
||||||
# Already has number, just update sync timestamp
|
# Already has number, just update sync timestamp
|
||||||
execute_query("UPDATE customers SET last_synced_at = NOW() WHERE id = %s", (matched[0]['id'],))
|
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:
|
else:
|
||||||
not_matched_count += 1
|
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")
|
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 {
|
return {
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"matched": matched_count,
|
"matched": matched_count,
|
||||||
"not_matched": not_matched_count,
|
"verified": verifiot_matched_count,
|
||||||
"total_processed": len(economic_customers)
|
"total_processed": len(economic_customers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user