[31f88f42] Keine neuen Commits in dieser Session.

Keine neuen Commits in dieser Session.
This commit is contained in:
2026-03-10 13:54:07 +00:00
parent a3f79db2d2
commit 3fd3c5acfa
8 changed files with 268 additions and 9 deletions

View File

@@ -18,7 +18,17 @@ from sqlalchemy.orm import sessionmaker
# --- Setup Logging ---
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
import msal
from .models import init_db, ProposalJob, ProposedSlot
# Import centralized matching service
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
try:
from company_explorer_connector import match_company
except ImportError:
logging.warning("Could not import company_explorer_connector. Matching logic might be disabled.")
def match_company(name, **kwargs): return {"match_found": False}
# --- Database Setup (SQLite) ---
class TestLeadPayload(BaseModel):
company_name: str
@@ -351,6 +361,19 @@ def book_slot(job_uuid: str, ts: int):
return HTMLResponse(content=FALLBACK_HTML.format(ms_bookings_url=MS_BOOKINGS_URL))
if create_calendar_invite(job.customer_email, job.customer_company, slot_time):
# NEW: Account Matching in SuperOffice (via Company Explorer)
try:
logging.info(f"MATCHING ACCOUNT: Checking for '{job.customer_company}' before Sale creation...")
match_res = match_company(job.customer_company)
if match_res.get("match_found"):
best = match_res["best_match"]
logging.info(f"✅ MATCH SUCCESS: Found CRM ID {best['crm_id']} for '{best['name']}' (Score: {best['score']})")
# This CRM ID can now be used for the subsequent Sale creation in the next task.
else:
logging.warning(f"⚠️ NO MATCH FOUND in SuperOffice for '{job.customer_company}'. A new account will be needed.")
except Exception as e:
logging.error(f"❌ ERROR during SuperOffice Matching check: {e}")
job.status = "booked"
db.commit()
db.close()