Skip to main content
All CollectionsAutomationTemplates
Template Smart Field: Customer balances per currency
Template Smart Field: Customer balances per currency

Use a smart field that can list the balances of a customer, grouped by currency.

Ron Danenberg avatar
Written by Ron Danenberg
Updated over 7 months ago

If you need to show the total balance per currency of all the invoices belonging to a customer, this guide will show you how.

Let's imagine this scenario where the customer has 3 invoices:

  • USD 99 overdue by 5 days

  • GBP 5 overdue by 10 days

  • GBP 3 overdue by 12 days

You can use this code:

{% balances_per_currency customer as balances_list %}
The balances per currency:
{% for elem in balances_list %}
- {{elem.currency.iso}} {{elem.balance}}
{% endfor %}

What are we seeing?

1) The function is balances_per_currency. We assign it to the current Customer and name the list it outputs as balances_list.

2) We loop through it, where every element of the list will be call elem.

3) For every element, we print the currency ISO and balance,

In the example above, it will output:

The balances per currency:
USD 99.00
GBP 8.00

The list is ordered by descending balance.

Did this answer your question?