update
This commit is contained in:
@@ -465,6 +465,34 @@ def lookup_practice_id_for_license_email(email: str) -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
def lookup_license_email_for_practice(practice_id: str) -> Optional[str]:
|
||||
"""Liefert die zuletzt aktuelle Lizenz-/Kunden-E-Mail fuer eine Mandanten-practice_id."""
|
||||
_ensure_storage()
|
||||
pid = (practice_id or "").strip()
|
||||
if not pid:
|
||||
return None
|
||||
try:
|
||||
with sqlite3.connect(DB_PATH) as con:
|
||||
row = con.execute(
|
||||
"""
|
||||
SELECT customer_email FROM licenses
|
||||
WHERE practice_id = ?
|
||||
AND customer_email IS NOT NULL
|
||||
AND trim(customer_email) != ''
|
||||
AND lower(trim(customer_email)) LIKE '%@%'
|
||||
ORDER BY updated_at DESC
|
||||
LIMIT 1
|
||||
""",
|
||||
(pid,),
|
||||
).fetchone()
|
||||
if not row or not row[0]:
|
||||
return None
|
||||
em = str(row[0]).strip()
|
||||
return em if em else None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def _upsert_license(
|
||||
*,
|
||||
subscription_id: str,
|
||||
|
||||
Reference in New Issue
Block a user