Updated pydantic schemas, deleted client's retrieving logics on creating and updating document

This commit is contained in:
Fanilo-Nantenaina 2025-12-20 16:30:48 +03:00
parent dbb2a6f16e
commit 1240a118e5

660
api.py
View file

@ -1096,331 +1096,331 @@ templates_signature_email = {
"nom": "Demande de Signature Électronique", "nom": "Demande de Signature Électronique",
"sujet": "📝 Signature requise - {{TYPE_DOC}} {{NUMERO}}", "sujet": "📝 Signature requise - {{TYPE_DOC}} {{NUMERO}}",
"corps_html": """ "corps_html": """
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;"> <body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;">
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f7fa; padding: 40px 0;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f7fa; padding: 40px 0;">
<tr> <tr>
<td align="center"> <td align="center">
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);"> <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<!-- Header --> <!-- Header -->
<tr> <tr>
<td style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 30px; text-align: center; border-radius: 8px 8px 0 0;"> <td style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 30px; text-align: center; border-radius: 8px 8px 0 0;">
<h1 style="color: #000; margin: 0; font-size: 24px; font-weight: 600;"> <h1 style="color: #000; margin: 0; font-size: 24px; font-weight: 600;">
📝 Signature Électronique Requise 📝 Signature Électronique Requise
</h1> </h1>
</td> </td>
</tr> </tr>
<!-- Content --> <!-- Content -->
<tr> <tr>
<td style="padding: 40px 30px;"> <td style="padding: 40px 30px;">
<p style="color: #2d3748; font-size: 16px; line-height: 1.6; margin: 0 0 20px;"> <p style="color: #2d3748; font-size: 16px; line-height: 1.6; margin: 0 0 20px;">
Bonjour <strong>{{NOM_SIGNATAIRE}}</strong>, Bonjour <strong>{{NOM_SIGNATAIRE}}</strong>,
</p> </p>
<p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;"> <p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;">
Nous vous invitons à signer électroniquement le document suivant : Nous vous invitons à signer électroniquement le document suivant :
</p> </p>
<!-- Document Info Box --> <!-- Document Info Box -->
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f7fafc; border-left: 4px solid #667eea; border-radius: 4px; margin-bottom: 30px;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f7fafc; border-left: 4px solid #667eea; border-radius: 4px; margin-bottom: 30px;">
<tr> <tr>
<td style="padding: 20px;"> <td style="padding: 20px;">
<table width="100%" cellpadding="0" cellspacing="0"> <table width="100%" cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="color: #718096; font-size: 13px; padding: 5px 0;">Type de document</td> <td style="color: #718096; font-size: 13px; padding: 5px 0;">Type de document</td>
<td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{TYPE_DOC}}</td> <td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{TYPE_DOC}}</td>
</tr> </tr>
<tr> <tr>
<td style="color: #718096; font-size: 13px; padding: 5px 0;">Numéro</td> <td style="color: #718096; font-size: 13px; padding: 5px 0;">Numéro</td>
<td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{NUMERO}}</td> <td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{NUMERO}}</td>
</tr> </tr>
<tr> <tr>
<td style="color: #718096; font-size: 13px; padding: 5px 0;">Date</td> <td style="color: #718096; font-size: 13px; padding: 5px 0;">Date</td>
<td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{DATE}}</td> <td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{DATE}}</td>
</tr> </tr>
<tr> <tr>
<td style="color: #718096; font-size: 13px; padding: 5px 0;">Montant TTC</td> <td style="color: #718096; font-size: 13px; padding: 5px 0;">Montant TTC</td>
<td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{MONTANT_TTC}} </td> <td style="color: #2d3748; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{MONTANT_TTC}} </td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
<p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 30px;"> <p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 30px;">
Cliquez sur le bouton ci-dessous pour accéder au document et apposer votre signature électronique sécurisée : Cliquez sur le bouton ci-dessous pour accéder au document et apposer votre signature électronique sécurisée :
</p> </p>
<!-- CTA Button --> <!-- CTA Button -->
<table width="100%" cellpadding="0" cellspacing="0"> <table width="100%" cellpadding="0" cellspacing="0">
<tr> <tr>
<td align="center" style="padding: 10px 0 30px;"> <td align="center" style="padding: 10px 0 30px;">
<a href="{{SIGNER_URL}}" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #000; text-decoration: none; padding: 16px 40px; border-radius: 6px; font-size: 16px; font-weight: 600; box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);"> <a href="{{SIGNER_URL}}" style="display: inline-block; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #000; text-decoration: none; padding: 16px 40px; border-radius: 6px; font-size: 16px; font-weight: 600; box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);">
Signer le document Signer le document
</a> </a>
</td> </td>
</tr> </tr>
</table> </table>
<!-- Info Box --> <!-- Info Box -->
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #fffaf0; border: 1px solid #fbd38d; border-radius: 4px; margin-bottom: 20px;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #fffaf0; border: 1px solid #fbd38d; border-radius: 4px; margin-bottom: 20px;">
<tr> <tr>
<td style="padding: 15px;"> <td style="padding: 15px;">
<p style="color: #744210; font-size: 13px; line-height: 1.5; margin: 0;"> <p style="color: #744210; font-size: 13px; line-height: 1.5; margin: 0;">
<strong>Important :</strong> Ce lien de signature est valable pendant <strong>30 jours</strong>. <strong>Important :</strong> Ce lien de signature est valable pendant <strong>30 jours</strong>.
Nous vous recommandons de signer ce document dès que possible. Nous vous recommandons de signer ce document dès que possible.
</p> </p>
</td> </td>
</tr> </tr>
</table> </table>
<p style="color: #718096; font-size: 13px; line-height: 1.5; margin: 0;"> <p style="color: #718096; font-size: 13px; line-height: 1.5; margin: 0;">
<strong>🔒 Signature électronique sécurisée</strong><br> <strong>🔒 Signature électronique sécurisée</strong><br>
Votre signature est protégée par notre partenaire de confiance <strong>Universign</strong>, Votre signature est protégée par notre partenaire de confiance <strong>Universign</strong>,
certifié eIDAS et conforme au RGPD. Votre identité sera vérifiée et le document sera certifié eIDAS et conforme au RGPD. Votre identité sera vérifiée et le document sera
horodaté de manière infalsifiable. horodaté de manière infalsifiable.
</p> </p>
</td> </td>
</tr> </tr>
<!-- Footer --> <!-- Footer -->
<tr> <tr>
<td style="background-color: #f7fafc; padding: 25px 30px; border-radius: 0 0 8px 8px; border-top: 1px solid #e2e8f0;"> <td style="background-color: #f7fafc; padding: 25px 30px; border-radius: 0 0 8px 8px; border-top: 1px solid #e2e8f0;">
<p style="color: #718096; font-size: 12px; line-height: 1.5; margin: 0 0 10px;"> <p style="color: #718096; font-size: 12px; line-height: 1.5; margin: 0 0 10px;">
Vous avez des questions ? Contactez-nous à <a href="mailto:{{CONTACT_EMAIL}}" style="color: #667eea; text-decoration: none;">{{CONTACT_EMAIL}}</a> Vous avez des questions ? Contactez-nous à <a href="mailto:{{CONTACT_EMAIL}}" style="color: #667eea; text-decoration: none;">{{CONTACT_EMAIL}}</a>
</p> </p>
<p style="color: #a0aec0; font-size: 11px; line-height: 1.4; margin: 0;"> <p style="color: #a0aec0; font-size: 11px; line-height: 1.4; margin: 0;">
Cet email a été envoyé automatiquement par le système Sage 100c Dataven.<br> Cet email a été envoyé automatiquement par le système Sage 100c Dataven.<br>
Si vous avez reçu cet email par erreur, veuillez nous en informer. Si vous avez reçu cet email par erreur, veuillez nous en informer.
</p> </p>
</td> </td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>
""", """,
"variables_disponibles": [ "variables_disponibles": [
"NOM_SIGNATAIRE", "NOM_SIGNATAIRE",
"TYPE_DOC", "TYPE_DOC",
"NUMERO", "NUMERO",
"DATE", "DATE",
"MONTANT_TTC", "MONTANT_TTC",
"SIGNER_URL", "SIGNER_URL",
"CONTACT_EMAIL", "CONTACT_EMAIL",
], ],
}, },
"signature_confirmee": { "signature_confirmee": {
"id": "signature_confirmee", "id": "signature_confirmee",
"nom": "Confirmation de Signature", "nom": "Confirmation de Signature",
"sujet": "✅ Document signé - {{TYPE_DOC}} {{NUMERO}}", "sujet": "✅ Document signé - {{TYPE_DOC}} {{NUMERO}}",
"corps_html": """ "corps_html": """
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;"> <body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;">
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f7fa; padding: 40px 0;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f7fa; padding: 40px 0;">
<tr> <tr>
<td align="center"> <td align="center">
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);"> <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<!-- Header --> <!-- Header -->
<tr> <tr>
<td style="background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); padding: 30px; text-align: center; border-radius: 8px 8px 0 0;"> <td style="background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); padding: 30px; text-align: center; border-radius: 8px 8px 0 0;">
<h1 style="color: #ffffff; margin: 0; font-size: 24px; font-weight: 600;"> <h1 style="color: #ffffff; margin: 0; font-size: 24px; font-weight: 600;">
Document Signé avec Succès Document Signé avec Succès
</h1> </h1>
</td> </td>
</tr> </tr>
<!-- Content --> <!-- Content -->
<tr> <tr>
<td style="padding: 40px 30px;"> <td style="padding: 40px 30px;">
<p style="color: #2d3748; font-size: 16px; line-height: 1.6; margin: 0 0 20px;"> <p style="color: #2d3748; font-size: 16px; line-height: 1.6; margin: 0 0 20px;">
Bonjour <strong>{{NOM_SIGNATAIRE}}</strong>, Bonjour <strong>{{NOM_SIGNATAIRE}}</strong>,
</p> </p>
<p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;"> <p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;">
Nous confirmons la signature électronique du document suivant : Nous confirmons la signature électronique du document suivant :
</p> </p>
<!-- Success Box --> <!-- Success Box -->
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f0fff4; border-left: 4px solid #48bb78; border-radius: 4px; margin-bottom: 30px;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f0fff4; border-left: 4px solid #48bb78; border-radius: 4px; margin-bottom: 30px;">
<tr> <tr>
<td style="padding: 20px;"> <td style="padding: 20px;">
<table width="100%" cellpadding="0" cellspacing="0"> <table width="100%" cellpadding="0" cellspacing="0">
<tr> <tr>
<td style="color: #2f855a; font-size: 13px; padding: 5px 0;">Document</td> <td style="color: #2f855a; font-size: 13px; padding: 5px 0;">Document</td>
<td style="color: #22543d; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{TYPE_DOC}} {{NUMERO}}</td> <td style="color: #22543d; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{TYPE_DOC}} {{NUMERO}}</td>
</tr> </tr>
<tr> <tr>
<td style="color: #2f855a; font-size: 13px; padding: 5px 0;">Signé le</td> <td style="color: #2f855a; font-size: 13px; padding: 5px 0;">Signé le</td>
<td style="color: #22543d; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{DATE_SIGNATURE}}</td> <td style="color: #22543d; font-size: 15px; font-weight: 600; text-align: right; padding: 5px 0;">{{DATE_SIGNATURE}}</td>
</tr> </tr>
<tr> <tr>
<td style="color: #2f855a; font-size: 13px; padding: 5px 0;">ID Transaction</td> <td style="color: #2f855a; font-size: 13px; padding: 5px 0;">ID Transaction</td>
<td style="color: #22543d; font-size: 13px; font-family: monospace; text-align: right; padding: 5px 0;">{{TRANSACTION_ID}}</td> <td style="color: #22543d; font-size: 13px; font-family: monospace; text-align: right; padding: 5px 0;">{{TRANSACTION_ID}}</td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
<p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;"> <p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;">
Le document signé a été automatiquement archivé et est disponible dans votre espace client. Le document signé a été automatiquement archivé et est disponible dans votre espace client.
Un certificat de signature électronique conforme eIDAS a été généré. Un certificat de signature électronique conforme eIDAS a été généré.
</p> </p>
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #ebf8ff; border: 1px solid #90cdf4; border-radius: 4px; margin-bottom: 20px;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #ebf8ff; border: 1px solid #90cdf4; border-radius: 4px; margin-bottom: 20px;">
<tr> <tr>
<td style="padding: 15px;"> <td style="padding: 15px;">
<p style="color: #2c5282; font-size: 13px; line-height: 1.5; margin: 0;"> <p style="color: #2c5282; font-size: 13px; line-height: 1.5; margin: 0;">
🔐 <strong>Signature certifiée :</strong> Ce document a été signé avec une signature 🔐 <strong>Signature certifiée :</strong> Ce document a été signé avec une signature
électronique qualifiée, ayant la même valeur juridique qu'une signature manuscrite électronique qualifiée, ayant la même valeur juridique qu'une signature manuscrite
conformément au règlement eIDAS. conformément au règlement eIDAS.
</p> </p>
</td> </td>
</tr> </tr>
</table> </table>
<p style="color: #718096; font-size: 14px; line-height: 1.6; margin: 0;"> <p style="color: #718096; font-size: 14px; line-height: 1.6; margin: 0;">
Merci pour votre confiance. Notre équipe reste à votre disposition pour toute question. Merci pour votre confiance. Notre équipe reste à votre disposition pour toute question.
</p> </p>
</td> </td>
</tr> </tr>
<!-- Footer --> <!-- Footer -->
<tr> <tr>
<td style="background-color: #f7fafc; padding: 25px 30px; border-radius: 0 0 8px 8px; border-top: 1px solid #e2e8f0;"> <td style="background-color: #f7fafc; padding: 25px 30px; border-radius: 0 0 8px 8px; border-top: 1px solid #e2e8f0;">
<p style="color: #718096; font-size: 12px; line-height: 1.5; margin: 0 0 10px;"> <p style="color: #718096; font-size: 12px; line-height: 1.5; margin: 0 0 10px;">
Contact : <a href="mailto:{{CONTACT_EMAIL}}" style="color: #48bb78; text-decoration: none;">{{CONTACT_EMAIL}}</a> Contact : <a href="mailto:{{CONTACT_EMAIL}}" style="color: #48bb78; text-decoration: none;">{{CONTACT_EMAIL}}</a>
</p> </p>
<p style="color: #a0aec0; font-size: 11px; line-height: 1.4; margin: 0;"> <p style="color: #a0aec0; font-size: 11px; line-height: 1.4; margin: 0;">
Sage 100c Dataven - Système de signature électronique sécurisée Sage 100c Dataven - Système de signature électronique sécurisée
</p> </p>
</td> </td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>
""", """,
"variables_disponibles": [ "variables_disponibles": [
"NOM_SIGNATAIRE", "NOM_SIGNATAIRE",
"TYPE_DOC", "TYPE_DOC",
"NUMERO", "NUMERO",
"DATE_SIGNATURE", "DATE_SIGNATURE",
"TRANSACTION_ID", "TRANSACTION_ID",
"CONTACT_EMAIL", "CONTACT_EMAIL",
], ],
}, },
"relance_signature": { "relance_signature": {
"id": "relance_signature", "id": "relance_signature",
"nom": "Relance Signature en Attente", "nom": "Relance Signature en Attente",
"sujet": "⏰ Rappel - Signature en attente {{TYPE_DOC}} {{NUMERO}}", "sujet": "⏰ Rappel - Signature en attente {{TYPE_DOC}} {{NUMERO}}",
"corps_html": """ "corps_html": """
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head> </head>
<body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;"> <body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;">
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f7fa; padding: 40px 0;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f4f7fa; padding: 40px 0;">
<tr> <tr>
<td align="center"> <td align="center">
<table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);"> <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
<!-- Header --> <!-- Header -->
<tr> <tr>
<td style="background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%); padding: 30px; text-align: center; border-radius: 8px 8px 0 0;"> <td style="background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%); padding: 30px; text-align: center; border-radius: 8px 8px 0 0;">
<h1 style="color: #ffffff; margin: 0; font-size: 24px; font-weight: 600;"> <h1 style="color: #ffffff; margin: 0; font-size: 24px; font-weight: 600;">
Signature en Attente Signature en Attente
</h1> </h1>
</td> </td>
</tr> </tr>
<!-- Content --> <!-- Content -->
<tr> <tr>
<td style="padding: 40px 30px;"> <td style="padding: 40px 30px;">
<p style="color: #2d3748; font-size: 16px; line-height: 1.6; margin: 0 0 20px;"> <p style="color: #2d3748; font-size: 16px; line-height: 1.6; margin: 0 0 20px;">
Bonjour <strong>{{NOM_SIGNATAIRE}}</strong>, Bonjour <strong>{{NOM_SIGNATAIRE}}</strong>,
</p> </p>
<p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;"> <p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 25px;">
Nous vous avons envoyé il y a <strong>{{NB_JOURS}}</strong> jours un document à signer électroniquement. Nous vous avons envoyé il y a <strong>{{NB_JOURS}}</strong> jours un document à signer électroniquement.
Nous constatons que celui-ci n'a pas encore été signé. Nous constatons que celui-ci n'a pas encore été signé.
</p> </p>
<!-- Warning Box --> <!-- Warning Box -->
<table width="100%" cellpadding="0" cellspacing="0" style="background-color: #fffaf0; border-left: 4px solid #ed8936; border-radius: 4px; margin-bottom: 30px;"> <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #fffaf0; border-left: 4px solid #ed8936; border-radius: 4px; margin-bottom: 30px;">
<tr> <tr>
<td style="padding: 20px;"> <td style="padding: 20px;">
<p style="color: #744210; font-size: 14px; line-height: 1.5; margin: 0 0 10px;"> <p style="color: #744210; font-size: 14px; line-height: 1.5; margin: 0 0 10px;">
<strong>Document en attente :</strong> {{TYPE_DOC}} {{NUMERO}} <strong>Document en attente :</strong> {{TYPE_DOC}} {{NUMERO}}
</p> </p>
<p style="color: #744210; font-size: 13px; line-height: 1.5; margin: 0;"> <p style="color: #744210; font-size: 13px; line-height: 1.5; margin: 0;">
Le lien de signature expirera dans <strong>{{JOURS_RESTANTS}}</strong> jours Le lien de signature expirera dans <strong>{{JOURS_RESTANTS}}</strong> jours
</p> </p>
</td> </td>
</tr> </tr>
</table> </table>
<p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 30px;"> <p style="color: #4a5568; font-size: 15px; line-height: 1.6; margin: 0 0 30px;">
Pour éviter tout retard dans le traitement de votre dossier, nous vous invitons à signer ce document dès maintenant : Pour éviter tout retard dans le traitement de votre dossier, nous vous invitons à signer ce document dès maintenant :
</p> </p>
<!-- CTA Button --> <!-- CTA Button -->
<table width="100%" cellpadding="0" cellspacing="0"> <table width="100%" cellpadding="0" cellspacing="0">
<tr> <tr>
<td align="center" style="padding: 10px 0 30px;"> <td align="center" style="padding: 10px 0 30px;">
<a href="{{SIGNER_URL}}" style="display: inline-block; background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%); color: #ffffff; text-decoration: none; padding: 16px 40px; border-radius: 6px; font-size: 16px; font-weight: 600; box-shadow: 0 4px 12px rgba(237, 137, 54, 0.4);"> <a href="{{SIGNER_URL}}" style="display: inline-block; background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%); color: #ffffff; text-decoration: none; padding: 16px 40px; border-radius: 6px; font-size: 16px; font-weight: 600; box-shadow: 0 4px 12px rgba(237, 137, 54, 0.4);">
Signer maintenant Signer maintenant
</a> </a>
</td> </td>
</tr> </tr>
</table> </table>
<p style="color: #718096; font-size: 13px; line-height: 1.5; margin: 0;"> <p style="color: #718096; font-size: 13px; line-height: 1.5; margin: 0;">
Si vous rencontrez des difficultés ou avez des questions, n'hésitez pas à nous contacter. Si vous rencontrez des difficultés ou avez des questions, n'hésitez pas à nous contacter.
</p> </p>
</td> </td>
</tr> </tr>
<!-- Footer --> <!-- Footer -->
<tr> <tr>
<td style="background-color: #f7fafc; padding: 25px 30px; border-radius: 0 0 8px 8px; border-top: 1px solid #e2e8f0;"> <td style="background-color: #f7fafc; padding: 25px 30px; border-radius: 0 0 8px 8px; border-top: 1px solid #e2e8f0;">
<p style="color: #718096; font-size: 12px; line-height: 1.5; margin: 0 0 10px;"> <p style="color: #718096; font-size: 12px; line-height: 1.5; margin: 0 0 10px;">
Contact : <a href="mailto:{{CONTACT_EMAIL}}" style="color: #ed8936; text-decoration: none;">{{CONTACT_EMAIL}}</a> Contact : <a href="mailto:{{CONTACT_EMAIL}}" style="color: #ed8936; text-decoration: none;">{{CONTACT_EMAIL}}</a>
</p> </p>
<p style="color: #a0aec0; font-size: 11px; line-height: 1.4; margin: 0;"> <p style="color: #a0aec0; font-size: 11px; line-height: 1.4; margin: 0;">
Sage 100c Dataven - Relance automatique Sage 100c Dataven - Relance automatique
</p> </p>
</td> </td>
</tr> </tr>
</table> </table>
</td> </td>
</tr> </tr>
</table> </table>
</body> </body>
</html> </html>
""", """,
"variables_disponibles": [ "variables_disponibles": [
"NOM_SIGNATAIRE", "NOM_SIGNATAIRE",
@ -1887,6 +1887,12 @@ async def creer_devis(devis: DevisRequest):
devis_data = { devis_data = {
"client_id": devis.client_id, "client_id": devis.client_id,
"date_devis": devis.date_devis.isoformat() if devis.date_devis else None, "date_devis": devis.date_devis.isoformat() if devis.date_devis else None,
"date_livraison": (
devis.date_livraison.isoformat() if devis.date_livraison else None
),
"date_expedition": (
devis.date_expedition.isoformat() if devis.date_expedition else None
),
"reference": devis.reference, "reference": devis.reference,
"lignes": [ "lignes": [
{ {
@ -1969,17 +1975,19 @@ async def creer_commande(
commande: CommandeCreateRequest, session: AsyncSession = Depends(get_session) commande: CommandeCreateRequest, session: AsyncSession = Depends(get_session)
): ):
try: try:
# Vérifier que le client existe
client = sage_client.lire_client(commande.client_id)
if not client:
raise HTTPException(404, f"Client {commande.client_id} introuvable")
# Préparer les données pour la gateway
commande_data = { commande_data = {
"client_id": commande.client_id, "client_id": commande.client_id,
"date_commande": ( "date_commande": (
commande.date_commande.isoformat() if commande.date_commande else None commande.date_commande.isoformat() if commande.date_commande else None
), ),
"date_livraison": (
commande.date_livraison.isoformat() if commande.date_livraison else None
),
"date_expedition": (
commande.date_expedition.isoformat()
if commande.date_expedition
else None
),
"reference": commande.reference, "reference": commande.reference,
"lignes": [ "lignes": [
{ {
@ -2184,12 +2192,6 @@ async def envoyer_devis_email(
id: str, request: EmailEnvoiRequest, session: AsyncSession = Depends(get_session) id: str, request: EmailEnvoiRequest, session: AsyncSession = Depends(get_session)
): ):
try: try:
# Vérifier que le devis existe
devis = sage_client.lire_devis(id)
if not devis:
raise HTTPException(404, f"Devis {id} introuvable")
# Créer logs email pour chaque destinataire
tous_destinataires = [request.destinataire] + request.cc + request.cci tous_destinataires = [request.destinataire] + request.cc + request.cci
email_logs = [] email_logs = []
@ -3141,17 +3143,17 @@ async def creer_facture(
facture: FactureCreateRequest, session: AsyncSession = Depends(get_session) facture: FactureCreateRequest, session: AsyncSession = Depends(get_session)
): ):
try: try:
# Vérifier que le client existe
client = sage_client.lire_client(facture.client_id)
if not client:
raise HTTPException(404, f"Client {facture.client_id} introuvable")
# Préparer les données pour la gateway
facture_data = { facture_data = {
"client_id": facture.client_id, "client_id": facture.client_id,
"date_facture": ( "date_facture": (
facture.date_facture.isoformat() if facture.date_facture else None facture.date_facture.isoformat() if facture.date_facture else None
), ),
"date_livraison": (
facture.date_livraison.isoformat() if facture.date_livraison else None
),
"date_expedition": (
facture.date_expedition.isoformat() if facture.date_expedition else None
),
"reference": facture.reference, "reference": facture.reference,
"lignes": [ "lignes": [
{ {
@ -3759,15 +3761,15 @@ async def creer_avoir(
avoir: AvoirCreateRequest, session: AsyncSession = Depends(get_session) avoir: AvoirCreateRequest, session: AsyncSession = Depends(get_session)
): ):
try: try:
# Vérifier que le client existe
client = sage_client.lire_client(avoir.client_id)
if not client:
raise HTTPException(404, f"Client {avoir.client_id} introuvable")
# Préparer les données pour la gateway
avoir_data = { avoir_data = {
"client_id": avoir.client_id, "client_id": avoir.client_id,
"date_avoir": (avoir.date_avoir.isoformat() if avoir.date_avoir else None), "date_avoir": (avoir.date_avoir.isoformat() if avoir.date_avoir else None),
"date_livraison": (
facture.date_livraison.isoformat() if facture.date_livraison else None
),
"date_expedition": (
facture.date_expedition.isoformat() if facture.date_expedition else None
),
"reference": avoir.reference, "reference": avoir.reference,
"lignes": [ "lignes": [
{ {
@ -3887,12 +3889,6 @@ async def creer_livraison(
livraison: LivraisonCreateRequest, session: AsyncSession = Depends(get_session) livraison: LivraisonCreateRequest, session: AsyncSession = Depends(get_session)
): ):
try: try:
# Vérifier que le client existe
client = sage_client.lire_client(livraison.client_id)
if not client:
raise HTTPException(404, f"Client {livraison.client_id} introuvable")
# Préparer les données pour la gateway
livraison_data = { livraison_data = {
"client_id": livraison.client_id, "client_id": livraison.client_id,
"date_livraison": ( "date_livraison": (
@ -3900,6 +3896,16 @@ async def creer_livraison(
if livraison.date_livraison if livraison.date_livraison
else None else None
), ),
"date_livraison_prevue": (
livraison.date_livraison_prevue.isoformat()
if livraison.date_livraison_prevue
else None
),
"date_expedition": (
livraison.date_expedition.isoformat()
if livraison.date_expedition
else None
),
"reference": livraison.reference, "reference": livraison.reference,
"lignes": [ "lignes": [
{ {