fix(universign): add missing api_url parameter to document service
This commit is contained in:
parent
24d7a49a73
commit
d6ed8792cc
2 changed files with 17 additions and 15 deletions
|
|
@ -1531,6 +1531,7 @@ async def telecharger_documents_manquants(
|
||||||
logger.info(f"📥 {len(transactions)} document(s) à télécharger")
|
logger.info(f"📥 {len(transactions)} document(s) à télécharger")
|
||||||
|
|
||||||
document_service = UniversignDocumentService(
|
document_service = UniversignDocumentService(
|
||||||
|
api_url=settings.universign_api_url,
|
||||||
api_key=settings.universign_api_key, timeout=60
|
api_key=settings.universign_api_key, timeout=60
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -1596,6 +1597,7 @@ async def nettoyer_anciens_documents(
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
document_service = UniversignDocumentService(
|
document_service = UniversignDocumentService(
|
||||||
|
api_url=settings.universign_api_url,
|
||||||
api_key=settings.universign_api_key
|
api_key=settings.universign_api_key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -322,7 +322,6 @@ class UniversignSyncService:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Erreur création signer {email}: {e}")
|
logger.error(f"Erreur création signer {email}: {e}")
|
||||||
|
|
||||||
|
|
||||||
async def sync_transaction(
|
async def sync_transaction(
|
||||||
self,
|
self,
|
||||||
session,
|
session,
|
||||||
|
|
@ -330,7 +329,7 @@ class UniversignSyncService:
|
||||||
force: bool = False,
|
force: bool = False,
|
||||||
):
|
):
|
||||||
import json
|
import json
|
||||||
|
|
||||||
# Si statut final et pas de force, skip
|
# Si statut final et pas de force, skip
|
||||||
if is_final_status(transaction.local_status.value) and not force:
|
if is_final_status(transaction.local_status.value) and not force:
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|
@ -395,7 +394,9 @@ class UniversignSyncService:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logger.warning(f"⚠️ Statut Universign inconnu: {universign_status_raw}")
|
logger.warning(f"⚠️ Statut Universign inconnu: {universign_status_raw}")
|
||||||
if new_local_status == "SIGNE":
|
if new_local_status == "SIGNE":
|
||||||
transaction.universign_status = UniversignTransactionStatus.COMPLETED
|
transaction.universign_status = (
|
||||||
|
UniversignTransactionStatus.COMPLETED
|
||||||
|
)
|
||||||
elif new_local_status == "REFUSE":
|
elif new_local_status == "REFUSE":
|
||||||
transaction.universign_status = UniversignTransactionStatus.REFUSED
|
transaction.universign_status = UniversignTransactionStatus.REFUSED
|
||||||
elif new_local_status == "EXPIRE":
|
elif new_local_status == "EXPIRE":
|
||||||
|
|
@ -427,7 +428,7 @@ class UniversignSyncService:
|
||||||
# === SECTION CORRIGÉE: Gestion des documents ===
|
# === SECTION CORRIGÉE: Gestion des documents ===
|
||||||
# Ne plus chercher document_url dans la réponse (elle n'existe pas!)
|
# Ne plus chercher document_url dans la réponse (elle n'existe pas!)
|
||||||
# Le téléchargement se fait via le service document qui utilise le bon endpoint
|
# Le téléchargement se fait via le service document qui utilise le bon endpoint
|
||||||
|
|
||||||
documents = universign_data.get("documents", [])
|
documents = universign_data.get("documents", [])
|
||||||
if documents:
|
if documents:
|
||||||
first_doc = documents[0]
|
first_doc = documents[0]
|
||||||
|
|
@ -435,30 +436,27 @@ class UniversignSyncService:
|
||||||
f"📄 Document Universign trouvé: id={first_doc.get('id')}, "
|
f"📄 Document Universign trouvé: id={first_doc.get('id')}, "
|
||||||
f"status={first_doc.get('status')}"
|
f"status={first_doc.get('status')}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Téléchargement automatique du document signé
|
# Téléchargement automatique du document signé
|
||||||
if new_local_status == "SIGNE" and not transaction.signed_document_path:
|
if new_local_status == "SIGNE" and not transaction.signed_document_path:
|
||||||
logger.info("📥 Déclenchement téléchargement document signé...")
|
logger.info("📥 Déclenchement téléchargement document signé...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
(
|
(
|
||||||
download_success,
|
download_success,
|
||||||
download_error,
|
download_error,
|
||||||
) = await self.document_service.download_and_store_signed_document(
|
) = await self.document_service.download_and_store_signed_document(
|
||||||
session=session,
|
session=session, transaction=transaction, force=False
|
||||||
transaction=transaction,
|
|
||||||
force=False
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if download_success:
|
if download_success:
|
||||||
logger.info("✅ Document signé téléchargé et stocké")
|
logger.info("✅ Document signé téléchargé et stocké")
|
||||||
else:
|
else:
|
||||||
logger.warning(f"⚠️ Échec téléchargement: {download_error}")
|
logger.warning(f"⚠️ Échec téléchargement: {download_error}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"❌ Erreur téléchargement document: {e}",
|
f"❌ Erreur téléchargement document: {e}", exc_info=True
|
||||||
exc_info=True
|
|
||||||
)
|
)
|
||||||
# === FIN SECTION CORRIGÉE ===
|
# === FIN SECTION CORRIGÉE ===
|
||||||
|
|
||||||
|
|
@ -496,7 +494,9 @@ class UniversignSyncService:
|
||||||
# Exécuter les actions post-changement
|
# Exécuter les actions post-changement
|
||||||
if status_changed:
|
if status_changed:
|
||||||
logger.info(f"🎬 Exécution actions pour statut: {new_local_status}")
|
logger.info(f"🎬 Exécution actions pour statut: {new_local_status}")
|
||||||
await self._execute_status_actions(session, transaction, new_local_status)
|
await self._execute_status_actions(
|
||||||
|
session, transaction, new_local_status
|
||||||
|
)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"✅ Sync terminée: {transaction.transaction_id} | "
|
f"✅ Sync terminée: {transaction.transaction_id} | "
|
||||||
|
|
@ -518,7 +518,7 @@ class UniversignSyncService:
|
||||||
await session.commit()
|
await session.commit()
|
||||||
|
|
||||||
return False, error_msg
|
return False, error_msg
|
||||||
|
|
||||||
# CORRECTION 3 : Amélioration du logging dans sync_transaction
|
# CORRECTION 3 : Amélioration du logging dans sync_transaction
|
||||||
async def _sync_transaction_documents_corrected(
|
async def _sync_transaction_documents_corrected(
|
||||||
self, session, transaction, universign_data: dict, new_local_status: str
|
self, session, transaction, universign_data: dict, new_local_status: str
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue