From 01a1b5b8fda8a1de51b0b4a2ff1929ddc20f44ef Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Tue, 27 Oct 2026 17:12:15 +0100 Subject: [PATCH] fix(erpsetup): state the permanent discount when it is a negative line The Vertragsbedingungen block (#95) only stated the permanent discount for a document-level discount (total - net_total). The K-00001 Pilotrabatt is a negative line item, by design, because eu_einvoice cannot carry a document-level discount, so the sentence never rendered and the Rabattdauer (one of the reviewer's required terms) was missing from the PDF. Count negative lines (rate < 0) as well, and say the discount is already contained in the stated net amount. Keep the block on one page (page-break-inside: avoid); it split across pages 1-2. Rendered against mocks: line-item discount, document-level discount and no discount all produce the expected text. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01KYcAAeTw22GE9QPzDM8yc4 --- internal/erpsetup/branding.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/erpsetup/branding.go b/internal/erpsetup/branding.go index 3355cd1..44901d2 100644 --- a/internal/erpsetup/branding.go +++ b/internal/erpsetup/branding.go @@ -283,17 +283,24 @@ var documentHTML = brand.Replace(`{%- set is_inv = doc.doctype == "Sales Invoice

Nicht im Inland steuerbare Leistung.

{%- endif %} {%- if doc.doctype == "Quotation" %} +{#- The Pilotrabatt is a negative line item (eu_einvoice cannot carry a + document-level discount), so count negative lines as well as the + document discount. -#} +{%- set line_discount = 0 - (doc.items | selectattr("rate", "lt", 0) | sum(attribute="amount")) if doc.items else 0 -%} +{%- set total_discount = net_discount + line_discount -%} +

Vertragsbedingungen

- +
- +
VertragsartMonatlich wiederkehrende SaaS- und Hosting-Leistungen (Abonnement).
Vertragsbeginn{{ doc.get("contract_start") or "Mit Bereitstellung der gebuchten Dienste gemäß Auftragsbestätigung." }}
Laufzeit / KündigungKeine Mindestlaufzeit; der Vertrag läuft auf unbestimmte Zeit. Monatlich kündbar mit einer Frist von einem Monat zum Monatsende.
AbrechnungMonatlich, jeweils zu Beginn des Leistungszeitraums.
{% if interval == "monatlich" %}Monatliche Vergütung{% else %}Vergütung{% endif %}{{ doc.get_formatted("net_total") }} netto zzgl. gesetzlicher Umsatzsteuer.{% if net_discount > 0.005 %} Der monatliche Nachlass von {{ frappe.utils.fmt_money(net_discount, currency=doc.currency) }} gilt dauerhaft, einschließlich etwaiger Verlängerungen.{% endif %}
{% if interval == "monatlich" %}Monatliche Vergütung{% else %}Vergütung{% endif %}{{ doc.get_formatted("net_total") }} netto zzgl. gesetzlicher Umsatzsteuer.{% if total_discount > 0.005 %} Der darin enthaltene monatliche Nachlass von {{ frappe.utils.fmt_money(total_discount, currency=doc.currency) }} gilt dauerhaft, einschließlich etwaiger Verlängerungen.{% endif %}
MehrverbrauchÜber das gebuchte Kontingent hinausgehende Prüfungen werden je zusätzlicher Prüfung gesondert berechnet.
Vertragsgrundlagen{{ doc.get("vertragsgrundlage") or "Es gelten die SaaS-Vertragsbedingungen, die Leistungsbeschreibungen, das SLA und die AVV (Art. 28 DSGVO) in der jeweils vereinbarten Fassung; die Versionsstände sind in der Anlage bezeichnet." }}
AnnahmeDurch schriftliche oder elektronische Annahme dieses Angebots{% if doc.valid_till %} bis zum {{ frappe.utils.formatdate(doc.valid_till) }}{% endif %}.
+
{%- endif %} {%- if is_inv and not doc.is_return %} {%- if sepa and has_mandate %} -- 2.54.1