[31f88f42] Keine neuen Commits in dieser Session.
Keine neuen Commits in dieser Session.
This commit is contained in:
@@ -73,6 +73,19 @@ def get_company_details(company_id: int) -> dict:
|
||||
"""Holt die vollständigen Details zu einem Unternehmen."""
|
||||
return _make_api_request("GET", f"/companies/{company_id}")
|
||||
|
||||
def match_company(name: str, website: str = None, city: str = None) -> dict:
|
||||
"""
|
||||
Gleicht ein Unternehmen über den zentralen Matching-Service im Company Explorer ab.
|
||||
Gibt potenzielle Treffer mit Scores und SuperOffice Contact IDs zurück.
|
||||
"""
|
||||
payload = {
|
||||
"name": name,
|
||||
"website": website,
|
||||
"city": city,
|
||||
"country": "Deutschland"
|
||||
}
|
||||
return _make_api_request("POST", "/match-company", json_data=payload)
|
||||
|
||||
def create_contact(company_id: int, contact_data: dict) -> dict:
|
||||
"""Erstellt einen neuen Kontakt für ein Unternehmen im Company Explorer."""
|
||||
payload = {
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user