{%- macro amount(value, currency="USD") -%}{{ currency_symbol(currency) }}{{
"{:,.2f}".format(value | float | abs) }}{%- endmacro -%} {%- macro
currency_symbol(currency) -%} {%- set code = currency | upper if currency else
'USD' -%} {%- if code == 'USD' -%}$ {%- elif code == 'CAD' -%}CA$ {%- elif code
== 'AUD' -%}A$ {%- elif code == 'NZD' -%}NZ$ {%- elif code == 'EUR' -%}€ {%-
elif code == 'GBP' -%}£ {%- elif code == 'JPY' -%}¥ {%- else -%}{{ code }}{%-
endif -%} {%- endmacro -%} {%- macro category_row(category, category_total,
swatch_index) -%} {%- set children = category.children |
selectattr('transaction_count') | sort(attribute='total_amount', reverse=true)
-%} {%- set section_total = category_total | abs -%} {%- set percent =
((category.total_amount | abs / section_total) * 100) | round -%} {%- if
children -%}
{{ category.category_name }}
{{ amount(category.total_amount, category.currency or 'USD')
}}{{ percent }}%
{%- for child in children -%} {%- set child_percent =
((child.total_amount | abs / section_total) * 100) | round -%}