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

@@ -1,44 +1,37 @@
import os
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
# --- Infrastructure ---
# Internal Docker URL for Company Explorer
COMPANY_EXPLORER_URL: str = "http://company-explorer:8000"
# --- SuperOffice API Credentials ---
SO_ENVIRONMENT: str = "sod" # 'sod' or 'online'
SO_CLIENT_ID: str = ""
SO_CLIENT_SECRET: str = ""
SO_REFRESH_TOKEN: str = ""
SO_REDIRECT_URI: str = "http://localhost"
SO_CONTEXT_IDENTIFIER: str = "Cust55774" # e.g. Cust12345
# --- Feature Flags ---
ENABLE_WEBSITE_SYNC: bool = False # Disabled by default to prevent loops
# --- Mappings (IDs from SuperOffice) ---
# Vertical IDs (List Items)
# Default values match the current hardcoded DEV IDs
# Format: "Name In Explorer": ID_In_SuperOffice
VERTICAL_MAP_JSON: str = '{"Logistics - Warehouse": 23, "Healthcare - Hospital": 24, "Infrastructure - Transport": 25, "Leisure - Indoor Active": 26}'
class Settings:
def __init__(self):
# --- Infrastructure ---
# Internal Docker URL for Company Explorer
self.COMPANY_EXPLORER_URL = os.getenv("COMPANY_EXPLORER_URL", "http://company-explorer:8000")
# --- SuperOffice API Credentials ---
# Fallback for empty string in env var
env_val = os.getenv("SO_ENVIRONMENT")
self.SO_ENVIRONMENT = env_val if env_val else "sod"
self.SO_CLIENT_ID = os.getenv("SO_CLIENT_ID", "")
self.SO_CLIENT_SECRET = os.getenv("SO_CLIENT_SECRET", "")
self.SO_REFRESH_TOKEN = os.getenv("SO_REFRESH_TOKEN", "")
self.SO_REDIRECT_URI = os.getenv("SO_REDIRECT_URI", "http://localhost")
self.SO_CONTEXT_IDENTIFIER = os.getenv("SO_CONTEXT_IDENTIFIER", "Cust55774") # e.g. Cust12345
# --- Feature Flags ---
self.ENABLE_WEBSITE_SYNC = os.getenv("ENABLE_WEBSITE_SYNC", "False").lower() in ("true", "1", "t")
# --- Mappings (IDs from SuperOffice) ---
# Vertical IDs (List Items)
self.VERTICAL_MAP_JSON = os.getenv("VERTICAL_MAP_JSON", '{"Logistics - Warehouse": 23, "Healthcare - Hospital": 24, "Infrastructure - Transport": 25, "Leisure - Indoor Active": 26}')
# Persona / Job Role IDs (List Items for "Position" field)
# To be filled after discovery
PERSONA_MAP_JSON: str = '{}'
# Persona / Job Role IDs (List Items for "Position" field)
self.PERSONA_MAP_JSON = os.getenv("PERSONA_MAP_JSON", '{}')
# User Defined Fields (ProgIDs)
# The technical names of the fields in SuperOffice
# Default values match the current hardcoded DEV UDFs
UDF_SUBJECT: str = "SuperOffice:5"
UDF_INTRO: str = "SuperOffice:6"
UDF_SOCIAL_PROOF: str = "SuperOffice:7"
UDF_VERTICAL: str = "SuperOffice:5" # NOTE: Currently same as Subject in dev? Need to verify. worker.py had 'SuperOffice:5' for vertical AND 'SuperOffice:5' for subject in the map?
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
extra = "ignore" # Ignore extra fields in .env
# User Defined Fields (ProgIDs)
self.UDF_SUBJECT = os.getenv("UDF_SUBJECT", "SuperOffice:5")
self.UDF_INTRO = os.getenv("UDF_INTRO", "SuperOffice:6")
self.UDF_SOCIAL_PROOF = os.getenv("UDF_SOCIAL_PROOF", "SuperOffice:7")
self.UDF_VERTICAL = os.getenv("UDF_VERTICAL", "SuperOffice:5")
# Global instance
settings = Settings()
settings = Settings()