I am building a custom print format and want to map the currency to the totals.
{% for group in doc.items | groupby("item_code") %}
{% set group_count = group.list|length %}
{% set count = 1 %}
{% set item_desc = [] %}
{% for item in group.list %}
{% if count == 1 -%}
{% set _ = item_desc.append(item.item_name) %}
{%- endif %}
{% set count = count + 1 %}
{%- endfor %}
<tr>
<td style="width: 35%; text-align: left;">{{ group.grouper }} - {{ item_desc[0] }}</td>
{% set tot_qty = group.list|sum(attribute='qty') %}
{% set tot_amt = group.list|sum(attribute='net_amount') %}
{% set avg_rate = tot_amt / tot_qty %}
<td style="width: 15%; text-align: right;">{{ (tot_qty | round(2)|string).rstrip('0').rstrip('.') }} </td>
<td style="width: 15%; text-align: right;">{{ "{:,.2f}".format(avg_rate) }} </td>
<td style="width: 25%; text-align: right;">{{ "{:,.2f}".format(tot_amt) }}</td>
</tr>
{%- endfor %}