fix: gross discount layout for VAT-inclusive invoices
With inclusive pricing and a discount on Grand Total the Total line is the tax-inclusive item total and the discount is printed as entered, followed by Total After Discount, which the Net Total and charge lines then break down. Other cases keep the net layout: Total (net before discount), the discount's net share, Net Total, charges. Thai label for Total After Discount.
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
ERPNext takes an Additional Discount off the items' net amounts (item.distributed_discount_amount;
|
||||
a discount on Grand Total is split between net and taxes) and books each charge at
|
||||
tax_amount_after_discount_amount, while upstream prints the discount as entered and the
|
||||
pre-discount tax_amount. Here: the net share of the discount, Net Total, then the charges
|
||||
as booked. A discount that is not distributed (cash / non-trade) comes off the grand total
|
||||
only, so it stays after the charges, as upstream. -#}
|
||||
pre-discount tax_amount, so the lines do not add up to Grand Total.
|
||||
|
||||
Inclusive tax with a discount on Grand Total: the Total line is the tax-inclusive item total
|
||||
and the discount is printed as entered; Total After Discount is then broken down into
|
||||
Net Total and the charges. Otherwise the Total line is the net before the discount, so the
|
||||
discount is its net share, followed by Net Total and the charges. A discount that is not
|
||||
distributed (cash / non-trade) comes off the grand total only and stays after the charges,
|
||||
as upstream. -#}
|
||||
{%- macro amount_row(label, value) -%}
|
||||
<div class="row">
|
||||
<div class="col-xs-5 {%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
@@ -20,11 +25,16 @@
|
||||
{{ frappe.format_value(value, {"fieldtype": "Currency", "options": "currency"}, doc) }}
|
||||
{%- endmacro -%}
|
||||
{%- set net_discount = doc.get("items")|map(attribute="distributed_discount_amount")|select|sum -%}
|
||||
{%- set gross_discount = net_discount and doc.apply_discount_on == "Grand Total" and doc.flags.show_inclusive_tax_in_print -%}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-6"></div>
|
||||
<div class="col-xs-6">
|
||||
{%- if net_discount -%}
|
||||
{%- if gross_discount -%}
|
||||
{{ amount_row(_(doc.meta.get_label("discount_amount")), "- " ~ doc.get_formatted("discount_amount", doc)) }}
|
||||
{{ amount_row(_("Total After Discount"), currency(doc.total - doc.discount_amount)) }}
|
||||
{{ amount_row(_(doc.meta.get_label("net_total")), doc.get_formatted("net_total", doc)) }}
|
||||
{%- elif net_discount -%}
|
||||
{{ amount_row(_(doc.meta.get_label("discount_amount")), "- " ~ currency(net_discount)) }}
|
||||
{{ amount_row(_(doc.meta.get_label("net_total")), doc.get_formatted("net_total", doc)) }}
|
||||
{%- endif -%}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
{#- ERPNext's templates/print_formats/includes/total.html, except that with inclusive tax the
|
||||
"Total (Without Tax)" line is the net total before the Additional Discount: net_total already
|
||||
has the discount's net share (item.distributed_discount_amount) taken off, and the taxes
|
||||
include prints that share and Net Total right below this line. -#}
|
||||
{#- ERPNext's templates/print_formats/includes/total.html, paired with the taxes include:
|
||||
with inclusive tax and a discount on Grand Total the Total line is the tax-inclusive item
|
||||
total (the discount is printed as entered below it); with inclusive tax otherwise it is
|
||||
the net before the Additional Discount, since net_total already has the discount's net
|
||||
share (item.distributed_discount_amount) taken off. -#}
|
||||
{%- set net_discount = doc.get("items")|map(attribute="distributed_discount_amount")|select|sum -%}
|
||||
{%- set gross_discount = net_discount and doc.apply_discount_on == "Grand Total" and doc.flags.show_inclusive_tax_in_print -%}
|
||||
<div class="row {% if df.bold %}important{% endif %} data-field">
|
||||
{% if doc.flags.show_inclusive_tax_in_print %}
|
||||
{%- set before_discount = doc.net_total + (doc.get("items")|map(attribute="distributed_discount_amount")|select|sum) -%}
|
||||
{% if doc.flags.show_inclusive_tax_in_print and not gross_discount %}
|
||||
<div class="col-xs-5 {%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
<label>{{ _("Total (Without Tax)") }}</label></div>
|
||||
<div class="col-xs-7 text-right value">
|
||||
{{ frappe.format_value(before_discount, {"fieldtype": "Currency", "options": "currency"}, doc) }}
|
||||
{{ frappe.format_value(doc.net_total + net_discount, {"fieldtype": "Currency", "options": "currency"}, doc) }}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-xs-5 {%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
|
||||
@@ -50,6 +50,7 @@ Amount,จำนวนเงิน
|
||||
Total,รวม
|
||||
Total (Without Tax),รวมก่อนภาษี
|
||||
Net Total,ยอดรวมสุทธิ
|
||||
Total After Discount,ยอดรวมหลังหักส่วนลด
|
||||
Total Taxes and Charges,รวมภาษีและค่าธรรมเนียม
|
||||
Grand Total,ยอดรวมทั้งสิ้น
|
||||
Rounded Total,ยอดรวมปัดเศษ
|
||||
|
||||
|
Reference in New Issue
Block a user