Code cleanup

This commit is contained in:
2026-03-16 17:47:16 +01:00
parent 40c05f7860
commit b403efd056
2 changed files with 1 additions and 19 deletions

View File

@@ -10,7 +10,7 @@ from models import Facture, LigneFacture, Client, StatutFacture
from numerotation import generer_numero_facture
from config import settings
from auth import get_current_user
from template_helper import render, render_xml
from template_helper import render
from generate_facturx_jinja2 import Address, Party, Invoice, InvoiceLine, generate_facturx_xml
router = APIRouter(prefix="/factures", tags=["factures"], dependencies=[Depends(get_current_user)])
@@ -161,7 +161,6 @@ from generate_facturx_jinja2 import Invoice, Party, Address, InvoiceLine, filte
@router.get("/{facture_id}/facturx")
def telecharger_facturx(request: Request, facture_id: int, db: Session = Depends(get_db)):
facture = get_invoice_data(facture_id, db) # votre appel BDD
# facture = db.query(Facture).get(facture_id)
if not facture:
raise HTTPException(status_code=404)

View File

@@ -17,20 +17,3 @@ def render(templates: Jinja2Templates, template_name: str,
response = templates.TemplateResponse(template_name, ctx)
response.status_code = status_code
return response
def render_xml(templates: Jinja2Templates, template_name: str,
request: Request, invoice: "Invoice",
filename: str = "factur-x.xml") -> Response:
xml_content = templates.env.get_template(template_name).render(
request=request,
invoice=invoice,
seller=invoice.seller,
buyer=invoice.buyer,
)
return Response(
content=xml_content,
media_type="application/xml",
headers={"Content-Disposition": f'attachment; filename="{filename}"'}
)