{% import "_query_table.html" as querytable with context %} {% set module = request.args.get('module') %}
{% for key, label in [('aa_class', _('Asset Allocation Classes')), ('aa_account', _('Asset Allocation Accounts')), ('cashdrag', _('Cash Drag')), ('tlh', _('Tax Loss Harvestor')), ('summarizer', _('Summarizer')), ('minimizegains', _('Gains Minimizer')) ] %}

{% if not (module == key) %}{{ label }}{% else %} {{ label }}{% endif %}

{% endfor %}
{% if (module == None) %} Welcome! Fava Investor provides reports, analyses, and tools for investments. It implemented as a collection of modules. Use the tabs on the top to navigate to each module. {% endif %} {% macro table_list_renderer(title, tables) -%}

{{ title }}

{% if tables|length == 0 %} Module not configured. See example.beancount for how to configure this module. {% endif %} {% for table in tables %}

{{table[0]}}

{{ querytable.querytable(ledger, None, *table[1]) }} {% endfor %} {% endmacro %} {% if (module == 'aa_account') %} {{ table_list_renderer('Portfolio: Asset Allocation by Accounts', extension.build_aa_by_account()) }} {% endif %} {% if (module == 'cashdrag') %} {{ table_list_renderer('', extension.build_cashdrag()) }} {% endif %} {% if (module == 'summarizer') %} {{ table_list_renderer('', extension.build_summarizer()) }} {% endif %} {% if (module == 'minimizegains') %} {{ table_list_renderer('', extension.build_minimizegains()) }} {% endif %} {% if (module == 'tlh') %}

Tax Loss Harvester

{% set harvests = extension.build_tlh_tables() %}

Summary

{% for key, value in harvests[1].items() %} {% endfor %}
{{ _('Summary') }} {{ _('Val') }}
{{ key }} {{ value }}

Losses by Commodity

{{ querytable.querytable(ledger, None, *harvests[3]) }}

Candidates for tax loss harvesting

{{ querytable.querytable(ledger, None, *harvests[0]) }}

Potential wash sales: purchases within the past 30 days

Below is a list of purchases with the past 30 days. "earliest_sale" is the date on which a loss of the ticker shown can be harvested without resulting in a wash sale. {% set table_empty_msg = None %} {% if harvests[2][0]|length == 0 %} {% set table_empty_msg = 'No purchases of the candidates above found within the last 30 days!' %} {% endif %} {{ querytable.querytable(ledger, table_empty_msg, *harvests[2]) }}

What not to buy

Below is a list of recent sales with losses. Assuming these losses were harvested, purchasing these within 30 days of the sale could result in the loss becoming a wash sale. {% set lossy_sales = extension.recently_sold_at_loss() %} {% set table_empty_msg = None %} {% if lossy_sales[1]|length == 0 %} {% set table_empty_msg = 'No sales with losses found in the last 30 days!' %} {% endif %} {{ querytable.querytable(ledger, table_empty_msg, *lossy_sales) }}
None of the above is meant to be financial, legal, tax, or other advice. {% endif %} {% set table_hover_text = _('Hold Shift while clicking to expand all children. Hold Ctrl or Cmd while clicking to expand one level.') %} {# TODO: - add a format_percentage() to fava's template_filters, and use that here - display 0 decimal places for assets (needed for all of fava_investor) - fix: asset bucket spacing is too wide - get currency from libassetalloc instead of looping: {% for currency in ledger.options.operating_currency %} - remove links from asset class name #} {% macro asset_tree(account_node) %}
  1. {% for currency in ledger.options.operating_currency %} {{ currency }} {% endfor %} {{ _('Percentage') }}

  2. {% for account in ([account_node] if account_node.name else account_node.children) recursive %} {% for currency in ledger.options.operating_currency %} {{ account.balance|format_currency(currency) }} {{ account.balance_children|format_currency(currency) }} {% endfor %} {% set percentage_parent = '{:3.0f}% of {}'.format(account.percentage_parent, account.parent.name) if account.parent else '' %} {{ '{:6.2f} %'.format(account.percentage) if account.percentage else '' }} {{ '{:6.2f} %'.format(account.percentage_children) if account.percentage_children else '' }}

    {% if account.children %}
      {{ loop(account.children|sort(attribute='name')) }}
    {% endif %} {% endfor %}
{% endmacro %} {% if (module == 'aa_class') %}

Portfolio: Asset Allocation by Class

{% set results = extension.build_assetalloc_by_class() %} {% set chart_data = [{ 'type': 'hierarchy', 'label': "Asset Allocation", 'data': results[0].serialise(results[0]['currency']) }] %} {{ asset_tree(results[0]) }} {% endif %}