{% set infotext = {
'green': "The last entry is a passing balance check.",
'red': "The last entry is a failing balance check.",
'yellow': "The last entry is not a balance check.",
'gray': "This account has not been updated in a while.",
} %}
{% macro indicator(account) %}
{% set status=api.is_account_uptodate(account) %}
{% if status %}
{% endif %}
{% endmacro %}
{% macro last_account_activity(account_name) %}
{% set last_account_activity_in_days=api.last_account_activity_in_days(account_name) %}
{% if last_account_activity_in_days > config['uptodate-indicator-grey-lookback-days'] %}
{% endif %}
{% endmacro %}
{% macro balance_directive(account) %}
{% for position in api.inventory(account) %}
{{ today }} balance {{ account.ljust(28) }} {% with num=position.units.number|string %}{{ num.rjust(15) }}{% endwith %} {{ position.units.currency }}
{% endfor %}
{% endmacro %}
{% macro account_name(account_name, last_segment=False) %}
{{ account_name|last_segment if last_segment else account_name }}
{% if config['uptodate-indicator-show-everywhere'] %}
{% if account_name and account_name|uptodate_eligible %}
{{ indicator(account_name) }}
{{ last_account_activity(account_name) }}
{% endif %}
{% endif %}
{% endmacro %}
{% macro account_name_header(account_name) %}
{% set levels = account_name|account_level %}
{% for level in range(0, levels) %}
{% set subaccount_name = account_name.rsplit(':', maxsplit=levels-loop.index)[0] %}
{% set subaccount_part = account_name.split(':')[level] %}
{%- if loop.last -%}
{{ subaccount_part }}
{%- else -%}
{{ subaccount_part }}:
{%- endif -%}
{% endfor %}
{% if account_name and account_name|uptodate_eligible %}
{{ indicator(account_name) }}
{{ last_account_activity(account_name) }}
{% endif %}
{% set activity = api.statistics(account_name=account_name) %}
{% if activity %}
(Last entry: {{ activity.last_posting_date }})
{% endif %}
{% endmacro %}
{% macro balance_with_budget(currency, number, budget=None, show_currency=False, css_class="balance") %}
{% if number %}
{% if budget %}
{% set budget_curr = budget[currency] if currency in budget else None %}
{% if budget_curr != None %}
({{ budget_curr|format_currency(currency, show_if_zero=True) }})
{% else %}
{% endif %}
{% endif %}
{{ number|format_currency(currency) }}{% if show_currency %} {{ currency }}{% endif %}
{% endif %}
{% endmacro %}