Compare commits

..

No commits in common. "b85bd26dbe406c2697c323f76dec93a8694c40ba" and "9f12727bd3c603a278d3e013da32bb6377cc6ab8" have entirely different histories.

3 changed files with 10 additions and 44 deletions

37
api.py
View file

@ -4,7 +4,7 @@ from fastapi.responses import StreamingResponse, HTMLResponse, Response
from fastapi.encoders import jsonable_encoder from fastapi.encoders import jsonable_encoder
from pydantic import BaseModel, Field, EmailStr from pydantic import BaseModel, Field, EmailStr
from typing import List, Optional from typing import List, Optional
from datetime import datetime, date from datetime import datetime
import uvicorn import uvicorn
import asyncio import asyncio
from contextlib import asynccontextmanager from contextlib import asynccontextmanager
@ -2999,7 +2999,7 @@ async def regler_factures_multiple(
try: try:
resultat = sage.regler_factures_client( resultat = sage.regler_factures_client(
client_code=reglement.client_id, client_code=reglement.client_id,
montant_total=float(reglement.montant_total), montant_total=reglement.montant_total,
mode_reglement=reglement.mode_reglement, mode_reglement=reglement.mode_reglement,
date_reglement=reglement.date_reglement.isoformat() date_reglement=reglement.date_reglement.isoformat()
if reglement.date_reglement if reglement.date_reglement
@ -3173,39 +3173,6 @@ async def get_parametres_encaissement(
raise HTTPException(500, str(e)) raise HTTPException(500, str(e))
@app.get("/reglements", tags=["Règlements"])
async def get_tous_reglements(
date_debut: Optional[date] = Query(None),
date_fin: Optional[date] = Query(None),
client_code: Optional[str] = Query(None),
type_reglement: Optional[str] = Query(None),
):
"""Liste tous les règlements avec filtres optionnels"""
params = {}
if date_debut:
params["date_debut"] = date_debut.isoformat()
if date_fin:
params["date_fin"] = date_fin.isoformat()
if client_code:
params["client_code"] = client_code
if type_reglement:
params["type_reglement"] = type_reglement
return sage_client.get_tous_reglements(params)
@app.get("/reglements/facture/{facture_no}", tags=["Règlements"])
async def get_reglement_facture_detail(facture_no):
"""Détail complet d'un règlement"""
return sage_client.get_reglement_facture_detail(facture_no)
@app.get("/reglements/{rg_no}", tags=["Règlements"])
async def get_reglement_detail(rg_no):
"""Détail complet d'un règlement"""
return sage_client.get_reglement_detail(rg_no)
@app.get("/health", tags=["System"]) @app.get("/health", tags=["System"])
async def health_check( async def health_check(
sage: SageGatewayClient = Depends(get_sage_client_for_user), sage: SageGatewayClient = Depends(get_sage_client_for_user),

View file

@ -557,6 +557,13 @@ class SageGatewayClient:
def get_comptes_generaux( def get_comptes_generaux(
self, prefixe: str = None, type_compte: str = None self, prefixe: str = None, type_compte: str = None
) -> List[dict]: ) -> List[dict]:
"""
Récupère les comptes généraux
Args:
prefixe: Filtre par préfixe (ex: "41", "51")
type_compte: "client", "fournisseur", "banque", "caisse", "tva"
"""
params = {} params = {}
if prefixe: if prefixe:
params["prefixe"] = prefixe params["prefixe"] = prefixe
@ -590,14 +597,5 @@ class SageGatewayClient:
except Exception: except Exception:
return {"status": "down"} return {"status": "down"}
def get_tous_reglements(self, params=None):
return self._get("/sage/reglements", params=params)
def get_reglement_facture_detail(self, facture_no):
return self._get(f"/sage/reglements/facture/{facture_no}")
def get_reglement_detail(self, rg_no):
return self._get(f"/sage/reglements/{rg_no}")
sage_client = SageGatewayClient() sage_client = SageGatewayClient()

View file

@ -72,6 +72,7 @@ class ReglementMultipleCreate(BaseModel):
client_id: str = Field(..., description="Code client") client_id: str = Field(..., description="Code client")
montant_total: Decimal = Field(..., gt=0) montant_total: Decimal = Field(..., gt=0)
# Même structure que ReglementFactureCreate
devise_code: Optional[int] = Field(0) devise_code: Optional[int] = Field(0)
cours_devise: Optional[Decimal] = Field(1.0) cours_devise: Optional[Decimal] = Field(1.0)
mode_reglement: int = Field(...) mode_reglement: int = Field(...)