méthodes de contact utilitaures
This commit is contained in:
parent
800d828f75
commit
09e3589132
1 changed files with 46 additions and 18 deletions
|
|
@ -7524,34 +7524,62 @@ class SageConnector:
|
||||||
|
|
||||||
|
|
||||||
def _contact_to_dict(self, contact) -> Dict:
|
def _contact_to_dict(self, contact) -> Dict:
|
||||||
"""Convertit un objet COM Contact en dictionnaire"""
|
"""
|
||||||
|
Convertit un objet COM Contact (IBOTiersContact3) en dictionnaire
|
||||||
|
VERSION REFACTORISÉE
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
civilite_code = getattr(contact, "CT_Civilite", None)
|
# IBOTiersContact3 utilise Nom/Prenom (sans préfixe CT_)
|
||||||
|
civilite_code = getattr(contact, "Civilite", None)
|
||||||
civilite_map = {0: "M.", 1: "Mme", 2: "Mlle", 3: "Société"}
|
civilite_map = {0: "M.", 1: "Mme", 2: "Mlle", 3: "Société"}
|
||||||
civilite = civilite_map.get(civilite_code) if civilite_code is not None else None
|
civilite = civilite_map.get(civilite_code) if civilite_code is not None else None
|
||||||
|
|
||||||
|
# Coordonnées via Telecom
|
||||||
|
telephone = None
|
||||||
|
portable = None
|
||||||
|
telecopie = None
|
||||||
|
email = None
|
||||||
|
|
||||||
|
if hasattr(contact, 'Telecom'):
|
||||||
|
try:
|
||||||
|
telecom = contact.Telecom
|
||||||
|
telephone = self._safe_strip(getattr(telecom, "Telephone", None))
|
||||||
|
portable = self._safe_strip(getattr(telecom, "Portable", None))
|
||||||
|
telecopie = self._safe_strip(getattr(telecom, "Telecopie", None))
|
||||||
|
email = self._safe_strip(getattr(telecom, "EMail", None))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Récupérer CT_No et N_Contact via SQL si possible
|
||||||
|
# Car IBOTiersContact3 du DossierContact ne les a pas
|
||||||
|
contact_numero = None
|
||||||
|
n_contact = None
|
||||||
|
numero = None
|
||||||
|
|
||||||
|
# Ces infos doivent venir de F_CONTACTT
|
||||||
|
# On les passe plutôt en paramètre ou on les récupère différemment
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"numero": self._safe_strip(getattr(contact, "CT_Num", None)),
|
"numero": numero, # À passer en paramètre
|
||||||
"contact_numero": getattr(contact, "CT_No", None),
|
"contact_numero": contact_numero, # À passer en paramètre
|
||||||
"n_contact": getattr(contact, "N_Contact", None),
|
"n_contact": n_contact, # À passer en paramètre
|
||||||
"civilite": civilite,
|
"civilite": civilite,
|
||||||
"nom": self._safe_strip(getattr(contact, "CT_Nom", None)),
|
"nom": self._safe_strip(getattr(contact, "Nom", None)),
|
||||||
"prenom": self._safe_strip(getattr(contact, "CT_Prenom", None)),
|
"prenom": self._safe_strip(getattr(contact, "Prenom", None)),
|
||||||
"fonction": self._safe_strip(getattr(contact, "CT_Fonction", None)),
|
"fonction": self._safe_strip(getattr(contact, "Fonction", None)),
|
||||||
"service_code": getattr(contact, "N_Service", None),
|
"service_code": getattr(contact, "ServiceContact", None),
|
||||||
"telephone": self._safe_strip(getattr(contact, "CT_Telephone", None)),
|
"telephone": telephone,
|
||||||
"portable": self._safe_strip(getattr(contact, "CT_TelPortable", None)),
|
"portable": portable,
|
||||||
"telecopie": self._safe_strip(getattr(contact, "CT_Telecopie", None)),
|
"telecopie": telecopie,
|
||||||
"email": self._safe_strip(getattr(contact, "CT_EMail", None)),
|
"email": email,
|
||||||
"facebook": self._safe_strip(getattr(contact, "CT_Facebook", None)),
|
"facebook": self._safe_strip(getattr(contact, "Facebook", None)),
|
||||||
"linkedin": self._safe_strip(getattr(contact, "CT_LinkedIn", None)),
|
"linkedin": self._safe_strip(getattr(contact, "LinkedIn", None)),
|
||||||
"skype": self._safe_strip(getattr(contact, "CT_Skype", None)),
|
"skype": self._safe_strip(getattr(contact, "Skype", None)),
|
||||||
}
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Erreur conversion contact: {e}")
|
logger.warning(f"Erreur conversion contact: {e}")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def _row_to_contact_dict(self, row) -> Dict:
|
def _row_to_contact_dict(self, row) -> Dict:
|
||||||
"""Convertit une ligne SQL en dictionnaire contact"""
|
"""Convertit une ligne SQL en dictionnaire contact"""
|
||||||
civilite_code = row.CT_Civilite
|
civilite_code = row.CT_Civilite
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue