bmc_hub/test_vtiger_contact.py
Christian 8ac3a9db2f v1.3.64 - Redesigned sync architecture with clear field ownership
BREAKING CHANGES:
- vTiger sync: Never overwrites existing vtiger_id
- Contact sync: REPLACES links instead of appending (idempotent)
- E-conomic sync: Only updates fields it owns (address, city, postal, email_domain, website)
- E-conomic sync: Does NOT overwrite name or cvr_number anymore

ARCHITECTURE:
- Each data source owns specific fields
- Sync operations are now idempotent (can run multiple times)
- Clear documentation of field ownership in sync_router.py
- Contact links deleted and recreated on sync to match vTiger state

FIXED:
- Contact relationships now correct after re-sync
- No more mixed customer data from different sources
- Sorting contacts by company_count DESC (companies first)
2025-12-24 10:34:13 +01:00

45 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""
Test script to check vTiger contact data
"""
import asyncio
import sys
sys.path.insert(0, '/Users/christianthomas/DEV/bmc_hub_dev')
from app.services.vtiger_service import VTigerService
async def test_contact():
vtiger = VTigerService()
# Fetch contact by email
query = "SELECT id, firstname, lastname, email, account_id FROM Contacts WHERE email = 'accounting@arbodania.com';"
print(f"Query: {query}")
result = await vtiger.query(query)
if result:
contact = result[0]
print(f"\n✅ Contact found:")
print(f" ID: {contact.get('id')}")
print(f" Name: {contact.get('firstname')} {contact.get('lastname')}")
print(f" Email: {contact.get('email')}")
print(f" Account ID: {contact.get('account_id')}")
# Now fetch the account details
account_id = contact.get('account_id')
if account_id:
account_query = f"SELECT id, accountname FROM Accounts WHERE id = '{account_id}';"
print(f"\nFetching account: {account_query}")
account_result = await vtiger.query(account_query)
if account_result:
account = account_result[0]
print(f"\n✅ Account found:")
print(f" ID: {account.get('id')}")
print(f" Name: {account.get('accountname')}")
else:
print("❌ Contact not found")
if __name__ == "__main__":
asyncio.run(test_contact())