From fb241befccea4badf04b6e5ebb8ca30217d06712 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar Date: Wed, 30 Sep 2026 11:48:16 +0000 Subject: [PATCH] fix(erpsetup): letter head and footer in the print template, chevron as PNG (#53) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB --- internal/erpsetup/branding.go | 27 +++++++++++++++++++-------- internal/erpsetup/erpsetup_test.go | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/internal/erpsetup/branding.go b/internal/erpsetup/branding.go index 1aad378..cda771e 100644 --- a/internal/erpsetup/branding.go +++ b/internal/erpsetup/branding.go @@ -7,6 +7,8 @@ package erpsetup // customer mandate), so a change there needs no new run. // // Print formats are rendered by wkhtmltopdf: tables for layout, no flexbox. +// A custom (Jinja) print format must place the letter head and the footer +// itself; ERPNext only does that for its standard formats. import "strings" @@ -111,9 +113,10 @@ var brand = strings.NewReplacer( "$REGISTER", legalRegister, "$DIRECTORS", legalDirectors, ) -// logoSVG is the chevron from the portal favicon, inline so wkhtmltopdf needs -// no network access. -const logoSVG = `` +// logoSVG is the chevron from the portal favicon, as an embedded PNG +// (120×115, rendered from docs/public/logo.svg): wkhtmltopdf does not draw +// inline SVG and must not need network access. +const logoSVG = `` // Shared Jinja: the company's own address and its bank account. const companyVars = `{%- set bp_addr = frappe.db.get_value("Address", {"is_your_company_address": 1, "is_primary_address": 1, "disabled": 0}, ["address_line1", "pincode", "city", "email_id"], as_dict=1) or {"address_line1": "In Steinäckern 16", "pincode": "78351", "city": "Bodman-Ludwigshafen", "email_id": "kontakt@breakpilot.com"} -%} @@ -141,10 +144,10 @@ var letterFooterHTML = brand.Replace(strings.ReplaceAll(`${companyVars} {%- set bp_bic = frappe.db.get_value("Bank", bp_bank.bank, "swift_number") if bp_bank.bank else "" -%} - - - - + + + +
{{ doc.company }}
{{ bp_addr.address_line1 }}
{{ bp_addr.pincode }} {{ bp_addr.city }}
$REGISTER_BR
USt-IdNr. {{ frappe.db.get_value("Company", doc.company, "tax_id") or "" }}
$DIRECTORS_BR{% if bp_bank.iban %}{{ bp_bank.bank }}
IBAN {{ bp_bank.iban }}{% if bp_bic %}
BIC {{ bp_bic }}{% endif %}{% endif %}
{{ doc.company }}
{{ bp_addr.address_line1 }}
{{ bp_addr.pincode }} {{ bp_addr.city }}
$REGISTER_BR
USt-IdNr. {{ frappe.db.get_value("Company", doc.company, "tax_id") or "" }}
$DIRECTORS_BR{% if bp_bank.iban %}{{ bp_bank.bank }}
IBAN {{ bp_bank.iban }}{% if bp_bic %}
BIC {{ bp_bic }}{% endif %}{% endif %}
`, "${companyVars}", companyVars)) @@ -163,7 +166,9 @@ var documentHTML = brand.Replace(`{%- set is_inv = doc.doctype == "Sales Invoice {%- set tpl = doc.taxes_and_charges or "" -%} {%- set period_from = doc.get("from_date") or (doc.items[0].get("service_start_date") if doc.items else None) -%} {%- set period_to = doc.get("to_date") or (doc.items[0].get("service_end_date") if doc.items else None) -%} +{%- if letter_head and not no_letterhead %}
{{ letter_head }}
{% endif %}