feat: Implement address synchronization between EspoCRM and Advoware

- Add AdressenMapper for transforming addresses between EspoCRM and Advoware formats.
- Create AdressenSync class to handle address creation, update, and deletion synchronization.
- Introduce NotificationManager for managing manual intervention notifications in case of sync issues.
- Implement detailed logging for address sync operations and error handling.
- Ensure READ-ONLY field changes are detected and notified for manual resolution.
This commit is contained in:
2026-02-08 14:29:29 +00:00
parent 68c8b398aa
commit c770f2c8ee
15 changed files with 6427 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
#!/usr/bin/env python3
"""
Test: Welche Felder sind bei PUT wirklich änderbar?
====================================================
"""
import asyncio
import sys
import os
import json
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from services.advoware import AdvowareAPI
TEST_BETNR = 104860
BOLD = '\033[1m'
RED = '\033[91m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
BLUE = '\033[94m'
RESET = '\033[0m'
def print_success(text):
print(f"{GREEN}{text}{RESET}")
def print_error(text):
print(f"{RED}{text}{RESET}")
def print_info(text):
print(f"{BLUE} {text}{RESET}")
class SimpleLogger:
def info(self, msg): pass
def error(self, msg): pass
def debug(self, msg): pass
def warning(self, msg): pass
class SimpleContext:
def __init__(self):
self.logger = SimpleLogger()
async def main():
print(f"\n{BOLD}=== PUT Response Analyse ==={RESET}\n")
context = SimpleContext()
advo = AdvowareAPI(context=context)
# Finde Test-Adresse
all_addresses = await advo.api_call(
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
method='GET'
)
test_addr = None
for addr in all_addresses:
bemerkung = addr.get('bemerkung') or ''
if 'TEST-SOFTDELETE' in bemerkung:
test_addr = addr
break
if not test_addr:
print_error("Test-Adresse nicht gefunden")
return
index = test_addr.get('reihenfolgeIndex')
print_info(f"Test-Adresse Index: {index}")
print_info("\nVORHER:")
print(json.dumps(test_addr, indent=2, ensure_ascii=False))
# PUT mit ALLEN Feldern inklusive gueltigBis
print_info("\n=== Sende PUT mit ALLEN Feldern ===")
update_data = {
"strasse": "GEÄNDERT Straße",
"plz": "11111",
"ort": "GEÄNDERT Ort",
"land": "AT",
"postfach": "PF 123",
"postfachPLZ": "11112",
"anschrift": "GEÄNDERT Anschrift",
"standardAnschrift": True,
"bemerkung": "VERSUCH: bemerkung ändern",
"gueltigVon": "2025-01-01T00:00:00", # ← GEÄNDERT
"gueltigBis": "2027-12-31T23:59:59" # ← NEU GESETZT
}
print(json.dumps(update_data, indent=2, ensure_ascii=False))
result = await advo.api_call(
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen/{index}',
method='PUT',
json_data=update_data
)
print_info("\n=== PUT Response: ===")
print(json.dumps(result, indent=2, ensure_ascii=False))
# GET und vergleichen
print_info("\n=== GET nach PUT: ===")
all_addresses = await advo.api_call(
f'/api/v1/advonet/Beteiligte/{TEST_BETNR}/Adressen',
method='GET'
)
updated_addr = next((a for a in all_addresses if a.get('reihenfolgeIndex') == index), None)
if updated_addr:
print(json.dumps(updated_addr, indent=2, ensure_ascii=False))
print(f"\n{BOLD}=== VERGLEICH: Was wurde wirklich geändert? ==={RESET}\n")
fields = ['strasse', 'plz', 'ort', 'land', 'postfach', 'postfachPLZ',
'anschrift', 'standardAnschrift', 'bemerkung', 'gueltigVon', 'gueltigBis']
for field in fields:
sent = update_data.get(field)
received = updated_addr.get(field)
if sent == received:
print_success(f"{field:20s}: ✓ GEÄNDERT → {received}")
else:
print_error(f"{field:20s}: ✗ NICHT geändert (sent: {sent}, got: {received})")
if __name__ == "__main__":
asyncio.run(main())