diff --git a/ledger_pyreport/__init__.py b/ledger_pyreport/__init__.py
index ea04df6..86cf8a2 100644
--- a/ledger_pyreport/__init__.py
+++ b/ledger_pyreport/__init__.py
@@ -213,25 +213,38 @@ def transaction():
# Template filters
@app.template_filter('a')
-def filter_amount(amt):
+def filter_amount(amt, link=None):
if amt.near_zero:
- return flask.Markup('0.00 ')
- elif amt > 0:
- return flask.Markup('{:,.2f} '.format(amt.amount).replace(',', ' ')) # Narrow no-break space
+ amt_str = '0.00'
+ is_pos = True
+ elif amt >= 0:
+ amt_str = '{:,.2f}'.format(amt.amount).replace(',', ' ') # Narrow no-break space
+ is_pos = True
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('{} '.format(link, amt.tostr(False), amt_str))
+ else:
+ return flask.Markup('({})'.format(link, amt.tostr(False), amt_str))
+ else:
+ if is_pos:
+ return flask.Markup(' '.format(amt.tostr(False), amt_str))
+ else:
+ return flask.Markup('({})'.format(amt.tostr(False), amt_str))
@app.template_filter('b')
def filter_amount_positive(amt):
- return flask.Markup('{:,.2f}'.format(amt.amount).replace(',', ' '))
- #return flask.Markup('{:,.2f} {}'.format(amt.amount, amt.currency.name).replace(',', ' '))
+ return flask.Markup('{:,.2f}'.format(amt.tostr(False), amt.amount).replace(',', ' '))
@app.template_filter('bc')
def filter_currency_positive(amt):
if amt.currency.is_prefix:
- return flask.Markup('{}{:,.2f}'.format(amt.currency.name, amt.amount).replace(',', ' '))
+ return flask.Markup('{}{:,.2f}'.format(amt.tostr(False), amt.currency.name, amt.amount).replace(',', ' '))
else:
- return flask.Markup('{:,.2f} {}'.format(amt.amount, amt.currency.name).replace(',', ' '))
+ return flask.Markup('{:,.2f} {}'.format(amt.tostr(False), amt.amount, amt.currency.name).replace(',', ' '))
@app.template_filter('bt')
def filter_currency_table_positive(amt, show_price, link=None):
diff --git a/ledger_pyreport/jinja2/balance.html b/ledger_pyreport/jinja2/balance.html
index e304d47..7be02fd 100644
--- a/ledger_pyreport/jinja2/balance.html
+++ b/ledger_pyreport/jinja2/balance.html
@@ -38,12 +38,11 @@
{% if not amount.near_zero %}
{% if account.name == config['current_year_earnings'] %}
-
+ {{ 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 %}
-
+ {{ 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 %}
- {{ amount|a }}
-
+
{% endif %}
|
{% endfor %}
diff --git a/ledger_pyreport/jinja2/debug_noncash_transactions.html b/ledger_pyreport/jinja2/debug_noncash_transactions.html
index 259bcfc..1f68f65 100644
--- a/ledger_pyreport/jinja2/debug_noncash_transactions.html
+++ b/ledger_pyreport/jinja2/debug_noncash_transactions.html
@@ -41,8 +41,8 @@
{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %} |
{% if loop.first %}{{ transaction.description }}{% endif %} |
{{ (posting.account.name|e).__str__().replace(':', ':')|safe }} |
- {% if amount > 0 %}{{ amount|b }}{% endif %} |
- {% if amount < 0 %}{{ -amount|b }}{% endif %} |
+ {% if amount > 0 %}{{ amount|b }}{% endif %} |
+ {% if amount < 0 %}{{ -amount|b }}{% endif %} |
{% endfor %}
{% endfor %}
diff --git a/ledger_pyreport/jinja2/pandl.html b/ledger_pyreport/jinja2/pandl.html
index cda1e00..a85cba7 100644
--- a/ledger_pyreport/jinja2/pandl.html
+++ b/ledger_pyreport/jinja2/pandl.html
@@ -29,7 +29,7 @@
{% for pandl in pandls %}
{% set amount = (-pandl.get_balance(account) if invert else pandl.get_balance(account)).exchange(report_currency, True) %}
- {% if not amount.near_zero %}{{ amount|a }}{% endif %} |
+ {% 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 %} |
{% endfor %}
diff --git a/ledger_pyreport/jinja2/transaction.html b/ledger_pyreport/jinja2/transaction.html
index ecd9d7a..9b471e3 100644
--- a/ledger_pyreport/jinja2/transaction.html
+++ b/ledger_pyreport/jinja2/transaction.html
@@ -56,8 +56,8 @@
{{ posting.comment }} |
{{ (posting.account.name|e).__str__().replace(':', ':')|safe }} |
- {% if amount > 0 %}{{ amount|b }}{% endif %} |
- {% if amount < 0 %}{{ -amount|b }}{% endif %} |
+ {% if amount > 0 %}{{ amount|b }}{% endif %} |
+ {% if amount < 0 %}{{ -amount|b }}{% endif %} |
{% endfor %}
diff --git a/ledger_pyreport/jinja2/transactions.html b/ledger_pyreport/jinja2/transactions.html
index 9b6d211..7f29a10 100644
--- a/ledger_pyreport/jinja2/transactions.html
+++ b/ledger_pyreport/jinja2/transactions.html
@@ -77,8 +77,8 @@
{% if account %}
{# Reverse Dr/Cr so it's from the "perspective" of this account #}
{% set ns.balance = ns.balance - amount %}
- {% if amount < 0 %}{{ -amount|b }}{% endif %} |
- {% if amount > 0 %}{{ amount|b }}{% endif %} |
+ {% if amount < 0 %}{{ -amount|b }}{% endif %} |
+ {% if amount > 0 %}{{ amount|b }}{% endif %} |
{% if loop.last %}
{% if ns.balance >= 0 %}
@@ -89,8 +89,8 @@
{% endif %}
|
{% else %}
- {% if amount > 0 %}{{ amount|b }}{% endif %} |
- {% if amount < 0 %}{{ -amount|b }}{% endif %} |
+ {% if amount > 0 %}{{ amount|b }}{% endif %} |
+ {% if amount < 0 %}{{ -amount|b }}{% endif %} |
{% endif %}
{% endfor %}