fix(erpsetup): VAT after discount on documents; SEPA days on offers #80
No files matched your search
@@ -261,11 +261,15 @@ var documentHTML = brand.Replace(`{%- set is_inv = doc.doctype == "Sales Invoice
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{%- set net_discount = (doc.total or 0) - (doc.net_total or 0) -%}
|
||||
<table class="totals">
|
||||
{%- if net_discount > 0.005 %}
|
||||
<tr><td>Zwischensumme</td><td class="r">{{ doc.get_formatted("total") }}</td></tr>
|
||||
<tr><td>Rabatt</td><td class="r">− {{ frappe.utils.fmt_money(net_discount, currency=doc.currency) }}</td></tr>
|
||||
{%- endif %}
|
||||
<tr><td>Summe netto</td><td class="r">{{ doc.get_formatted("net_total") }}</td></tr>
|
||||
{%- if doc.discount_amount %}<tr><td>Rabatt</td><td class="r">− {{ doc.get_formatted("discount_amount") }}</td></tr>{% endif %}
|
||||
{%- for t in doc.taxes %}{% if t.tax_amount %}
|
||||
<tr><td>{{ t.description }}{% if t.rate and "%" not in t.description %} ({{ ("%g"|format(t.rate)) | replace(".", ",") }} %){% endif %}</td><td class="r">{{ t.get_formatted("tax_amount", doc) }}</td></tr>
|
||||
{%- for t in doc.taxes %}{% if t.tax_amount_after_discount_amount %}
|
||||
<tr><td>{{ t.description }}{% if t.rate and "%" not in t.description %} ({{ ("%g"|format(t.rate)) | replace(".", ",") }} %){% endif %}</td><td class="r">{{ t.get_formatted("tax_amount_after_discount_amount", doc) }}</td></tr>
|
||||
{%- endif %}{% endfor %}
|
||||
<tr class="grand"><td>Gesamtbetrag</td><td class="r">{{ doc.get_formatted("rounded_total" if doc.rounded_total else "grand_total") }}</td></tr>
|
||||
</table>
|
||||
@@ -288,7 +292,8 @@ Bitte sorgen Sie für ausreichende Kontodeckung.</p>
|
||||
<p>Bitte überweisen Sie den Rechnungsbetrag bis zum <b>{{ frappe.utils.formatdate(doc.due_date) }}</b> unter Angabe der Rechnungsnummer <b>{{ doc.name }}</b>.</p>
|
||||
{%- endif %}
|
||||
{%- elif not is_inv and sepa %}
|
||||
<p>Zahlungsart: SEPA-Lastschrift {{ "gemäß erteiltem SEPA-Lastschriftmandat" if has_mandate else "nach Erteilung eines gültigen SEPA-Lastschriftmandats" }}.</p>
|
||||
{%- set term = frappe.db.get_value("Payment Term", doc.payment_schedule[0].payment_term, ["credit_days", "due_date_based_on"], as_dict=1) if doc.payment_schedule[0].payment_term else None -%}
|
||||
<p>Zahlungsart: SEPA-Lastschrift{% if term and term.credit_days and term.due_date_based_on == "Day(s) after invoice date" %}, Einzug {{ term.credit_days }} Tage nach Rechnungsdatum{% endif %}, {{ "gemäß erteiltem SEPA-Lastschriftmandat" if has_mandate else "nach Erteilung eines gültigen SEPA-Lastschriftmandats" }}.</p>
|
||||
{%- endif %}
|
||||
{%- if doc.get("terms") %}<div class="muted">{{ doc.terms }}</div>{% endif %}
|
||||
<p class="muted">Vielen Dank für Ihr Vertrauen.</p>
|
||||
|
||||
@@ -517,3 +517,17 @@ func TestLetterHeadSourceIsRestoredAndTbodyIgnored(t *testing.T) {
|
||||
t.Fatalf("source not restored: %v", lh["source"])
|
||||
}
|
||||
}
|
||||
|
||||
// With a discount (above all one on the grand total) ERPNext lowers net_total
|
||||
// but keeps tax_amount at the pre-discount value; the printed VAT must be the
|
||||
// amount after the discount, and the lines must add up to the total.
|
||||
func TestTotalsPrintTheTaxAfterDiscount(t *testing.T) {
|
||||
if strings.Contains(documentHTML, `get_formatted("tax_amount", doc)`) || strings.Contains(documentHTML, `get_formatted("discount_amount")`) {
|
||||
t.Fatal("totals print the pre-discount tax or the gross discount")
|
||||
}
|
||||
for _, want := range []string{`tax_amount_after_discount_amount`, `Zwischensumme`, `doc.total`, `Einzug {{ term.credit_days }} Tage`} {
|
||||
if !strings.Contains(documentHTML, want) {
|
||||
t.Errorf("document template lacks %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user