add contract storage fix various bugs and translations

This commit is contained in:
2026-02-16 01:23:31 +01:00
parent 627ddfc464
commit be8e32ebed
28 changed files with 1225 additions and 401 deletions

View File

@@ -5,37 +5,39 @@ import html
from weasyprint import HTML
def generate_html_contract(
form: models.Form,
contract_informations: dict,
planned: list[dict],
recurrent: list[dict],
contract: models.Contract,
cheques: list[dict],
planneds: list[dict],
reccurents: list[dict],
recurrent_price: float,
total_price: float,
):
total_price: float
):
template_dir = "./src/contracts/templates"
template_loader = jinja2.FileSystemLoader(searchpath=template_dir)
template_env = jinja2.Environment(loader=template_loader, autoescape=jinja2.select_autoescape(["html", "xml"]))
template_file = "layout.html"
template = template_env.get_template(template_file)
output_text = template.render(
contract_name=form.name,
contract_type=form.productor.type,
contract_season=form.season,
referer_name=form.referer.name,
referer_email=form.referer.email,
productor_name=form.productor.name,
productor_address=form.productor.address,
payment_methods_map={"cheque": "Ordre du chèque", "transfer": "IBAN (paiement par virements)"},
productor_payment_methods=form.productor.payment_methods,
member_name=f'{html.escape(contract_informations["firstname"])} {html.escape(contract_informations["lastname"])}',
member_email=html.escape(contract_informations["email"]),
member_phone=html.escape(contract_informations["phone"]),
contract_start_date=form.start,
contract_end_date=form.end,
planned=planned,
recurrent=recurrent,
contract_name=contract.form.name,
contract_type=contract.form.productor.type,
contract_season=contract.form.season,
referer_name=contract.form.referer.name,
referer_email=contract.form.referer.email,
productor_name=contract.form.productor.name,
productor_address=contract.form.productor.address,
payment_methods_map={"cheque": "Ordre du chèque", "transfer": "virements"},
productor_payment_methods=contract.form.productor.payment_methods,
member_name=f'{html.escape(contract.firstname)} {html.escape(contract.lastname)}',
member_email=html.escape(contract.email),
member_phone=html.escape(contract.phone),
contract_start_date=contract.form.start,
contract_end_date=contract.form.end,
planneds=planneds,
recurrents=reccurents,
recurrent_price=recurrent_price,
total_price=total_price,
contract_payment_method={"cheque": "chèque", "transfer": "virements"}[contract.payment_method],
cheques=cheques
)
options = {
'page-size': 'Letter',