{% set entry_types = ['open', 'close', 'transaction', 'balance', 'note', 'document', 'pad', 'query', 'custom'] %} {% set sub_types = { 'custom': ( ('budget', 'B', _('Budget entries')), ), 'document': ( ('discovered', 'D', _('Documents with a #discovered tag')), ('linked', 'L', _('Documents with a #linked tag')), ), 'transaction': ( ('cleared', '*', _('Cleared transactions')), ('pending', '!', _('Pending transactions')), ('other', 'x', _('Other transactions')), ), } %} {% set keyboard_shortcuts = { 'open': 's o', 'close': 's c', 'balance': 's b', 'note': 's n', 'pad': 's p', 'query': 's q', 'custom': 's C', 'budget': 's B', 'transaction': 's t', 'cleared': 't c', 'pending': 't p', 'other': 't o', 'document': 's d', 'discovered': 'd d', 'linked': 'd l', } %} {% set short_type = { 'balance': 'Bal', 'close': 'Close', 'document': 'Doc', 'note': 'Note', 'open': 'Open', } %} {% if not request.args.get('show') %} {% set journal_show = g.ledger.fava_options['journal-show'] + g.ledger.fava_options['journal-show-transaction'] + g.ledger.fava_options['journal-show-document'] %} {% else %} {% set journal_show = request.args.getlist('show') %} {% endif %} {% macro account_link(name) %}{{ name }}{% endmacro %} {% macro render_metadata(metadata, entry_hash=None) -%} {% if metadata %}
{% for key, value in metadata.items() %}
{{ key }}:
{%- if key.startswith('document') %}{{ value }} {% elif value is string and (value.startswith('http://') or value.startswith('https://')) %}{{ value }} {% else %} {{ value }} {% endif -%} {%- if key.startswith('document') %}{% 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(entries, show_change_and_balance=False) %} {% autoescape false %}
{% for type in entry_types %} {% if type in sub_types.keys() %} {% for sub_type in sub_types[type] %} {% endfor %} {% endif %} {% endfor %}
  1. {{ _('Date') }} {{ _('F') }} {{ _('Narration/Payee') }} {{ _('Position') }} {{ _('Price') }} {{ _('Cost') }} {% if show_change_and_balance %} {{ _('Change') }} {{ _('Balance') }} {% endif %}

  2. {% for entry in entries|reverse %} {% if show_change_and_balance %} {% set entry, _, change, balance = entry %} {% endif %} {% set type = entry.__class__.__name__.lower() %} {% set entry_hash = entry|hash_entry %} {% set metadata = entry.meta|remove_keys(['__tolerances__', '__automatic__', 'filename', 'lineno']) %}
  3. {{ 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 == "" %}{{ value.value|format_amount }} {%- 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, show_if_zero=True) }} {{ 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 %} {% for key, value in metadata.items() %} {% endfor %} {% for posting in entry.postings %} {% endfor %} {% if type == 'balance' %} {{ entry.amount|format_amount }} {% endif %} {% if show_change_and_balance %} {% for pos in change|cost_or_value(entry.date) %}{{ pos.units|format_amount }}
    {% endfor %}
    {% for pos in balance|cost_or_value(entry.date) %}{{ pos.units|format_amount }}
    {% endfor %}

    {% endif %} {{ render_metadata(metadata, entry_hash) }} {% if entry.postings %} {% endif %}
  4. {% endfor %}
{% endautoescape %} {%- endmacro %}