{%- from "templates/print_formats/standard_macros.html" import add_header, render_field, print_value, fieldmeta, get_width, get_align_class with context -%} {%- macro render_currency(df, doc) -%}
{% if doc.get(df.fieldname) != None -%} {{ frappe.utils.fmt_money((doc[df.fieldname])|abs, currency=doc.currency) }} {% endif %}
{%- endmacro -%} {%- macro render_taxes(df, doc) -%} {%- set data = doc.get(df.fieldname)[df.start:df.end] -%}
{%- for charge in data -%} {%- if (charge.tax_amount or doc.flags.print_taxes_with_zero_amount) and (not charge.included_in_print_rate or doc.flags.show_inclusive_tax_in_print) -%}
{{ frappe.utils.fmt_money((charge.tax_amount)|abs, currency=doc.currency) }}
{%- endif -%} {%- endfor -%}
{%- endmacro -%} {%- macro render_table(df, doc) -%} {%- set table_meta = frappe.get_meta(df.options) -%} {%- set data = doc.get(df.fieldname)[df.start:df.end] -%} {%- if doc.print_templates and doc.print_templates.get(df.fieldname) -%} {% include doc.print_templates[df.fieldname] %} {%- else -%} {%- if data -%} {%- set visible_columns = get_visible_columns(doc.get(df.fieldname), table_meta, df) -%}
{% for tdf in visible_columns %} {% if (data and not data[0].flags.compact_item_print) or tdf.fieldname in doc.get(df.fieldname)[0].flags.compact_item_fields %} {% endif %} {% endfor %} {% for d in data %} {% for tdf in visible_columns %} {% if not print_settings.compact_item_print or tdf.fieldname in doc.flags.compact_item_fields %} {% elif tdf.fieldtype == 'Currency' %}
{{ frappe.utils.fmt_money((d[tdf.fieldname])|abs, currency=doc.currency) }}
{% else %} {% if doc.child_print_templates %} {%- set child_templates = doc.child_print_templates.get(df.fieldname) -%}
{{ print_value(tdf, d, doc, visible_columns, child_templates) }}
{% else %}
{{ print_value(tdf, d, doc, visible_columns) }}
{% endif %} {% endif %} {% endif %} {% endfor %} {% endfor %}
{{ _("Sr") }} {{ _(tdf.label) }}
{{ d.idx }} {% if tdf.fieldname == 'qty' %}
{{ (d[tdf.fieldname])|abs }}
{%- endif -%} {%- endif -%} {%- endmacro -%} {% for page in layout %}
{{ add_header(loop.index, layout|len, doc, letter_head, no_letterhead, footer, print_settings) }}
{% if print_settings.repeat_header_footer %} {% endif %} {% for section in page %}
{% if section.columns.fields %} {%- if doc.print_line_breaks and loop.index != 1 -%}
{%- endif -%} {%- if doc.print_section_headings and section.label and section.has_data -%}

{{ _(section.label) }}

{% endif %} {%- endif -%} {% for column in section.columns %}
{% for df in column.fields %} {% if df.fieldname == 'taxes' %} {{ render_taxes(df, doc) }} {% elif df.fieldtype == 'Currency' %} {{ render_currency(df, doc) }} {% elif df.fieldtype =='Table' %} {{ render_table(df, doc)}} {% elif doc[df.fieldname] and df.fieldname != 'total_qty' %} {{ render_field(df, doc) }} {% endif %} {% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}