Compare commits
No commits in common. "c1f4c66e8c3cdcefd0e4d3ee3ca2b2a3080cf51a" and "211dd4fd23025e3835af6564ac72345102c8285e" have entirely different histories.
c1f4c66e8c
...
211dd4fd23
3 changed files with 116 additions and 18 deletions
96
api.py
96
api.py
|
|
@ -224,6 +224,7 @@ app.include_router(entreprises_router)
|
||||||
@app.get("/clients", response_model=List[ClientDetails], tags=["Clients"])
|
@app.get("/clients", response_model=List[ClientDetails], tags=["Clients"])
|
||||||
async def obtenir_clients(
|
async def obtenir_clients(
|
||||||
query: Optional[str] = Query(None),
|
query: Optional[str] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -237,6 +238,7 @@ async def obtenir_clients(
|
||||||
@app.get("/clients/{code}", response_model=ClientDetails, tags=["Clients"])
|
@app.get("/clients/{code}", response_model=ClientDetails, tags=["Clients"])
|
||||||
async def lire_client_detail(
|
async def lire_client_detail(
|
||||||
code: str,
|
code: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -259,6 +261,7 @@ async def modifier_client(
|
||||||
code: str,
|
code: str,
|
||||||
client_update: ClientUpdate,
|
client_update: ClientUpdate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -284,6 +287,7 @@ async def modifier_client(
|
||||||
async def ajouter_client(
|
async def ajouter_client(
|
||||||
client: ClientCreate,
|
client: ClientCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -308,6 +312,7 @@ async def ajouter_client(
|
||||||
@app.get("/articles", response_model=List[Article], tags=["Articles"])
|
@app.get("/articles", response_model=List[Article], tags=["Articles"])
|
||||||
async def rechercher_articles(
|
async def rechercher_articles(
|
||||||
query: Optional[str] = Query(None),
|
query: Optional[str] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -326,6 +331,7 @@ async def rechercher_articles(
|
||||||
)
|
)
|
||||||
async def creer_article(
|
async def creer_article(
|
||||||
article: ArticleCreate,
|
article: ArticleCreate,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -366,6 +372,7 @@ async def creer_article(
|
||||||
async def modifier_article(
|
async def modifier_article(
|
||||||
reference: str = Path(..., description="Référence de l'article à modifier"),
|
reference: str = Path(..., description="Référence de l'article à modifier"),
|
||||||
article: ArticleUpdate = Body(...),
|
article: ArticleUpdate = Body(...),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -409,6 +416,7 @@ async def modifier_article(
|
||||||
@app.get("/articles/{reference}", response_model=Article, tags=["Articles"])
|
@app.get("/articles/{reference}", response_model=Article, tags=["Articles"])
|
||||||
async def lire_article(
|
async def lire_article(
|
||||||
reference: str = Path(..., description="Référence de l'article"),
|
reference: str = Path(..., description="Référence de l'article"),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -438,6 +446,7 @@ async def lire_article(
|
||||||
@app.post("/devis", response_model=Devis, status_code=201, tags=["Devis"])
|
@app.post("/devis", response_model=Devis, status_code=201, tags=["Devis"])
|
||||||
async def creer_devis(
|
async def creer_devis(
|
||||||
devis: DevisRequest,
|
devis: DevisRequest,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -477,6 +486,7 @@ async def modifier_devis(
|
||||||
id: str,
|
id: str,
|
||||||
devis_update: DevisUpdate,
|
devis_update: DevisUpdate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -522,6 +532,7 @@ async def modifier_devis(
|
||||||
async def creer_commande(
|
async def creer_commande(
|
||||||
commande: CommandeCreate,
|
commande: CommandeCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -571,6 +582,7 @@ async def modifier_commande(
|
||||||
id: str,
|
id: str,
|
||||||
commande_update: CommandeUpdate,
|
commande_update: CommandeUpdate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -619,6 +631,7 @@ async def lister_devis(
|
||||||
inclure_lignes: bool = Query(
|
inclure_lignes: bool = Query(
|
||||||
True, description="Inclure les lignes de chaque devis"
|
True, description="Inclure les lignes de chaque devis"
|
||||||
),
|
),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -635,6 +648,7 @@ async def lister_devis(
|
||||||
@app.get("/devis/{id}", tags=["Devis"])
|
@app.get("/devis/{id}", tags=["Devis"])
|
||||||
async def lire_devis(
|
async def lire_devis(
|
||||||
id: str,
|
id: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -655,6 +669,7 @@ async def lire_devis(
|
||||||
@app.get("/devis/{id}/pdf", tags=["Devis"])
|
@app.get("/devis/{id}/pdf", tags=["Devis"])
|
||||||
async def telecharger_devis_pdf(
|
async def telecharger_devis_pdf(
|
||||||
id: str,
|
id: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -677,6 +692,7 @@ async def telecharger_document_pdf(
|
||||||
description="Type de document (0=Devis, 10=Commande, 30=Livraison, 60=Facture, 50=Avoir)",
|
description="Type de document (0=Devis, 10=Commande, 30=Livraison, 60=Facture, 50=Avoir)",
|
||||||
),
|
),
|
||||||
numero: str = Path(..., description="Numéro du document"),
|
numero: str = Path(..., description="Numéro du document"),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -733,6 +749,7 @@ async def envoyer_devis_email(
|
||||||
id: str,
|
id: str,
|
||||||
request: EmailEnvoi,
|
request: EmailEnvoi,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -788,6 +805,7 @@ async def changer_statut_document(
|
||||||
nouveau_statut: int = Query(
|
nouveau_statut: int = Query(
|
||||||
..., ge=0, le=6, description="0=Saisi, 1=Confirmé, 2=Accepté"
|
..., ge=0, le=6, description="0=Saisi, 1=Confirmé, 2=Accepté"
|
||||||
),
|
),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
document_type_sql = None
|
document_type_sql = None
|
||||||
|
|
@ -904,6 +922,7 @@ async def changer_statut_document(
|
||||||
@app.get("/commandes/{id}", tags=["Commandes"])
|
@app.get("/commandes/{id}", tags=["Commandes"])
|
||||||
async def lire_commande(
|
async def lire_commande(
|
||||||
id: str,
|
id: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -922,6 +941,7 @@ async def lire_commande(
|
||||||
async def lister_commandes(
|
async def lister_commandes(
|
||||||
limit: int = Query(100, le=1000),
|
limit: int = Query(100, le=1000),
|
||||||
statut: Optional[int] = Query(None),
|
statut: Optional[int] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -937,6 +957,7 @@ async def lister_commandes(
|
||||||
async def devis_vers_commande(
|
async def devis_vers_commande(
|
||||||
id: str,
|
id: str,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -981,6 +1002,7 @@ async def devis_vers_commande(
|
||||||
async def commande_vers_facture(
|
async def commande_vers_facture(
|
||||||
id: str,
|
id: str,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1082,6 +1104,7 @@ async def envoyer_emails_lot(
|
||||||
async def valider_remise(
|
async def valider_remise(
|
||||||
client_id: str = Query(..., min_length=1),
|
client_id: str = Query(..., min_length=1),
|
||||||
remise_pourcentage: float = Query(0.0, ge=0, le=100),
|
remise_pourcentage: float = Query(0.0, ge=0, le=100),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1115,6 +1138,7 @@ async def relancer_devis_signature(
|
||||||
id: str,
|
id: str,
|
||||||
relance: RelanceDevis,
|
relance: RelanceDevis,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1181,6 +1205,7 @@ class ContactClientResponse(BaseModel):
|
||||||
@app.get("/devis/{id}/contact", response_model=ContactClientResponse, tags=["Devis"])
|
@app.get("/devis/{id}/contact", response_model=ContactClientResponse, tags=["Devis"])
|
||||||
async def recuperer_contact_devis(
|
async def recuperer_contact_devis(
|
||||||
id: str,
|
id: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1208,6 +1233,7 @@ async def recuperer_contact_devis(
|
||||||
async def lister_factures(
|
async def lister_factures(
|
||||||
limit: int = Query(100, le=1000),
|
limit: int = Query(100, le=1000),
|
||||||
statut: Optional[int] = Query(None),
|
statut: Optional[int] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1222,6 +1248,7 @@ async def lister_factures(
|
||||||
@app.get("/factures/{numero}", tags=["Factures"])
|
@app.get("/factures/{numero}", tags=["Factures"])
|
||||||
async def lire_facture_detail(
|
async def lire_facture_detail(
|
||||||
numero: str,
|
numero: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1248,6 +1275,7 @@ class RelanceFacture(BaseModel):
|
||||||
async def creer_facture(
|
async def creer_facture(
|
||||||
facture: FactureCreate,
|
facture: FactureCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1297,6 +1325,7 @@ async def modifier_facture(
|
||||||
id: str,
|
id: str,
|
||||||
facture_update: FactureUpdate,
|
facture_update: FactureUpdate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1366,6 +1395,7 @@ async def relancer_facture(
|
||||||
id: str,
|
id: str,
|
||||||
relance: RelanceFacture,
|
relance: RelanceFacture,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1436,6 +1466,7 @@ async def journal_emails(
|
||||||
destinataire: Optional[str] = Query(None),
|
destinataire: Optional[str] = Query(None),
|
||||||
limit: int = Query(100, le=1000),
|
limit: int = Query(100, le=1000),
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
query = select(EmailLog)
|
query = select(EmailLog)
|
||||||
|
|
@ -1471,6 +1502,7 @@ async def journal_emails(
|
||||||
async def exporter_logs_csv(
|
async def exporter_logs_csv(
|
||||||
statut: Optional[StatutEmail] = Query(None),
|
statut: Optional[StatutEmail] = Query(None),
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
query = select(EmailLog)
|
query = select(EmailLog)
|
||||||
|
|
@ -1540,7 +1572,9 @@ class TemplatePreview(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
@app.get("/templates/emails", response_model=List[TemplateEmail], tags=["Emails"])
|
@app.get("/templates/emails", response_model=List[TemplateEmail], tags=["Emails"])
|
||||||
async def lister_templates():
|
async def lister_templates(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
|
):
|
||||||
return [TemplateEmail(**template) for template in templates_email_db.values()]
|
return [TemplateEmail(**template) for template in templates_email_db.values()]
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1549,6 +1583,7 @@ async def lister_templates():
|
||||||
)
|
)
|
||||||
async def lire_template(
|
async def lire_template(
|
||||||
template_id: str,
|
template_id: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
):
|
):
|
||||||
if template_id not in templates_email_db:
|
if template_id not in templates_email_db:
|
||||||
raise HTTPException(404, f"Template {template_id} introuvable")
|
raise HTTPException(404, f"Template {template_id} introuvable")
|
||||||
|
|
@ -1559,6 +1594,7 @@ async def lire_template(
|
||||||
@app.post("/templates/emails", response_model=TemplateEmail, tags=["Emails"])
|
@app.post("/templates/emails", response_model=TemplateEmail, tags=["Emails"])
|
||||||
async def creer_template(
|
async def creer_template(
|
||||||
template: TemplateEmail,
|
template: TemplateEmail,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
):
|
):
|
||||||
template_id = str(uuid.uuid4())
|
template_id = str(uuid.uuid4())
|
||||||
|
|
||||||
|
|
@ -1581,6 +1617,7 @@ async def creer_template(
|
||||||
async def modifier_template(
|
async def modifier_template(
|
||||||
template_id: str,
|
template_id: str,
|
||||||
template: TemplateEmail,
|
template: TemplateEmail,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
):
|
):
|
||||||
if template_id not in templates_email_db:
|
if template_id not in templates_email_db:
|
||||||
raise HTTPException(404, f"Template {template_id} introuvable")
|
raise HTTPException(404, f"Template {template_id} introuvable")
|
||||||
|
|
@ -1604,6 +1641,7 @@ async def modifier_template(
|
||||||
@app.delete("/templates/emails/{template_id}", tags=["Emails"])
|
@app.delete("/templates/emails/{template_id}", tags=["Emails"])
|
||||||
async def supprimer_template(
|
async def supprimer_template(
|
||||||
template_id: str,
|
template_id: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
):
|
):
|
||||||
if template_id not in templates_email_db:
|
if template_id not in templates_email_db:
|
||||||
raise HTTPException(404, f"Template {template_id} introuvable")
|
raise HTTPException(404, f"Template {template_id} introuvable")
|
||||||
|
|
@ -1621,6 +1659,7 @@ async def supprimer_template(
|
||||||
@app.post("/templates/emails/preview", tags=["Emails"])
|
@app.post("/templates/emails/preview", tags=["Emails"])
|
||||||
async def previsualiser_email(
|
async def previsualiser_email(
|
||||||
preview: TemplatePreview,
|
preview: TemplatePreview,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
if preview.template_id not in templates_email_db:
|
if preview.template_id not in templates_email_db:
|
||||||
|
|
@ -1659,6 +1698,7 @@ async def previsualiser_email(
|
||||||
@app.get("/prospects", tags=["Prospects"])
|
@app.get("/prospects", tags=["Prospects"])
|
||||||
async def rechercher_prospects(
|
async def rechercher_prospects(
|
||||||
query: Optional[str] = Query(None),
|
query: Optional[str] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1672,6 +1712,7 @@ async def rechercher_prospects(
|
||||||
@app.get("/prospects/{code}", tags=["Prospects"])
|
@app.get("/prospects/{code}", tags=["Prospects"])
|
||||||
async def lire_prospect(
|
async def lire_prospect(
|
||||||
code: str,
|
code: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1691,6 +1732,7 @@ async def lire_prospect(
|
||||||
)
|
)
|
||||||
async def rechercher_fournisseurs(
|
async def rechercher_fournisseurs(
|
||||||
query: Optional[str] = Query(None),
|
query: Optional[str] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1712,6 +1754,7 @@ async def rechercher_fournisseurs(
|
||||||
async def ajouter_fournisseur(
|
async def ajouter_fournisseur(
|
||||||
fournisseur: FournisseurCreate,
|
fournisseur: FournisseurCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1741,6 +1784,7 @@ async def modifier_fournisseur(
|
||||||
code: str,
|
code: str,
|
||||||
fournisseur_update: FournisseurUpdate,
|
fournisseur_update: FournisseurUpdate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1763,6 +1807,7 @@ async def modifier_fournisseur(
|
||||||
@app.get("/fournisseurs/{code}", tags=["Fournisseurs"])
|
@app.get("/fournisseurs/{code}", tags=["Fournisseurs"])
|
||||||
async def lire_fournisseur(
|
async def lire_fournisseur(
|
||||||
code: str,
|
code: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1781,6 +1826,7 @@ async def lire_fournisseur(
|
||||||
async def lister_avoirs(
|
async def lister_avoirs(
|
||||||
limit: int = Query(100, le=1000),
|
limit: int = Query(100, le=1000),
|
||||||
statut: Optional[int] = Query(None),
|
statut: Optional[int] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1794,6 +1840,7 @@ async def lister_avoirs(
|
||||||
@app.get("/avoirs/{numero}", tags=["Avoirs"])
|
@app.get("/avoirs/{numero}", tags=["Avoirs"])
|
||||||
async def lire_avoir(
|
async def lire_avoir(
|
||||||
numero: str,
|
numero: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1812,6 +1859,7 @@ async def lire_avoir(
|
||||||
async def creer_avoir(
|
async def creer_avoir(
|
||||||
avoir: AvoirCreate,
|
avoir: AvoirCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1859,6 +1907,7 @@ async def modifier_avoir(
|
||||||
id: str,
|
id: str,
|
||||||
avoir_update: AvoirUpdate,
|
avoir_update: AvoirUpdate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1904,6 +1953,7 @@ async def modifier_avoir(
|
||||||
async def lister_livraisons(
|
async def lister_livraisons(
|
||||||
limit: int = Query(100, le=1000),
|
limit: int = Query(100, le=1000),
|
||||||
statut: Optional[int] = Query(None),
|
statut: Optional[int] = Query(None),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1917,6 +1967,7 @@ async def lister_livraisons(
|
||||||
@app.get("/livraisons/{numero}", tags=["Livraisons"])
|
@app.get("/livraisons/{numero}", tags=["Livraisons"])
|
||||||
async def lire_livraison(
|
async def lire_livraison(
|
||||||
numero: str,
|
numero: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1935,6 +1986,7 @@ async def lire_livraison(
|
||||||
async def creer_livraison(
|
async def creer_livraison(
|
||||||
livraison: LivraisonCreate,
|
livraison: LivraisonCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -1988,6 +2040,7 @@ async def modifier_livraison(
|
||||||
id: str,
|
id: str,
|
||||||
livraison_update: LivraisonUpdate,
|
livraison_update: LivraisonUpdate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2033,6 +2086,7 @@ async def modifier_livraison(
|
||||||
async def livraison_vers_facture(
|
async def livraison_vers_facture(
|
||||||
id: str,
|
id: str,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2076,6 +2130,7 @@ async def livraison_vers_facture(
|
||||||
async def devis_vers_facture_direct(
|
async def devis_vers_facture_direct(
|
||||||
id: str,
|
id: str,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2136,6 +2191,7 @@ async def devis_vers_facture_direct(
|
||||||
async def commande_vers_livraison(
|
async def commande_vers_livraison(
|
||||||
id: str,
|
id: str,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2207,6 +2263,7 @@ async def commande_vers_livraison(
|
||||||
)
|
)
|
||||||
async def lister_familles(
|
async def lister_familles(
|
||||||
filtre: Optional[str] = Query(None, description="Filtre sur code ou intitulé"),
|
filtre: Optional[str] = Query(None, description="Filtre sur code ou intitulé"),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2232,6 +2289,7 @@ async def lister_familles(
|
||||||
)
|
)
|
||||||
async def lire_famille(
|
async def lire_famille(
|
||||||
code: str = Path(..., description="Code de la famille (ex: ZDIVERS)"),
|
code: str = Path(..., description="Code de la famille (ex: ZDIVERS)"),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2267,6 +2325,7 @@ async def lire_famille(
|
||||||
)
|
)
|
||||||
async def creer_famille(
|
async def creer_famille(
|
||||||
famille: FamilleCreate,
|
famille: FamilleCreate,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2310,6 +2369,7 @@ async def creer_famille(
|
||||||
)
|
)
|
||||||
async def creer_entree_stock(
|
async def creer_entree_stock(
|
||||||
entree: EntreeStock,
|
entree: EntreeStock,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2346,6 +2406,7 @@ async def creer_entree_stock(
|
||||||
)
|
)
|
||||||
async def creer_sortie_stock(
|
async def creer_sortie_stock(
|
||||||
sortie: SortieStock,
|
sortie: SortieStock,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2381,6 +2442,7 @@ async def creer_sortie_stock(
|
||||||
)
|
)
|
||||||
async def lire_mouvement_stock(
|
async def lire_mouvement_stock(
|
||||||
numero: str = Path(..., description="Numéro du mouvement (ex: ME00123 ou MS00124)"),
|
numero: str = Path(..., description="Numéro du mouvement (ex: ME00123 ou MS00124)"),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2413,6 +2475,7 @@ async def lire_mouvement_stock(
|
||||||
summary="Statistiques sur les familles",
|
summary="Statistiques sur les familles",
|
||||||
)
|
)
|
||||||
async def statistiques_familles(
|
async def statistiques_familles(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2434,6 +2497,7 @@ async def lister_utilisateurs_debug(
|
||||||
limit: int = Query(100, le=1000),
|
limit: int = Query(100, le=1000),
|
||||||
role: Optional[str] = Query(None),
|
role: Optional[str] = Query(None),
|
||||||
verified_only: bool = Query(False),
|
verified_only: bool = Query(False),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
):
|
):
|
||||||
from database import User
|
from database import User
|
||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
@ -2520,6 +2584,7 @@ async def statistiques_utilisateurs(session: AsyncSession = Depends(get_session)
|
||||||
async def creer_contact(
|
async def creer_contact(
|
||||||
numero: str,
|
numero: str,
|
||||||
contact: ContactCreate,
|
contact: ContactCreate,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2552,6 +2617,7 @@ async def creer_contact(
|
||||||
@app.get("/tiers/{numero}/contacts", response_model=List[Contact], tags=["Contacts"])
|
@app.get("/tiers/{numero}/contacts", response_model=List[Contact], tags=["Contacts"])
|
||||||
async def lister_contacts(
|
async def lister_contacts(
|
||||||
numero: str,
|
numero: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2570,6 +2636,7 @@ async def lister_contacts(
|
||||||
async def obtenir_contact(
|
async def obtenir_contact(
|
||||||
numero: str,
|
numero: str,
|
||||||
contact_numero: int,
|
contact_numero: int,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2595,6 +2662,7 @@ async def modifier_contact(
|
||||||
numero: str,
|
numero: str,
|
||||||
contact_numero: int,
|
contact_numero: int,
|
||||||
contact: ContactUpdate,
|
contact: ContactUpdate,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2626,6 +2694,7 @@ async def modifier_contact(
|
||||||
async def supprimer_contact(
|
async def supprimer_contact(
|
||||||
numero: str,
|
numero: str,
|
||||||
contact_numero: int,
|
contact_numero: int,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2640,6 +2709,7 @@ async def supprimer_contact(
|
||||||
async def definir_contact_defaut(
|
async def definir_contact_defaut(
|
||||||
numero: str,
|
numero: str,
|
||||||
contact_numero: int,
|
contact_numero: int,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2661,6 +2731,7 @@ async def obtenir_tiers(
|
||||||
description="Filtre par type: 0/client, 1/fournisseur, 2/prospect, 3/all ou strings",
|
description="Filtre par type: 0/client, 1/fournisseur, 2/prospect, 3/all ou strings",
|
||||||
),
|
),
|
||||||
query: Optional[str] = Query(None, description="Recherche sur code ou intitulé"),
|
query: Optional[str] = Query(None, description="Recherche sur code ou intitulé"),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2675,6 +2746,7 @@ async def obtenir_tiers(
|
||||||
@app.get("/tiers/{code}", response_model=TiersDetails, tags=["Tiers"])
|
@app.get("/tiers/{code}", response_model=TiersDetails, tags=["Tiers"])
|
||||||
async def lire_tiers_detail(
|
async def lire_tiers_detail(
|
||||||
code: str,
|
code: str,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2712,6 +2784,7 @@ async def lister_collaborateurs(
|
||||||
actifs_seulement: bool = Query(
|
actifs_seulement: bool = Query(
|
||||||
True, description="Exclure les collaborateurs en sommeil"
|
True, description="Exclure les collaborateurs en sommeil"
|
||||||
),
|
),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Liste tous les collaborateurs"""
|
"""Liste tous les collaborateurs"""
|
||||||
|
|
@ -2730,6 +2803,7 @@ async def lister_collaborateurs(
|
||||||
)
|
)
|
||||||
async def lire_collaborateur_detail(
|
async def lire_collaborateur_detail(
|
||||||
numero: int,
|
numero: int,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Lit un collaborateur par son numéro"""
|
"""Lit un collaborateur par son numéro"""
|
||||||
|
|
@ -2756,6 +2830,7 @@ async def lire_collaborateur_detail(
|
||||||
)
|
)
|
||||||
async def creer_collaborateur(
|
async def creer_collaborateur(
|
||||||
collaborateur: CollaborateurCreate,
|
collaborateur: CollaborateurCreate,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Crée un nouveau collaborateur"""
|
"""Crée un nouveau collaborateur"""
|
||||||
|
|
@ -2782,6 +2857,7 @@ async def creer_collaborateur(
|
||||||
async def modifier_collaborateur(
|
async def modifier_collaborateur(
|
||||||
numero: int,
|
numero: int,
|
||||||
collaborateur: CollaborateurUpdate,
|
collaborateur: CollaborateurUpdate,
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Modifie un collaborateur existant"""
|
"""Modifie un collaborateur existant"""
|
||||||
|
|
@ -2804,6 +2880,7 @@ async def modifier_collaborateur(
|
||||||
|
|
||||||
@app.get("/societe/info", response_model=SocieteInfo, tags=["Société"])
|
@app.get("/societe/info", response_model=SocieteInfo, tags=["Société"])
|
||||||
async def obtenir_informations_societe(
|
async def obtenir_informations_societe(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2823,6 +2900,7 @@ async def obtenir_informations_societe(
|
||||||
|
|
||||||
@app.get("/societe/logo", tags=["Société"])
|
@app.get("/societe/logo", tags=["Société"])
|
||||||
async def obtenir_logo_societe(
|
async def obtenir_logo_societe(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Retourne le logo en tant qu'image directe"""
|
"""Retourne le logo en tant qu'image directe"""
|
||||||
|
|
@ -2847,6 +2925,7 @@ async def obtenir_logo_societe(
|
||||||
|
|
||||||
@app.get("/societe/preview", response_class=HTMLResponse, tags=["Société"])
|
@app.get("/societe/preview", response_class=HTMLResponse, tags=["Société"])
|
||||||
async def preview_societe(
|
async def preview_societe(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Page HTML pour visualiser les infos société avec logo"""
|
"""Page HTML pour visualiser les infos société avec logo"""
|
||||||
|
|
@ -2920,6 +2999,7 @@ async def preview_societe(
|
||||||
async def valider_facture(
|
async def valider_facture(
|
||||||
numero_facture: str,
|
numero_facture: str,
|
||||||
_: AsyncSession = Depends(get_session),
|
_: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2943,6 +3023,7 @@ async def valider_facture(
|
||||||
async def devalider_facture(
|
async def devalider_facture(
|
||||||
numero_facture: str,
|
numero_facture: str,
|
||||||
_: AsyncSession = Depends(get_session),
|
_: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2966,6 +3047,7 @@ async def devalider_facture(
|
||||||
async def get_statut_validation_facture(
|
async def get_statut_validation_facture(
|
||||||
numero_facture: str,
|
numero_facture: str,
|
||||||
_: AsyncSession = Depends(get_session),
|
_: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -2986,6 +3068,7 @@ async def regler_facture(
|
||||||
numero_facture: str,
|
numero_facture: str,
|
||||||
reglement: ReglementFactureCreate,
|
reglement: ReglementFactureCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -3029,6 +3112,7 @@ async def regler_facture(
|
||||||
async def regler_factures_multiple(
|
async def regler_factures_multiple(
|
||||||
reglement: ReglementMultipleCreate,
|
reglement: ReglementMultipleCreate,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -3067,6 +3151,7 @@ async def regler_factures_multiple(
|
||||||
async def get_reglements_facture(
|
async def get_reglements_facture(
|
||||||
numero_facture: str,
|
numero_facture: str,
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -3091,6 +3176,7 @@ async def get_reglements_client(
|
||||||
date_fin: Optional[datetime] = Query(None, description="Date fin"),
|
date_fin: Optional[datetime] = Query(None, description="Date fin"),
|
||||||
inclure_soldees: bool = Query(True, description="Inclure les factures soldées"),
|
inclure_soldees: bool = Query(True, description="Inclure les factures soldées"),
|
||||||
session: AsyncSession = Depends(get_session),
|
session: AsyncSession = Depends(get_session),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -3115,6 +3201,7 @@ async def get_reglements_client(
|
||||||
|
|
||||||
@app.get("/journaux/banque", tags=["Règlements"])
|
@app.get("/journaux/banque", tags=["Règlements"])
|
||||||
async def get_journaux_banque(
|
async def get_journaux_banque(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
|
|
@ -3127,6 +3214,7 @@ async def get_journaux_banque(
|
||||||
|
|
||||||
@app.get("/reglements/modes", tags=["Référentiels"])
|
@app.get("/reglements/modes", tags=["Référentiels"])
|
||||||
async def get_modes_reglement(
|
async def get_modes_reglement(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Liste des modes de règlement disponibles dans Sage"""
|
"""Liste des modes de règlement disponibles dans Sage"""
|
||||||
|
|
@ -3140,6 +3228,7 @@ async def get_modes_reglement(
|
||||||
|
|
||||||
@app.get("/devises", tags=["Référentiels"])
|
@app.get("/devises", tags=["Référentiels"])
|
||||||
async def get_devises(
|
async def get_devises(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Liste des devises disponibles dans Sage"""
|
"""Liste des devises disponibles dans Sage"""
|
||||||
|
|
@ -3153,6 +3242,7 @@ async def get_devises(
|
||||||
|
|
||||||
@app.get("/journaux/tresorerie", tags=["Référentiels"])
|
@app.get("/journaux/tresorerie", tags=["Référentiels"])
|
||||||
async def get_journaux_tresorerie(
|
async def get_journaux_tresorerie(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Liste des journaux de trésorerie (banque + caisse)"""
|
"""Liste des journaux de trésorerie (banque + caisse)"""
|
||||||
|
|
@ -3171,6 +3261,7 @@ async def get_comptes_generaux(
|
||||||
None,
|
None,
|
||||||
description="client | fournisseur | banque | caisse | tva | produit | charge",
|
description="client | fournisseur | banque | caisse | tva | produit | charge",
|
||||||
),
|
),
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Liste des comptes généraux"""
|
"""Liste des comptes généraux"""
|
||||||
|
|
@ -3184,6 +3275,7 @@ async def get_comptes_generaux(
|
||||||
|
|
||||||
@app.get("/tva/taux", tags=["Référentiels"])
|
@app.get("/tva/taux", tags=["Référentiels"])
|
||||||
async def get_tva_taux(
|
async def get_tva_taux(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Liste des taux de TVA"""
|
"""Liste des taux de TVA"""
|
||||||
|
|
@ -3197,6 +3289,7 @@ async def get_tva_taux(
|
||||||
|
|
||||||
@app.get("/parametres/encaissement", tags=["Référentiels"])
|
@app.get("/parametres/encaissement", tags=["Référentiels"])
|
||||||
async def get_parametres_encaissement(
|
async def get_parametres_encaissement(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
"""Paramètres TVA sur encaissement"""
|
"""Paramètres TVA sur encaissement"""
|
||||||
|
|
@ -3243,6 +3336,7 @@ async def get_reglement_detail(rg_no):
|
||||||
|
|
||||||
@app.get("/health", tags=["System"])
|
@app.get("/health", tags=["System"])
|
||||||
async def health_check(
|
async def health_check(
|
||||||
|
user: User = Depends(get_current_user),
|
||||||
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
sage: SageGatewayClient = Depends(get_sage_client_for_user),
|
||||||
):
|
):
|
||||||
gateway_health = sage.health()
|
gateway_health = sage.health()
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,6 @@ class ApiKeyMiddlewareHTTP(BaseHTTPMiddleware):
|
||||||
"/health",
|
"/health",
|
||||||
"/auth",
|
"/auth",
|
||||||
"/api-keys/verify",
|
"/api-keys/verify",
|
||||||
"/universign/webhook",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def _is_excluded_path(self, path: str) -> bool:
|
def _is_excluded_path(self, path: str) -> bool:
|
||||||
|
|
@ -138,12 +137,6 @@ class ApiKeyMiddlewareHTTP(BaseHTTPMiddleware):
|
||||||
auth_header = request.headers.get("Authorization")
|
auth_header = request.headers.get("Authorization")
|
||||||
api_key_header = request.headers.get("X-API-Key")
|
api_key_header = request.headers.get("X-API-Key")
|
||||||
|
|
||||||
if api_key_header:
|
|
||||||
logger.debug(f"🔑 API Key détectée pour {method} {path}")
|
|
||||||
return await self._handle_api_key_auth(
|
|
||||||
request, api_key_header, path, method, call_next
|
|
||||||
)
|
|
||||||
|
|
||||||
if auth_header and auth_header.startswith("Bearer "):
|
if auth_header and auth_header.startswith("Bearer "):
|
||||||
token = auth_header.split(" ")[1]
|
token = auth_header.split(" ")[1]
|
||||||
|
|
||||||
|
|
@ -151,16 +144,27 @@ class ApiKeyMiddlewareHTTP(BaseHTTPMiddleware):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
" API Key envoyée dans Authorization au lieu de X-API-Key"
|
" API Key envoyée dans Authorization au lieu de X-API-Key"
|
||||||
)
|
)
|
||||||
return await self._handle_api_key_auth(
|
api_key_header = token
|
||||||
request, token, path, method, call_next
|
else:
|
||||||
)
|
logger.debug(f" JWT détecté pour {method} {path}")
|
||||||
|
return await call_next(request)
|
||||||
|
|
||||||
logger.debug(f"🎫 JWT détecté pour {method} {path} → délégation à FastAPI")
|
if api_key_header:
|
||||||
request.state.authenticated_via = "jwt"
|
logger.debug(f" API Key détectée pour {method} {path}")
|
||||||
return await call_next(request)
|
return await self._handle_api_key_auth(
|
||||||
|
request, api_key_header, path, method, call_next
|
||||||
|
)
|
||||||
|
|
||||||
logger.debug(f" Aucune auth pour {method} {path} → délégation à FastAPI")
|
logger.warning(f" Aucune authentification: {method} {path}")
|
||||||
return await call_next(request)
|
return JSONResponse(
|
||||||
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
content={
|
||||||
|
"detail": "Authentification requise",
|
||||||
|
"hint": "Utilisez 'X-API-Key: sdk_live_xxx' ou 'Authorization: Bearer <jwt>'",
|
||||||
|
"path": path,
|
||||||
|
},
|
||||||
|
headers={"WWW-Authenticate": 'Bearer realm="API", charset="UTF-8"'},
|
||||||
|
)
|
||||||
|
|
||||||
async def _handle_api_key_auth(
|
async def _handle_api_key_auth(
|
||||||
self,
|
self,
|
||||||
|
|
@ -192,7 +196,7 @@ class ApiKeyMiddlewareHTTP(BaseHTTPMiddleware):
|
||||||
|
|
||||||
is_allowed, rate_info = await service.check_rate_limit(api_key_obj)
|
is_allowed, rate_info = await service.check_rate_limit(api_key_obj)
|
||||||
if not is_allowed:
|
if not is_allowed:
|
||||||
logger.warning(f" Rate limit: {api_key_obj.name}")
|
logger.warning(f"⚠️ Rate limit: {api_key_obj.name}")
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
|
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
|
||||||
content={"detail": "Rate limit dépassé"},
|
content={"detail": "Rate limit dépassé"},
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ async def create_api_key(
|
||||||
logger.info(" Endpoints: Tous (aucune restriction)")
|
logger.info(" Endpoints: Tous (aucune restriction)")
|
||||||
|
|
||||||
logger.info("=" * 70)
|
logger.info("=" * 70)
|
||||||
logger.info(" SAUVEGARDEZ CETTE CLÉ - Elle ne sera plus affichée !")
|
logger.info("⚠️ SAUVEGARDEZ CETTE CLÉ - Elle ne sera plus affichée !")
|
||||||
logger.info("=" * 70)
|
logger.info("=" * 70)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue