{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead, footer, print_settings=None, print_heading_template=None) -%} {% if letter_head and not no_letterhead %}
{{ letter_head }}
{% endif %} {% if print_heading_template %} {{ frappe.render_template(print_heading_template, {"doc":doc}) }} {% else %} {% endif %} {%- if doc.meta.is_submittable and doc.docstatus==2-%}

{{ _("CANCELLED") }}

{%- endif -%} {%- endmacro -%} {% for page in layout %}
{{ add_header(loop.index, layout|len, doc, letter_head, no_letterhead, footer, print_settings) }}
{% set address = (doc.address_display) %} {% if address and address.rstrip().endswith("
") %} {% set address = address[:-5] %} {% endif %} {% set company_address_display = (doc.company_address_display) %} {% if company_address_display and company_address_display.rstrip().endswith("
") %} {% set company_address_display = company_address_display[:-5] %} {% endif %}
{{ _("Customer Name") }}: {{doc.customer_name }} {{ _("Payment Due Date") }}: {{ frappe.utils.format_date(doc.due_date) }}
{{ _("Invoice Number") }}: {{ doc.name }} {{ _("Invoice Date") }}: {{ frappe.utils.format_date(doc.posting_date) }}
{{ _("Bill From") }}:
{{ address }}
{{ _("Bill To") }}:
{{ company_address_display }}
{% for item in doc.items %} {% endfor %}
{{ _("No") }} {{ _("Item") }} {{ _("Quantity") }} {{ _("Rate") }} {{ _("Amount") }}
{{ loop.index }} {{ item.item_name }} {{ item.get_formatted("qty", 0) }} {{ item.uom }} {{ item.get_formatted("net_rate", doc) }} {{ item.get_formatted("net_amount", doc) }}

{{ _("Total in words") }}

{{ doc.in_words }}
{% set tax_rate = doc.taxes | selectattr("tax_amount") | sum(attribute="rate") %} {% if tax_rate > 0 %} {% endif %}
{{ _("Sub Total:") }} {{ doc.get_formatted("total", doc) }}
{{ _("Discount") }} ({{ doc.additional_discount_percentage }}%): {{ doc.get_formatted("discount_amount", doc) }}
{{ _("Tax") }} ({{ tax_rate }}%): {{ doc.get_formatted("total_taxes_and_charges", doc) }}
{{ _("Grand Total:") }} {{ doc.get_formatted("grand_total", doc) }}
{% if doc.taxes_and_charges %}
{{ _("Tax Breakup") }}
{% for row in doc.taxes %} {% endfor %} {% for item in doc.items %} {% for row in doc.taxes %} {% set tax_amount = item.base_net_amount * (row.rate / 100) %} {% endfor %} {% endfor %}
{{ _("HSN/SAC") }} {{ _("Taxable Amount") }}{{ row.description }}
{{ item.gst_hsn_code }} {{ item.get_formatted("base_net_amount", doc) }} ({{ (row.rate) }}%) {{ frappe.format_value(tax_amount, {"fieldtype": "Currency"}, doc) }}
{% endif %} {% if doc.terms %}
{{ _("Terms and Conditions") }}
{{ doc.terms}}
{% endif %}
{% endfor %}