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")
|
||||
|
||||
document_service = UniversignDocumentService(
|
||||
api_url=settings.universign_api_url,
|
||||
api_key=settings.universign_api_key, timeout=60
|
||||
)
|
||||
|
||||
|
|
@ -1596,6 +1597,7 @@ async def nettoyer_anciens_documents(
|
|||
"""
|
||||
try:
|
||||
document_service = UniversignDocumentService(
|
||||
api_url=settings.universign_api_url,
|
||||
api_key=settings.universign_api_key
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -322,7 +322,6 @@ class UniversignSyncService:
|
|||
except Exception as e:
|
||||
logger.error(f"Erreur création signer {email}: {e}")
|
||||
|
||||
|
||||
async def sync_transaction(
|
||||
self,
|
||||
session,
|
||||
|
|
@ -330,7 +329,7 @@ class UniversignSyncService:
|
|||
force: bool = False,
|
||||
):
|
||||
import json
|
||||
|
||||
|
||||
# Si statut final et pas de force, skip
|
||||
if is_final_status(transaction.local_status.value) and not force:
|
||||
logger.debug(
|
||||
|
|
@ -395,7 +394,9 @@ class UniversignSyncService:
|
|||
except ValueError:
|
||||
logger.warning(f"⚠️ Statut Universign inconnu: {universign_status_raw}")
|
||||
if new_local_status == "SIGNE":
|
||||
transaction.universign_status = UniversignTransactionStatus.COMPLETED
|
||||
transaction.universign_status = (
|
||||
UniversignTransactionStatus.COMPLETED
|
||||
)
|
||||
elif new_local_status == "REFUSE":
|
||||
transaction.universign_status = UniversignTransactionStatus.REFUSED
|
||||
elif new_local_status == "EXPIRE":
|
||||
|
|
@ -427,7 +428,7 @@ class UniversignSyncService:
|
|||
# === SECTION CORRIGÉE: Gestion des documents ===
|
||||
# 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
|
||||
|
||||
|
||||
documents = universign_data.get("documents", [])
|
||||
if documents:
|
||||
first_doc = documents[0]
|
||||
|
|
@ -435,30 +436,27 @@ class UniversignSyncService:
|
|||
f"📄 Document Universign trouvé: id={first_doc.get('id')}, "
|
||||
f"status={first_doc.get('status')}"
|
||||
)
|
||||
|
||||
|
||||
# Téléchargement automatique du document signé
|
||||
if new_local_status == "SIGNE" and not transaction.signed_document_path:
|
||||
logger.info("📥 Déclenchement téléchargement document signé...")
|
||||
|
||||
|
||||
try:
|
||||
(
|
||||
download_success,
|
||||
download_error,
|
||||
) = await self.document_service.download_and_store_signed_document(
|
||||
session=session,
|
||||
transaction=transaction,
|
||||
force=False
|
||||
session=session, transaction=transaction, force=False
|
||||
)
|
||||
|
||||
|
||||
if download_success:
|
||||
logger.info("✅ Document signé téléchargé et stocké")
|
||||
else:
|
||||
logger.warning(f"⚠️ Échec téléchargement: {download_error}")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"❌ Erreur téléchargement document: {e}",
|
||||
exc_info=True
|
||||
f"❌ Erreur téléchargement document: {e}", exc_info=True
|
||||
)
|
||||
# === FIN SECTION CORRIGÉE ===
|
||||
|
||||
|
|
@ -496,7 +494,9 @@ class UniversignSyncService:
|
|||
# Exécuter les actions post-changement
|
||||
if status_changed:
|
||||
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(
|
||||
f"✅ Sync terminée: {transaction.transaction_id} | "
|
||||
|
|
@ -518,7 +518,7 @@ class UniversignSyncService:
|
|||
await session.commit()
|
||||
|
||||
return False, error_msg
|
||||
|
||||
|
||||
# CORRECTION 3 : Amélioration du logging dans sync_transaction
|
||||
async def _sync_transaction_documents_corrected(
|
||||
self, session, transaction, universign_data: dict, new_local_status: str
|
||||
|
|
|
|||
Loading…
Reference in a new issue