Registration form
# Retry the updates and form creation to ensure files are produced (state cleared previously)
from docx import Document
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Inches, Pt
from pathlib import Path
ICS = "BE47ZZZ0822934934"
CO_REG = "0822934934"
COMPANY_TAX = f "BE {CO_REG}"
ADDRESS = "211 Boulevard Auguste Reyers, 1030 Bruxelles"
def replace_text_in_doc(doc: Document, replacements: dict):
for p in doc.paragraphs:
for old, new in replacements.items():
if old in p.text:
for run in p.runs:
if old in run.text:
run.text = run.text.replace(old, new)
if old in p.text:
p.text = p.text.replace(old, new)
for tbl in doc.tables:
for row in tbl.rows:
for cell in row.cells:
for p in cell.paragraphs:
for old, new in replacements.items():
if old in p.text:
for run in p.runs:
if old in run.text:
run.text = run.text.replace(old, new)
if old in p.text:
p.text = p.text.replace(old, new)
def fmt_eur(n: int) -> str:
s = f"{n:,}".replace(",", " ")
s = s.replace(" ","\u202f")
return f"{s} €""
TOTAL = 5900
DEPOSIT = round(TOTAL * 0.30)
BALANCE = TOTAL - DEPOSIT
DATE_SOLDE = "03/10/2025"
# Update CG
cg_path = "/mnt/data/LaMaisonDeCouture-Conditions-Generales-2025.docx"
cg_out = "/mnt/data/LaMaisonDeCouture-Conditions-Generales-2025-v2.docx"
if Path(cg_path).exists():
cg = Document(cg_path)
repl = {
"ING SEPA Creditor Identifier - to be completed]": ICS,
"ICS : [ING SEPA Creditor Identifier - to be completed]": f "ICS : {ICS}",
"BE-[company no.]": COMPANY_TAX,
"BE-[company no.]": COMPANY_TAX,
"BE-[n°]": COMPANY_TAX,
"BE-[n°]": COMPANY_TAX,
"La Maison de Couture - École de Mode, 211 Boulevard Auguste Reyers, 1030 Brussels": f "La Maison de Couture - École de Mode, {ADDRESS}",
}
replace_text_in_doc(cg, repl)
cg.add_paragraph("Imprint: La Maison de Couture - " + ADDRESS + " - N° d'entreprise " + COMPANY_TAX + " - ICS SEPA " + ICS)
cg.save(cg_out)
# Update Pack
pack_path = "/mnt/data/LaMaisonDeCouture-Pack-Clauses-Word-v3.docx"
pack_out = "/mnt/data/LaMaisonDeCouture-Pack-Clauses-Word-v4.docx"
if Path(pack_path).exists():
pack = Document(pack_path)
repl = {
"ING SEPA Creditor Identifier - to be completed]": ICS,
"ICS : [ING SEPA Creditor Identifier - to be completed]": f "ICS : {ICS}",
"ICS : [BE...]": f "ICS : {ICS}",
"BE-[company no.]": COMPANY_TAX,
"BE-[company no.]": COMPANY_TAX,
"BE-[n°]": COMPANY_TAX,
"BE-[n°]": COMPANY_TAX,
"211 Boulevard Auguste Reyers, 1030 Brussels": ADDRESS,
}
replace_text_in_doc(pack, repl)
pack.save(pack_out)
# Create Enrollment Form
form = Document()
logo_path = "/mnt/data/Logo Lamaisondecouture-Fond-marron.png"
if Path(logo_path).exists():
form.add_picture(logo_path, width=Inches(4.2))
form.paragraphs[-1].alignment = WD_ALIGN_PARAGRAPH.CENTER
title = form.add_paragraph()
run = title.add_run("Registration form")
run.bold = True
run.font.size = Pt(20)
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
subtitle = form.add_paragraph(f "La Maison de Couture - {ADDRESS} - N° d'entreprise {COMPANY_TAX} - ICS SEPA {ICS}")
subtitle.alignment = WD_ALIGN_PARAGRAPH.CENTER
form.add_paragraph("")
form.add_heading("1) Program and session", level=1)
form.add_paragraph("Academic year : ______ / ______ - Training / Course : _________________________________________________")
form.add_paragraph("Desired start date : ____ / ____ / ______ - Duration : _______________________")
form.add_heading("2) Student identity", level=1)
form.add_paragraph("Last name: __________________________________ First name: __________________________________ Date of birth : ____ / ____ / ______")
form.add_paragraph("Nationality : ___________________________ ID number / Passport: __________________________________")
form.add_paragraph("Full address: _____________________________________________________________________________________")
form.add_paragraph("E-mail : _____________________________________________ Telephone : ___________________________________")
form.add_paragraph("Emergency contact (name/phone) : _________________________________________________________________")
form.add_heading("3