PDF conforme Factur-X #2
@@ -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)
|
||||
|
||||
@@ -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}"'}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user