Skip to content

Commit

Permalink
remove dead code for Fava <v1.18 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
yagebu authored Feb 4, 2024
1 parent 841c4c9 commit 1c78027
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 40 deletions.
14 changes: 0 additions & 14 deletions fava_investor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Fava Investor: Investing related reports and tools for Beancount/Fava"""

from fava.ext import FavaExtensionBase
from fava import __version__ as fava_version

from .modules.tlh import libtlh
from .modules.assetalloc_class import libassetalloc
Expand Down Expand Up @@ -54,16 +53,3 @@ def build_minimizegains(self):
def recently_sold_at_loss(self):
accapi = FavaInvestorAPI()
return libtlh.recently_sold_at_loss(accapi, self.config.get('tlh', {}))

def use_new_querytable(self):
"""
fava added the ledger as a first required argument to
querytable.querytable after version 1.18, so in order to support both,
we have to detect the version and adjust how we call it from inside our
template
"""
split_version = fava_version.split('.')
if len(split_version) != 2:
split_version = split_version[:2]
major, minor = split_version
return int(major) > 1 or (int(major) == 1 and int(minor) > 18)
32 changes: 6 additions & 26 deletions fava_investor/templates/Investor.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% import "_query_table.html" as querytable with context %}
{% set new_querytable = extension.use_new_querytable() %}

{% set module = request.args.get('module') %}
<div class="headerline">
Expand Down Expand Up @@ -30,11 +29,7 @@ <h2>{{ title }}</h2>
{% endif %}
{% for table in tables %}
<h2>{{table[0]}}</h2>
{% if new_querytable %}
{{ querytable.querytable(ledger, None, *table[1]) }}
{% else %}
{{ querytable.querytable(None, *table[1]) }}
{% endif %}
{{ querytable.querytable(ledger, None, *table[1]) }}
{% endfor %}
{% endmacro %}
<!-- -------------------------------------------------------------------------------- -->
Expand Down Expand Up @@ -84,22 +79,15 @@ <h3 style="text-align:left">Summary</h3>
</div>
<div class="column">
<h3 style="text-align:left">Losses by Commodity</h3>
{% if new_querytable %}
{{ querytable.querytable(ledger, None, *harvests[3]) }}
{% else %}
{{ querytable.querytable(None, *harvests[3]) }}
{% endif %}
{{ querytable.querytable(ledger, None, *harvests[3]) }}
<br />
</div>
</div>


<h3>Candidates for tax loss harvesting</h3>
{% if new_querytable %}
{{ querytable.querytable(ledger, None, *harvests[0]) }}
{% else %}
{{ querytable.querytable(None, *harvests[0]) }}
{% endif %}
{{ querytable.querytable(ledger, None, *harvests[0]) }}

<br />


Expand All @@ -112,11 +100,7 @@ <h3>Potential wash sales: purchases within the past 30 days</h3>
{% if harvests[2][0]|length == 0 %}
{% set table_empty_msg = 'No purchases of the candidates above found within the last 30 days!' %}
{% endif %}
{% if new_querytable %}
{{ querytable.querytable(ledger, table_empty_msg, *harvests[2]) }}
{% else %}
{{ querytable.querytable(table_empty_msg, *harvests[2]) }}
{% endif %}
{{ querytable.querytable(ledger, table_empty_msg, *harvests[2]) }}
<br />

<h3>What not to buy</h3>
Expand All @@ -128,11 +112,7 @@ <h3>What not to buy</h3>
{% if lossy_sales[1]|length == 0 %}
{% set table_empty_msg = 'No sales with losses found in the last 30 days!' %}
{% endif %}
{% if new_querytable %}
{{ querytable.querytable(ledger, table_empty_msg, *lossy_sales) }}
{% else %}
{{ querytable.querytable(table_empty_msg, *lossy_sales) }}
{% endif %}
{{ querytable.querytable(ledger, table_empty_msg, *lossy_sales) }}

<br>
<i>None of the above is meant to be financial, legal, tax, or other advice.</i>
Expand Down

0 comments on commit 1c78027

Please sign in to comment.