jinja print format dynamic total - jigneshpshah/greycube_helpmanual GitHub Wiki
{%- macro add_header(page_num, max_pages, doc, letter_head, no_letterhead) -%}
{% if letter_head and not no_letterhead %}
{{ letter_head }}
{% endif %}
{%- if doc.meta.is_submittable and doc.docstatus==2-%}
{{ _("CANCELLED") }}
{%- endif -%}
{% if max_pages > 1 %}
{{ _("Page #{0} of {1}").format(page_num, max_pages) }}
{% endif %}
{%- endmacro -%}
{{ add_header(0,1,doc,letter_head, no_letterhead) }}
{{doc.name}}
{{_("Invoice Number:")}}
{{doc.posting_date}}
{{_("Invoice Date:")}}
{{doc.customer_name}}
{{_("Customer Name:")}}
{{doc.sales_partner}}
{{_(" Sales Partner:")}}
{{doc.customer_code_cf}}
{{_("Customer No:")}}
{{doc.sales_partner_no_cf or ''}}
{{_("Sales Partner No:")}}
{{doc.tax_id or ''}}
{{_("Tax No:")}}
{{doc.invoice_type_cf}}
{{_(" Invoice Type:")}}
{%- for row in doc.items -%}
{%- endfor -%}
{% set pricelisttotal = [] %}
{% set discounttotoal = [] %}
{% for item in doc.items %}
{% if pricelisttotal.append(item.base_price_list_rate * item.qty) %}{% endif %}
{% if discounttotoal.append(item.discount_amount * item.qty) %}{% endif %}
{% endfor %}
{{_("Total Before VAT")}}
{{_("Tax Amount")}}
{{_("Discount Amount")}}
{{_("Rate")}}
{{_("QTY")}}
{{_("Description")}}
{{_("Item Code")}}
{{row.get_formatted("base_net_amount")}}
{{row.get_formatted("tax_amount")}}
{{row.get_formatted("discount_amount")}}
{{ row.get_formatted("base_price_list_rate", doc) }}
{{ row.qty }}
{{ row.description or '' }}
{{ row.item_code }}
{{doc.base_net_total}}
{{ doc.items|sum(attribute='tax_amount') }}
{{ '%0.2f' | format(discounttotoal | sum) }}
{{ '%0.2f' | format(pricelisttotal | sum) }}
{{_("Total")}}
{{ doc.items|sum(attribute='tax_amount') }}
{{_("VAT")}}
{{doc.grand_total}}
{{doc.in_words}} {{_(": Amount in Words")}}
{% if doc.accounts_receivable_summary_cf %}
{{_("Customer Aging")}}
{{ doc.accounts_receivable_summary_cf or '' }}
{% endif %}
Terms and Conditions
{{doc.terms or ''}}
Customer Stamp
Received By
Reviewed By
Prepared By
_____________
_____________
_____________
_____________
{% if not no_letterhead and footer %}
{{ footer }}
{% endif %}