- Added KommunikationSyncManager class to handle synchronization logic. - Implemented methods for loading data, computing diffs, and applying changes between Advoware and EspoCRM. - Introduced 3-way diffing mechanism to intelligently resolve conflicts. - Added helper methods for creating empty slots and detecting changes in communications. - Enhanced logging for better traceability during synchronization processes.
110 lines
3.3 KiB
Python
110 lines
3.3 KiB
Python
"""
|
|
Test: Was liefert kommArt im Vergleich zu kommKz?
|
|
|
|
kommArt sollte sein:
|
|
- 0 = Telefon/Fax
|
|
- 1 = Email
|
|
- 2 = Internet
|
|
|
|
Wenn kommArt funktioniert, können wir damit unterscheiden!
|
|
"""
|
|
|
|
import asyncio
|
|
from services.advoware import AdvowareAPI
|
|
|
|
TEST_BETNR = 104860
|
|
|
|
|
|
class SimpleContext:
|
|
class Logger:
|
|
def info(self, msg): print(f"[INFO] {msg}")
|
|
def error(self, msg): print(f"[ERROR] {msg}")
|
|
def warning(self, msg): print(f"[WARN] {msg}")
|
|
def debug(self, msg): pass
|
|
|
|
def __init__(self):
|
|
self.logger = self.Logger()
|
|
|
|
|
|
def print_section(title):
|
|
print("\n" + "="*70)
|
|
print(title)
|
|
print("="*70)
|
|
|
|
|
|
async def main():
|
|
print("\n" + "="*70)
|
|
print("ADVOWARE kommArt vs kommKz")
|
|
print("="*70)
|
|
|
|
context = SimpleContext()
|
|
advo = AdvowareAPI(context)
|
|
|
|
# Hole Beteiligte mit Kommunikationen
|
|
result = await advo.api_call(f'api/v1/advonet/Beteiligte/{TEST_BETNR}')
|
|
beteiligte = result[0]
|
|
kommunikationen = beteiligte.get('kommunikation', [])
|
|
|
|
print(f"\n✅ {len(kommunikationen)} Kommunikationen gefunden\n")
|
|
print(f"{'ID':>8s} | {'kommKz':>6s} | {'kommArt':>7s} | {'Wert':40s}")
|
|
print("-" * 70)
|
|
|
|
kommkz_values = []
|
|
kommart_values = []
|
|
|
|
for k in kommunikationen:
|
|
komm_id = k.get('id')
|
|
kommkz = k.get('kommKz', 'N/A')
|
|
kommart = k.get('kommArt', 'N/A')
|
|
wert = k.get('tlf', '')[:40]
|
|
|
|
kommkz_values.append(kommkz)
|
|
kommart_values.append(kommart)
|
|
|
|
# Markiere wenn Wert aussagekräftig ist
|
|
kommkz_str = f"{kommkz}" if kommkz != 0 else f"❌ {kommkz}"
|
|
kommart_str = f"{kommart}" if kommart != 0 else f"❌ {kommart}"
|
|
|
|
print(f"{komm_id:8d} | {kommkz_str:>6s} | {kommart_str:>7s} | {wert}")
|
|
|
|
print_section("ANALYSE")
|
|
|
|
# Statistik
|
|
print(f"\n📊 kommKz Werte:")
|
|
print(f" • Alle Werte: {set(kommkz_values)}")
|
|
print(f" • Alle sind 0: {all(v == 0 for v in kommkz_values)}")
|
|
|
|
print(f"\n📊 kommArt Werte:")
|
|
print(f" • Alle Werte: {set(kommart_values)}")
|
|
print(f" • Alle sind 0: {all(v == 0 for v in kommart_values)}")
|
|
|
|
print_section("FAZIT")
|
|
|
|
if not all(v == 0 for v in kommart_values):
|
|
print("\n✅ kommArt IST BRAUCHBAR!")
|
|
print("\nMapping:")
|
|
print(" 0 = Telefon/Fax")
|
|
print(" 1 = Email")
|
|
print(" 2 = Internet")
|
|
|
|
print("\n🎉 PERFEKT! Wir können unterscheiden:")
|
|
print(" • kommArt=0 → Telefon (zu phoneNumberData)")
|
|
print(" • kommArt=1 → Email (zu emailAddressData)")
|
|
print(" • kommArt=2 → Internet (überspringen oder zu Notiz)")
|
|
|
|
print("\n💡 Advoware → EspoCRM:")
|
|
print(" 1. Nutze kommArt um Typ zu erkennen")
|
|
print(" 2. Speichere in bemerkung: [ESPOCRM:hash:kommArt]")
|
|
print(" 3. Bei Reverse-Sync: Nutze kommArt aus bemerkung")
|
|
|
|
else:
|
|
print("\n❌ kommArt ist AUCH 0 - genau wie kommKz")
|
|
print("\n→ Wir müssen Typ aus Wert ableiten (Email vs. Telefon)")
|
|
print(" • '@' im Wert → Email")
|
|
print(" • '+' oder Ziffern → Telefon")
|
|
print("\n→ Feinere Unterscheidung (TelGesch vs TelPrivat) NICHT möglich")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|