Consolidate display logic and always show full value on hover
This commit is contained in:
parent
bc52ccc349
commit
2eff00b5db
@ -213,25 +213,38 @@ def transaction():
|
|||||||
# Template filters
|
# Template filters
|
||||||
|
|
||||||
@app.template_filter('a')
|
@app.template_filter('a')
|
||||||
def filter_amount(amt):
|
def filter_amount(amt, link=None):
|
||||||
if amt.near_zero:
|
if amt.near_zero:
|
||||||
return flask.Markup('0.00 ')
|
amt_str = '0.00'
|
||||||
elif amt > 0:
|
is_pos = True
|
||||||
return flask.Markup('{:,.2f} '.format(amt.amount).replace(',', ' ')) # Narrow no-break space
|
elif amt >= 0:
|
||||||
|
amt_str = '{:,.2f}'.format(amt.amount).replace(',', ' ') # Narrow no-break space
|
||||||
|
is_pos = True
|
||||||
else:
|
else:
|
||||||
return flask.Markup('({:,.2f})'.format(-amt.amount).replace(',', ' '))
|
amt_str = '{:,.2f}'.format(-amt.amount).replace(',', ' ')
|
||||||
|
is_pos = False
|
||||||
|
|
||||||
|
if link:
|
||||||
|
if is_pos:
|
||||||
|
return flask.Markup('<a href="{}"><span title="{}">{}</span></a> '.format(link, amt.tostr(False), amt_str))
|
||||||
|
else:
|
||||||
|
return flask.Markup('<a href="{}"><span title="{}">({})</span></a>'.format(link, amt.tostr(False), amt_str))
|
||||||
|
else:
|
||||||
|
if is_pos:
|
||||||
|
return flask.Markup('<span title="{}"> '.format(amt.tostr(False), amt_str))
|
||||||
|
else:
|
||||||
|
return flask.Markup('<span title="{}">({})</span>'.format(amt.tostr(False), amt_str))
|
||||||
|
|
||||||
@app.template_filter('b')
|
@app.template_filter('b')
|
||||||
def filter_amount_positive(amt):
|
def filter_amount_positive(amt):
|
||||||
return flask.Markup('{:,.2f}'.format(amt.amount).replace(',', ' '))
|
return flask.Markup('<span title="{}">{:,.2f}</span>'.format(amt.tostr(False), amt.amount).replace(',', ' '))
|
||||||
#return flask.Markup('{:,.2f} {}'.format(amt.amount, amt.currency.name).replace(',', ' '))
|
|
||||||
|
|
||||||
@app.template_filter('bc')
|
@app.template_filter('bc')
|
||||||
def filter_currency_positive(amt):
|
def filter_currency_positive(amt):
|
||||||
if amt.currency.is_prefix:
|
if amt.currency.is_prefix:
|
||||||
return flask.Markup('{}{:,.2f}'.format(amt.currency.name, amt.amount).replace(',', ' '))
|
return flask.Markup('<span title="{}">{}{:,.2f}</span>'.format(amt.tostr(False), amt.currency.name, amt.amount).replace(',', ' '))
|
||||||
else:
|
else:
|
||||||
return flask.Markup('{:,.2f} {}'.format(amt.amount, amt.currency.name).replace(',', ' '))
|
return flask.Markup('<span title="{}">{:,.2f} {}</span>'.format(amt.tostr(False), amt.amount, amt.currency.name).replace(',', ' '))
|
||||||
|
|
||||||
@app.template_filter('bt')
|
@app.template_filter('bt')
|
||||||
def filter_currency_table_positive(amt, show_price, link=None):
|
def filter_currency_table_positive(amt, show_price, link=None):
|
||||||
|
@ -38,12 +38,11 @@
|
|||||||
<td>
|
<td>
|
||||||
{% if not amount.near_zero %}
|
{% if not amount.near_zero %}
|
||||||
{% if account.name == config['current_year_earnings'] %}
|
{% if account.name == config['current_year_earnings'] %}
|
||||||
<a href="/pandl?{{ {'date_end': balance_sheet.date.strftime('%Y-%m-%d'), 'date_beg': balance_sheets[0].pstart.strftime('%Y-%m-%d'), 'compare': '0', 'cash': 'on' if cash else ''}|urlencode }}">
|
{{ amount|a('/pandl?' + {'date_end': balance_sheet.date.strftime('%Y-%m-%d'), 'date_beg': balance_sheets[0].pstart.strftime('%Y-%m-%d'), 'compare': '0', 'cash': 'on' if cash else ''}|urlencode) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="/transactions?{{ {'date': balance_sheet.date.strftime('%Y-%m-%d'), 'pstart': balance_sheet.pstart.strftime('%Y-%m-%d'), 'account': account.name, 'cash': 'on' if cash else ''}|urlencode }}">
|
{{ amount|a('/transactions?' + {'date': balance_sheet.date.strftime('%Y-%m-%d'), 'pstart': balance_sheet.pstart.strftime('%Y-%m-%d'), 'account': account.name, 'cash': 'on' if cash else ''}|urlencode) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ amount|a }}
|
|
||||||
</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
<td>{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %}</td>
|
<td>{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %}</td>
|
||||||
<td>{% if loop.first %}{{ transaction.description }}{% endif %}</td>
|
<td>{% if loop.first %}{{ transaction.description }}{% endif %}</td>
|
||||||
<td>{{ (posting.account.name|e).__str__().replace(':', ':<wbr>')|safe }}</td>
|
<td>{{ (posting.account.name|e).__str__().replace(':', ':<wbr>')|safe }}</td>
|
||||||
<td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount > 0 %}{{ amount|b }}{% endif %}</td>
|
||||||
<td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount < 0 %}{{ -amount|b }}{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</td>
|
</td>
|
||||||
{% for pandl in pandls %}
|
{% for pandl in pandls %}
|
||||||
{% set amount = (-pandl.get_balance(account) if invert else pandl.get_balance(account)).exchange(report_currency, True) %}
|
{% set amount = (-pandl.get_balance(account) if invert else pandl.get_balance(account)).exchange(report_currency, True) %}
|
||||||
<td>{% if not amount.near_zero %}<a href="/transactions?{{ {'date': pandl.date.strftime('%Y-%m-%d'), 'pstart': pandl.pstart.strftime('%Y-%m-%d'), 'account': account.name, 'cash': 'on' if cash else ''}|urlencode }}">{{ amount|a }}</a>{% endif %}</td>
|
<td>{% if not amount.near_zero %}{{ amount|a('/transactions?' + {'date': pandl.date.strftime('%Y-%m-%d'), 'pstart': pandl.pstart.strftime('%Y-%m-%d'), 'account': account.name, 'cash': 'on' if cash else ''}|urlencode) }}{% endif %}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{{ posting.comment }}</td>
|
<td>{{ posting.comment }}</td>
|
||||||
<td>{{ (posting.account.name|e).__str__().replace(':', ':<wbr>')|safe }}</td>
|
<td>{{ (posting.account.name|e).__str__().replace(':', ':<wbr>')|safe }}</td>
|
||||||
<td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount > 0 %}{{ amount|b }}{% endif %}</td>
|
||||||
<td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount < 0 %}{{ -amount|b }}{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@
|
|||||||
{% if account %}
|
{% if account %}
|
||||||
{# Reverse Dr/Cr so it's from the "perspective" of this account #}
|
{# Reverse Dr/Cr so it's from the "perspective" of this account #}
|
||||||
{% set ns.balance = ns.balance - amount %}
|
{% set ns.balance = ns.balance - amount %}
|
||||||
<td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount < 0 %}{{ -amount|b }}{% endif %}</td>
|
||||||
<td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount > 0 %}{{ amount|b }}{% endif %}</td>
|
||||||
<td style="text-align: right;">
|
<td style="text-align: right;">
|
||||||
{% if loop.last %}
|
{% if loop.last %}
|
||||||
{% if ns.balance >= 0 %}
|
{% if ns.balance >= 0 %}
|
||||||
@ -89,8 +89,8 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount > 0 %}{{ amount|b }}{% endif %}</td>
|
||||||
<td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
|
<td style="text-align: right;">{% if amount < 0 %}{{ -amount|b }}{% endif %}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Reference in New Issue
Block a user