Updated pydantic schemas, deleted client's retrieving logics on creating and updating document
This commit is contained in:
parent
dbb2a6f16e
commit
1240a118e5
1 changed files with 349 additions and 343 deletions
108
api.py
108
api.py
|
|
@ -1096,13 +1096,13 @@ templates_signature_email = {
|
|||
"nom": "Demande de Signature Électronique",
|
||||
"sujet": "📝 Signature requise - {{TYPE_DOC}} {{NUMERO}}",
|
||||
"corps_html": """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;">
|
||||
</head>
|
||||
<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;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
|
|
@ -1207,8 +1207,8 @@ templates_signature_email = {
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
""",
|
||||
"variables_disponibles": [
|
||||
"NOM_SIGNATAIRE",
|
||||
|
|
@ -1225,13 +1225,13 @@ templates_signature_email = {
|
|||
"nom": "Confirmation de Signature",
|
||||
"sujet": "✅ Document signé - {{TYPE_DOC}} {{NUMERO}}",
|
||||
"corps_html": """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;">
|
||||
</head>
|
||||
<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;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
|
|
@ -1318,8 +1318,8 @@ templates_signature_email = {
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
""",
|
||||
"variables_disponibles": [
|
||||
"NOM_SIGNATAIRE",
|
||||
|
|
@ -1335,13 +1335,13 @@ templates_signature_email = {
|
|||
"nom": "Relance Signature en Attente",
|
||||
"sujet": "⏰ Rappel - Signature en attente {{TYPE_DOC}} {{NUMERO}}",
|
||||
"corps_html": """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; font-family: 'Segoe UI', Arial, sans-serif; background-color: #f4f7fa;">
|
||||
</head>
|
||||
<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;">
|
||||
<tr>
|
||||
<td align="center">
|
||||
|
|
@ -1419,8 +1419,8 @@ templates_signature_email = {
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
""",
|
||||
"variables_disponibles": [
|
||||
"NOM_SIGNATAIRE",
|
||||
|
|
@ -1887,6 +1887,12 @@ async def creer_devis(devis: DevisRequest):
|
|||
devis_data = {
|
||||
"client_id": devis.client_id,
|
||||
"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,
|
||||
"lignes": [
|
||||
{
|
||||
|
|
@ -1969,17 +1975,19 @@ async def creer_commande(
|
|||
commande: CommandeCreateRequest, session: AsyncSession = Depends(get_session)
|
||||
):
|
||||
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 = {
|
||||
"client_id": commande.client_id,
|
||||
"date_commande": (
|
||||
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,
|
||||
"lignes": [
|
||||
{
|
||||
|
|
@ -2184,12 +2192,6 @@ async def envoyer_devis_email(
|
|||
id: str, request: EmailEnvoiRequest, session: AsyncSession = Depends(get_session)
|
||||
):
|
||||
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
|
||||
email_logs = []
|
||||
|
||||
|
|
@ -3141,17 +3143,17 @@ async def creer_facture(
|
|||
facture: FactureCreateRequest, session: AsyncSession = Depends(get_session)
|
||||
):
|
||||
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 = {
|
||||
"client_id": facture.client_id,
|
||||
"date_facture": (
|
||||
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,
|
||||
"lignes": [
|
||||
{
|
||||
|
|
@ -3759,15 +3761,15 @@ async def creer_avoir(
|
|||
avoir: AvoirCreateRequest, session: AsyncSession = Depends(get_session)
|
||||
):
|
||||
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 = {
|
||||
"client_id": avoir.client_id,
|
||||
"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,
|
||||
"lignes": [
|
||||
{
|
||||
|
|
@ -3887,12 +3889,6 @@ async def creer_livraison(
|
|||
livraison: LivraisonCreateRequest, session: AsyncSession = Depends(get_session)
|
||||
):
|
||||
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 = {
|
||||
"client_id": livraison.client_id,
|
||||
"date_livraison": (
|
||||
|
|
@ -3900,6 +3896,16 @@ async def creer_livraison(
|
|||
if livraison.date_livraison
|
||||
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,
|
||||
"lignes": [
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue