refactor(api): introduce TypeDocumentSQL enum and update document reading methods
This commit is contained in:
parent
5bed8c0cfe
commit
0faec99817
1 changed files with 13 additions and 4 deletions
17
api.py
17
api.py
|
|
@ -89,6 +89,15 @@ class TypeDocument(int, Enum):
|
|||
BON_AVOIR = settings.SAGE_TYPE_BON_AVOIR
|
||||
FACTURE = settings.SAGE_TYPE_FACTURE
|
||||
|
||||
class TypeDocumentSQL(int, Enum):
|
||||
DEVIS = settings.SAGE_TYPE_DEVIS
|
||||
BON_COMMANDE = 1
|
||||
PREPARATION = 2
|
||||
BON_LIVRAISON =3
|
||||
BON_RETOUR = 4
|
||||
BON_AVOIR = 5
|
||||
FACTURE = 6
|
||||
|
||||
|
||||
class StatutSignature(str, Enum):
|
||||
EN_ATTENTE = "EN_ATTENTE"
|
||||
|
|
@ -1887,7 +1896,7 @@ async def changer_statut_devis(
|
|||
async def lire_commande(id: str):
|
||||
"""📄 Lecture d'une commande avec ses lignes"""
|
||||
try:
|
||||
commande = sage_client.lire_document(id, TypeDocument.BON_COMMANDE)
|
||||
commande = sage_client.lire_document(id, TypeDocumentSQL.BON_COMMANDE)
|
||||
if not commande:
|
||||
raise HTTPException(404, f"Commande {id} introuvable")
|
||||
return commande
|
||||
|
|
@ -2538,7 +2547,7 @@ async def lire_facture_detail(numero: str):
|
|||
Facture complète avec lignes, client, totaux, etc.
|
||||
"""
|
||||
try:
|
||||
facture = sage_client.lire_document(numero, TypeDocument.FACTURE)
|
||||
facture = sage_client.lire_document(numero, TypeDocumentSQL.FACTURE)
|
||||
|
||||
if not facture:
|
||||
raise HTTPException(404, f"Facture {numero} introuvable")
|
||||
|
|
@ -3334,7 +3343,7 @@ async def lister_avoirs(
|
|||
async def lire_avoir(numero: str):
|
||||
"""📄 Lecture d'un avoir avec ses lignes"""
|
||||
try:
|
||||
avoir = sage_client.lire_avoir(numero)
|
||||
avoir = sage_client.lire_document(numero, TypeDocumentSQL.BON_AVOIR)
|
||||
if not avoir:
|
||||
raise HTTPException(404, f"Avoir {numero} introuvable")
|
||||
return avoir
|
||||
|
|
@ -3530,7 +3539,7 @@ async def lister_livraisons(
|
|||
async def lire_livraison(numero: str):
|
||||
"""📄 Lecture d'une livraison avec ses lignes"""
|
||||
try:
|
||||
livraison = sage_client.lire_livraison(numero)
|
||||
livraison = sage_client.lire_document(numero, TypeDocumentSQL.BON_LIVRAISON)
|
||||
if not livraison:
|
||||
raise HTTPException(404, f"Livraison {numero} introuvable")
|
||||
return livraison
|
||||
|
|
|
|||
Loading…
Reference in a new issue