{% from 'macros/_commodity_macros.html' import render_num, render_amount %} {% set short_type = { 'balance': 'Bal', 'close': 'Close', 'document': 'Doc', 'note': 'Note', 'open': 'Open', } %} {% macro _account_link(name) %}{{ name }}{% endmacro %} {% macro _render_metadata_indicators(metadata) -%} {% for key, value in metadata %} {{ key[:2] }} {% endfor %} {%- endmacro %} {% macro _render_metadata(metadata, entry_hash=None) -%} {% if metadata %}
{% for key, value in metadata %}
{{ key }}:
{%- if key.startswith('document') %}{{ value }} {% elif value is string and (value.startswith('http://') or value.startswith('https://')) %}{{ value }} {% else %} {{ value }} {% endif -%}
{% endfor %}
{% endif %} {% endmacro %} {% macro _render_tags_links(entry) -%} {% for tag in entry.tags|sort %}#{{ tag }}{% endfor %} {% for link_ in entry.links|sort %}^{{ link_ }}{% endfor %} {%- endmacro %} {% macro journal_table_contents(entries, show_change_and_balance=False, ledger=None) %} {% set ledger = ledger or g.ledger %} {% autoescape false %} {% for entry in entries %} {% if show_change_and_balance %} {% set index, entry, change, balance = entry %} {% else %} {% set index, entry = entry %} {% endif %} {% set type = entry.__class__.__name__.lower() %} {% set metadata_items = entry.meta|meta_items %} {% set entry_hash = entry|hash_entry -%}
  • {{ entry.date }} {% if type == 'transaction' %}{{ entry.flag }}{% else %}{{ short_type.get(type, type[:3]) }}{% endif %} {% if type == 'open' or type == 'close' %} {{ _account_link(entry.account) }} {% elif type == 'note' %} {{ entry.comment }} {% elif type == 'query' %} {{ entry.name }} {% elif type == 'pad' %} {{ _account_link(entry.account) }} from {{ _account_link(entry.source_account) }} {% elif type == 'custom' %} {{ entry.type }} {%- for value in entry['values'] -%}  {% if value.dtype|string == "" %}{{ _account_link(value.value) }} {%- elif value.dtype|string == "" %}{{ render_amount(ledger, value.value) }} {%- elif value.dtype|string == "" %}"{{ value.value }}" {%- elif value.dtype|string == "" %}{{ value.value }} {%- elif value.dtype|string == "" %}{{ value.value }}{% endif -%} {%- endfor -%} {% elif type == 'document' %} {{ _account_link(entry.account) }} {{ entry.filename|basename }} {{ _render_tags_links(entry) }} {% elif type == 'balance' %} {{ _account_link(entry.account) }} {% if entry.diff_amount %} accumulated {{ (entry.amount.number + entry.diff_amount.number)|format_currency(entry.amount.currency) }} {{ entry.amount.currency }} {% endif %} {% elif type == 'transaction' %} {{ entry.payee or '' }}{% if entry.payee and entry.narration %}{% endif %}{{ entry.narration or '' }} {{ _render_tags_links(entry) }} {% endif %} {{- _render_metadata_indicators(metadata_items) -}} {%- for posting in entry.postings -%} {{- _render_metadata_indicators(posting.meta|meta_items) -}} {%- endfor -%} {% if type == 'balance' %} {{ render_amount(ledger, entry.amount, 'num bal' + (' pending' if entry.diff_amount else '')) }} {% if entry.diff_amount %} {{- render_num(ledger, entry.diff_amount.currency, entry.diff_amount.number) -}} {% else %} {% endif %} {% if not show_change_and_balance %} {% endif %} {% endif %} {% if show_change_and_balance %} {% if type == 'transaction' %} {%- for currency, number in change.items() %}{{ render_num(ledger, currency, number) }}
    {% endfor -%}
    {% endif %} {%- for currency, number in balance.items() %}{{ render_num(ledger, currency, number) }}
    {% endfor -%}
    {% endif %}

    {{ _render_metadata(metadata_items, entry_hash) }} {% if entry.postings %} {% endif %}
  • {%- endfor %} {% endautoescape %} {%- endmacro %}