Generate EPC (SEPA Credit Transfer) QR codes inside Frappe/ERPNext, especially for invoices and other print formats.
- Frappe
>=15,<17 - Python
>=3.10 - App dependency:
segno~=1.6.1(installed automatically with the app)
Run these commands from your bench directory:
bench get-app https://github.com/david-loe/epc_qrcode.git
bench --site <your-site> install-app epc_qrcodeThe app adds one whitelisted and Jinja-available method:
epc_qrcode.gen.gen_epcqrcode
Signature:
gen_epcqrcode(
name,
iban,
amount,
text=None,
reference=None,
bic=None,
purpose=None,
encoding=None,
scale=3,
dark="#000",
light="#fff",
)Return value:
PNG Data URI string (for example: data:image/png;base64,...)
Because the method is registered in hooks as a Jinja method, you can call it directly in HTML/Jinja print formats.
{% set qr = gen_epcqrcode(
name="ACME GmbH",
iban="DE89370400440532013000",
amount=doc.rounded_total or doc.grand_total,
text=("Invoice " ~ doc.name)
) %}
<img src="{{ qr }}" alt="EPC QR" style="width: 140px; height: 140px;" />name: Beneficiary name (receiver)iban: Beneficiary IBANamount: Transfer amount (number)text: Unstructured remittance information (optional)reference: Structured creditor reference (optional)bic: Receiver BIC (optional, but recommended for compatibility)purpose: ISO purpose code (optional)encoding: EPC text encoding (optional)scale: QR image size multiplier (default3)dark,light: QR colors (defaults#000/#fff)
jinja2.exceptions.UndefinedError: 'gen_epcqrcode' is undefined- Confirm app installation:
bench --site <your-site> list-apps - Restart bench:
bench restart
- Confirm app installation:
- Broken QR image in print
- Ensure the template uses
<img src="{{ qr }}">(not{{ qr }}directly) - Validate IBAN and amount values passed from
doc
- Ensure the template uses
MIT