Enhance: Address/VAT Sync & Infrastructure Hardening [30e88f42]

- Implemented Address (City) and VAT (OrgNumber) sync back to SuperOffice.
- Hardened Infrastructure: Removed Pydantic dependency in config for better Docker compatibility.
- Improved SuperOffice Client error logging and handled empty SO_ENVIRONMENT variables.
- Updated Matrix Generator: Switched to gemini-2.0-flash, added industry filtering, and robust JSON parsing.
- Updated Documentation with session findings and troubleshooting steps.
This commit is contained in:
2026-02-21 21:26:57 +00:00
parent 1acdad9923
commit b41b6c38b8
8 changed files with 169 additions and 51 deletions

View File

@@ -210,6 +210,44 @@ def process_job(job, so_client: SuperOfficeClient):
else:
logger.warning(f"Vertical '{vertical_name}' not found in internal mapping.")
# 2b.2 Sync Address & VAT (Standard Fields)
# Check if we have address data to sync
ce_city = provisioning_data.get("address_city")
ce_country = provisioning_data.get("address_country") # Assuming 'DE' code or similar
ce_vat = provisioning_data.get("vat_id")
if ce_city or ce_vat:
try:
# Re-fetch contact to be safe (or use cached if optimal)
contact_data = so_client.get_contact(contact_id)
changed = False
# City (PostalAddress)
if ce_city:
# SuperOffice Address structure is complex. Simplified check on PostalAddress.
# Address: { "PostalAddress": { "City": "..." } }
current_city = contact_data.get("PostalAddress", {}).get("City", "")
if current_city != ce_city:
if "PostalAddress" not in contact_data: contact_data["PostalAddress"] = {}
contact_data["PostalAddress"]["City"] = ce_city
changed = True
logger.info(f"Updating City: {current_city} -> {ce_city}")
# VAT (OrgNumber)
if ce_vat:
current_vat = contact_data.get("OrgNumber", "")
if current_vat != ce_vat:
contact_data["OrgNumber"] = ce_vat
changed = True
logger.info(f"Updating VAT: {current_vat} -> {ce_vat}")
if changed:
logger.info(f"Pushing standard field updates for Contact {contact_id}...")
so_client._put(f"Contact/{contact_id}", contact_data)
except Exception as e:
logger.error(f"Failed to sync Address/VAT for Contact {contact_id}: {e}")
# 2c. Sync Website (Company Level)
# TEMPORARILY DISABLED TO PREVENT LOOP (SO API Read-after-Write latency or field mapping issue)
# Re-enable via config if needed