FOR loops - lists of invoices
The Send multiple invoices
email template includes a list of invoices.
{% set sum_of_invoice_balances = 0 %}
{% for invoice in invoices %}
* Invoice {{ invoice.refnumber }} - balance: {{ invoice.balance|number_format(2) }}
{% set sum_of_invoice_balances = sum_of_invoice_balances + invoice.balance %}
{% endfor %}
Total balance due: {{ sum_of_invoice_balances|number_format(2) }}