feat(api): enrich ArticleResponse model with additional fields
This commit is contained in:
parent
8f4c4f97a7
commit
1c53135b62
1 changed files with 60 additions and 7 deletions
67
api.py
67
api.py
|
|
@ -232,10 +232,65 @@ class ClientDetails(BaseModel):
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArticleResponse(BaseModel):
|
class ArticleResponse(BaseModel):
|
||||||
reference: str
|
"""
|
||||||
designation: str
|
Modèle de réponse pour un article Sage
|
||||||
prix_vente: float
|
|
||||||
stock_reel: float
|
✅ ENRICHI avec tous les champs disponibles
|
||||||
|
"""
|
||||||
|
# === IDENTIFICATION ===
|
||||||
|
reference: str = Field(..., description="Référence article (AR_Ref)")
|
||||||
|
designation: str = Field(..., description="Désignation principale (AR_Design)")
|
||||||
|
designation_complementaire: Optional[str] = Field(None, description="Désignation complémentaire")
|
||||||
|
|
||||||
|
# === CODE EAN / CODE-BARRES ===
|
||||||
|
code_ean: Optional[str] = Field(None, description="Code EAN / Code-barres")
|
||||||
|
code_barre: Optional[str] = Field(None, description="Code-barres (alias)")
|
||||||
|
|
||||||
|
# === PRIX ===
|
||||||
|
prix_vente: float = Field(..., description="Prix de vente HT")
|
||||||
|
prix_achat: Optional[float] = Field(None, description="Prix d'achat HT")
|
||||||
|
prix_revient: Optional[float] = Field(None, description="Prix de revient")
|
||||||
|
|
||||||
|
# === STOCK ===
|
||||||
|
stock_reel: float = Field(..., description="Stock réel")
|
||||||
|
stock_mini: Optional[float] = Field(None, description="Stock minimum")
|
||||||
|
stock_maxi: Optional[float] = Field(None, description="Stock maximum")
|
||||||
|
stock_reserve: Optional[float] = Field(None, description="Stock réservé (en commande)")
|
||||||
|
stock_commande: Optional[float] = Field(None, description="Stock en commande fournisseur")
|
||||||
|
stock_disponible: Optional[float] = Field(None, description="Stock disponible (réel - réservé)")
|
||||||
|
|
||||||
|
# === DESCRIPTIONS ===
|
||||||
|
description: Optional[str] = Field(None, description="Description détaillée / Commentaire")
|
||||||
|
|
||||||
|
# === CLASSIFICATION ===
|
||||||
|
type_article: Optional[int] = Field(None, description="Type d'article (0=Article, 1=Prestation, 2=Divers)")
|
||||||
|
type_article_libelle: Optional[str] = Field(None, description="Libellé du type")
|
||||||
|
famille_code: Optional[str] = Field(None, description="Code famille")
|
||||||
|
famille_libelle: Optional[str] = Field(None, description="Libellé famille")
|
||||||
|
|
||||||
|
# === FOURNISSEUR PRINCIPAL ===
|
||||||
|
fournisseur_principal: Optional[str] = Field(None, description="Code fournisseur principal")
|
||||||
|
fournisseur_nom: Optional[str] = Field(None, description="Nom fournisseur principal")
|
||||||
|
|
||||||
|
# === UNITÉS ===
|
||||||
|
unite_vente: Optional[str] = Field(None, description="Unité de vente")
|
||||||
|
unite_achat: Optional[str] = Field(None, description="Unité d'achat")
|
||||||
|
|
||||||
|
# === CARACTÉRISTIQUES PHYSIQUES ===
|
||||||
|
poids: Optional[float] = Field(None, description="Poids (kg)")
|
||||||
|
volume: Optional[float] = Field(None, description="Volume (m³)")
|
||||||
|
|
||||||
|
# === STATUT ===
|
||||||
|
est_actif: bool = Field(True, description="Article actif")
|
||||||
|
en_sommeil: bool = Field(False, description="Article en sommeil")
|
||||||
|
|
||||||
|
# === TVA ===
|
||||||
|
tva_code: Optional[str] = Field(None, description="Code TVA")
|
||||||
|
tva_taux: Optional[float] = Field(None, description="Taux de TVA (%)")
|
||||||
|
|
||||||
|
# === DATES ===
|
||||||
|
date_creation: Optional[str] = Field(None, description="Date de création")
|
||||||
|
date_modification: Optional[str] = Field(None, description="Date de dernière modification")
|
||||||
|
|
||||||
|
|
||||||
class LigneDevis(BaseModel):
|
class LigneDevis(BaseModel):
|
||||||
|
|
@ -2889,13 +2944,11 @@ async def lire_prospect(code: str):
|
||||||
async def rechercher_fournisseurs(query: Optional[str] = Query(None)):
|
async def rechercher_fournisseurs(query: Optional[str] = Query(None)):
|
||||||
"""
|
"""
|
||||||
🔍 Recherche fournisseurs via gateway Windows
|
🔍 Recherche fournisseurs via gateway Windows
|
||||||
✅ CORRECTION : Appel direct sans cache
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# ✅ APPEL DIRECT vers Windows (pas de cache)
|
|
||||||
fournisseurs = sage_client.lister_fournisseurs(filtre=query or "")
|
fournisseurs = sage_client.lister_fournisseurs(filtre=query or "")
|
||||||
|
|
||||||
logger.info(f"✅ {len(fournisseurs)} fournisseurs retournés depuis Windows")
|
logger.info(f"✅ {len(fournisseurs)} fournisseurs")
|
||||||
|
|
||||||
if len(fournisseurs) == 0:
|
if len(fournisseurs) == 0:
|
||||||
logger.warning("⚠️ Aucun fournisseur retourné - vérifier la gateway Windows")
|
logger.warning("⚠️ Aucun fournisseur retourné - vérifier la gateway Windows")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue