Merge branch 'feat/validation_facture' into develop
This commit is contained in:
commit
457c746706
2 changed files with 74 additions and 0 deletions
62
api.py
62
api.py
|
|
@ -2966,6 +2966,68 @@ async def preview_societe():
|
||||||
return f"<h1>Erreur</h1><p>{str(e)}</p>"
|
return f"<h1>Erreur</h1><p>{str(e)}</p>"
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/factures/{numero_facture}/valider", status_code=200, tags=["Factures"])
|
||||||
|
async def valider_facture(
|
||||||
|
numero_facture: str,
|
||||||
|
_: AsyncSession = Depends(get_session),
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
resultat = sage_client.valider_facture(numero_facture)
|
||||||
|
logger.info(
|
||||||
|
f"Facture {numero_facture} validée: {resultat.get('action_effectuee')}"
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"message": resultat.get("message", "Facture validée"),
|
||||||
|
"data": resultat,
|
||||||
|
}
|
||||||
|
except HTTPException:
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Erreur validation facture {numero_facture}: {e}")
|
||||||
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/factures/{numero_facture}/devalider", status_code=200, tags=["Factures"])
|
||||||
|
async def devalider_facture(
|
||||||
|
numero_facture: str,
|
||||||
|
_: AsyncSession = Depends(get_session),
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
resultat = sage_client.devalider_facture(numero_facture)
|
||||||
|
logger.info(
|
||||||
|
f"Facture {numero_facture} dévalidée: {resultat.get('action_effectuee')}"
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"message": resultat.get("message", "Facture dévalidée"),
|
||||||
|
"data": resultat,
|
||||||
|
}
|
||||||
|
except HTTPException:
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Erreur dévalidation facture {numero_facture}: {e}")
|
||||||
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/factures/{numero_facture}/statut-validation", tags=["Factures"])
|
||||||
|
async def get_statut_validation_facture(
|
||||||
|
numero_facture: str,
|
||||||
|
_: AsyncSession = Depends(get_session),
|
||||||
|
):
|
||||||
|
try:
|
||||||
|
resultat = sage_client.get_statut_validation(numero_facture)
|
||||||
|
return {
|
||||||
|
"success": True,
|
||||||
|
"data": resultat,
|
||||||
|
}
|
||||||
|
except HTTPException:
|
||||||
|
raise
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Erreur lecture statut {numero_facture}: {e}")
|
||||||
|
raise HTTPException(status_code=500, detail=str(e))
|
||||||
|
|
||||||
|
|
||||||
@app.post("/factures/{numero_facture}/regler", status_code=200, tags=["Règlements"])
|
@app.post("/factures/{numero_facture}/regler", status_code=200, tags=["Règlements"])
|
||||||
async def regler_facture(
|
async def regler_facture(
|
||||||
numero_facture: str,
|
numero_facture: str,
|
||||||
|
|
|
||||||
|
|
@ -431,6 +431,18 @@ class SageGatewayClient:
|
||||||
"""Lit les informations de la société depuis P_DOSSIER"""
|
"""Lit les informations de la société depuis P_DOSSIER"""
|
||||||
return self._get("/sage/societe/info").get("data")
|
return self._get("/sage/societe/info").get("data")
|
||||||
|
|
||||||
|
def valider_facture(self, numero_facture: str) -> dict:
|
||||||
|
response = self._post(f"/sage/factures/{numero_facture}/valider", {})
|
||||||
|
return response.get("data", {})
|
||||||
|
|
||||||
|
def devalider_facture(self, numero_facture: str) -> dict:
|
||||||
|
response = self._post(f"/sage/factures/{numero_facture}/devalider", {})
|
||||||
|
return response.get("data", {})
|
||||||
|
|
||||||
|
def get_statut_validation(self, numero_facture: str) -> dict:
|
||||||
|
response = self._get(f"/sage/factures/{numero_facture}/statut-validation")
|
||||||
|
return response.get("data", {})
|
||||||
|
|
||||||
def regler_facture(
|
def regler_facture(
|
||||||
self,
|
self,
|
||||||
numero_facture: str,
|
numero_facture: str,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue