Add home link and tweak transactions report heading

This commit is contained in:
RunasSudo 2020-03-20 23:20:39 +11:00
parent 1c217fd8d4
commit f5f59a7098
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
10 changed files with 327 additions and 283 deletions

View File

@ -98,6 +98,14 @@ def balance():
return flask.render_template('balance.html', ledger=l, balance_sheets=balance_sheets, accounts=accounts, config=config, report_currency=report_currency) return flask.render_template('balance.html', ledger=l, balance_sheets=balance_sheets, accounts=accounts, config=config, report_currency=report_currency)
def describe_period(date_end, date_beg):
if date_end == (date_beg.replace(year=date_beg.year + 1) - timedelta(days=1)):
return 'year ended {}'.format(date_end.strftime('%d %B %Y'))
elif date_beg == ledger.financial_year(date_end):
return 'financial year to {}'.format(date_end.strftime('%d %B %Y'))
else:
return 'period from {} to {}'.format(date_beg.strftime('%d %B %Y'), date_end.strftime('%d %B %Y'))
@app.route('/pandl') @app.route('/pandl')
def pandl(): def pandl():
date_beg = datetime.strptime(flask.request.args['date_beg'], '%Y-%m-%d') date_beg = datetime.strptime(flask.request.args['date_beg'], '%Y-%m-%d')
@ -118,14 +126,7 @@ def pandl():
if all(p.get_balance(account) == 0 and p.get_total(account) == 0 for p in pandls): if all(p.get_balance(account) == 0 and p.get_total(account) == 0 for p in pandls):
accounts.remove(account) accounts.remove(account)
if date_end == (date_beg.replace(year=date_beg.year + 1) - timedelta(days=1)): return flask.render_template('pandl.html', period=describe_period(date_end, date_beg), ledger=l, pandls=pandls, accounts=accounts, config=config, report_currency=report_currency)
period = 'year ended {}'.format(date_end.strftime('%d %B %Y'))
elif date_beg == ledger.financial_year(date_end):
period = 'financial year to {}'.format(date_end.strftime('%d %B %Y'))
else:
period = 'period from {} to {}'.format(date_beg.strftime('%d %B %Y'), date_end.strftime('%d %B %Y'))
return flask.render_template('pandl.html', period=period, ledger=l, pandls=pandls, accounts=accounts, config=config, report_currency=report_currency)
@app.route('/transactions') @app.route('/transactions')
def transactions(): def transactions():
@ -154,7 +155,7 @@ def transactions():
opening_balance = accounting.trial_balance(l, pstart, pstart).get_balance(account).exchange(report_currency, True) opening_balance = accounting.trial_balance(l, pstart, pstart).get_balance(account).exchange(report_currency, True)
closing_balance = accounting.trial_balance(l, date, pstart).get_balance(account).exchange(report_currency, True) closing_balance = accounting.trial_balance(l, date, pstart).get_balance(account).exchange(report_currency, True)
return flask.render_template('transactions.html', date=date, pstart=pstart, account=account, ledger=l, transactions=transactions, opening_balance=opening_balance, closing_balance=closing_balance, report_currency=report_currency) return flask.render_template('transactions.html', date=date, pstart=pstart, period=describe_period(date, pstart), account=account, ledger=l, transactions=transactions, opening_balance=opening_balance, closing_balance=closing_balance, report_currency=report_currency, timedelta=timedelta)
@app.template_filter('a') @app.template_filter('a')
def filter_amount(amt): def filter_amount(amt):

View File

@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
#} #}
{% extends 'base_report.html' %}
{% macro print_rows(account, invert=False, level=0) %} {% macro print_rows(account, invert=False, level=0) %}
<tr> <tr>
<td style="padding-left: calc(2px + {{ level }}em);"> <td style="padding-left: calc(2px + {{ level }}em);">
@ -80,40 +82,33 @@
</tr> </tr>
{% endmacro %} {% endmacro %}
<!DOCTYPE html> {% block title %}Balance Sheet as at {{ balance_sheets[0].date.strftime('%d %B %Y') }}{% endblock %}
<html>
<head> {% block report %}
<meta charset="utf-8"> <h1>Balance Sheet</h1>
<title>Balance Sheet as at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</title> <h2>As at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</h2>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}"> <table class="ledger onedesc">
</head> {# Assets #}
<body> <tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Assets</th></tr>
<h1>Balance Sheet</h1> {{ do_accounts(ledger.get_account(config['assets_account']), 'Assets', False, True) }}
<h2>As at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</h2> <tr><td colspan="2">&nbsp;</td></tr>
<table class="ledger onedesc"> {# Liabilities #}
{# Assets #} <tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Liabilities</th></tr>
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Assets</th></tr> {{ do_accounts(ledger.get_account(config['liabilities_account']), 'Liabilities', True, False) }}
{{ do_accounts(ledger.get_account(config['assets_account']), 'Assets', False, True) }} <tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
{# Equity #}
{# Liabilities #} <tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Equity</th></tr>
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Liabilities</th></tr>
{{ do_accounts(ledger.get_account(config['liabilities_account']), 'Liabilities', True, False) }} {% for account in ledger.get_account(config['equity_account']).children if account in accounts %}
<tr><td colspan="2">&nbsp;</td></tr> {{ print_rows(account, invert=True) }}
{% endfor %}
{# Equity #}
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Equity</th></tr> <tr class="total">
<td>Total Equity</td>
{% for account in ledger.get_account(config['equity_account']).children if account in accounts %} {% for balance_sheet in balance_sheets %}<td>{{ -balance_sheet.get_total(ledger.get_account(config['equity_account'])).exchange(report_currency, True)|a }}</td>{% endfor %}
{{ print_rows(account, invert=True) }} </tr>
{% endfor %} </table>
{% endblock %}
<tr class="total">
<td>Total Equity</td>
{% for balance_sheet in balance_sheets %}<td>{{ -balance_sheet.get_total(ledger.get_account(config['equity_account'])).exchange(report_currency, True)|a }}</td>{% endfor %}
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,30 @@
{#
ledger-pyreport
Copyright © 2020 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
</head>
<body>
{% block body %}{% endblock %}
</body>
</html>

View File

@ -0,0 +1,26 @@
{#
ledger-pyreport
Copyright © 2020 Lee Yingtong Li (RunasSudo)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
{% extends 'base.html' %}
{% block body %}
<a class="homelink" href="/">Home</a>
{% block report %}
{% endblock %}
{% endblock %}

View File

@ -16,60 +16,57 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
#} #}
<!DOCTYPE html> {% extends 'base.html' %}
<html>
<head> {% block title %}ledger-pyreport{% endblock %}
<meta charset="utf-8">
<title>ledger-pyreport</title> {% block body %}
</head> <ul>
<body> <li><form action="{{ url_for('trial') }}">
<ul> <button type="submit">Trial balance</button>
<li><form action="{{ url_for('trial') }}"> <label>Date: <input name="date" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<button type="submit">Trial balance</button> <label>Period start: <input name="pstart" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>Date: <input name="date" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label> <label>Compare <input name="compare" value="0" style="width: 2em;" oninput="txtc(this)"> periods</label>
<label>Period start: <input name="pstart" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label> {#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
<label>Compare <input name="compare" value="0" style="width: 2em;" oninput="txtc(this)"> periods</label> </form></li>
{#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
</form></li>
<li><form action="{{ url_for('balance') }}">
<button type="submit">Balance sheet</button>
<label>Date: <input name="date" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>Period start: <input name="pstart" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>Compare <input name="compare" value="0" style="width: 2em;" oninput="txtc(this)"> periods</label>
{#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
</form></li>
<li><form action="{{ url_for('pandl') }}">
<button type="submit">Income statement</button>
<label>Begin date: <input name="date_beg" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>End date: <input name="date_end" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>Compare <input name="compare" value="0" style="width: 2em;" oninput="txtc(this)"> periods</label>
{#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
</form></li>
<li><form action="{{ url_for('transactions') }}">
<button type="submit">General ledger</button>
<label>Date: <input name="date" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>Period start: <input name="pstart" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
{#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
</form></li>
</ul>
<script> <li><form action="{{ url_for('balance') }}">
// Called whenever a text input changes - update others to match <button type="submit">Balance sheet</button>
function txtc(el) { <label>Date: <input name="date" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
for (var e2 of document.querySelectorAll('input[name="' + el.name + '"]')) { <label>Period start: <input name="pstart" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
e2.value = el.value; <label>Compare <input name="compare" value="0" style="width: 2em;" oninput="txtc(this)"> periods</label>
} {#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
</form></li>
<li><form action="{{ url_for('pandl') }}">
<button type="submit">Income statement</button>
<label>Begin date: <input name="date_beg" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>End date: <input name="date_end" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>Compare <input name="compare" value="0" style="width: 2em;" oninput="txtc(this)"> periods</label>
{#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
</form></li>
<li><form action="{{ url_for('transactions') }}">
<button type="submit">General ledger</button>
<label>Date: <input name="date" value="{{ date.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
<label>Period start: <input name="pstart" value="{{ pstart.strftime('%Y-%m-%d') }}" style="width: 6em;" oninput="txtc(this)"></label>
{#<label><input name="cash" type="checkbox" oninput="chbc(this)"> Cash basis</label>#}
</form></li>
</ul>
<script>
// Called whenever a text input changes - update others to match
function txtc(el) {
for (var e2 of document.querySelectorAll('input[name="' + el.name + '"]')) {
e2.value = el.value;
} }
}
// Ditto for checkboxes
function chbc(el) { // Ditto for checkboxes
for (var e2 of document.querySelectorAll('input[name="' + el.name + '"]')) { function chbc(el) {
e2.checked = el.checked; for (var e2 of document.querySelectorAll('input[name="' + el.name + '"]')) {
} e2.checked = el.checked;
} }
</script> }
</body> </script>
</html> {% endblock %}

View File

@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
#} #}
{% extends 'base_report.html' %}
{% macro print_rows(account, invert=False, level=0) %} {% macro print_rows(account, invert=False, level=0) %}
<tr> <tr>
<td style="padding-left: calc(2px + {{ level }}em);"> <td style="padding-left: calc(2px + {{ level }}em);">
@ -57,29 +59,22 @@
</tr> </tr>
{% endmacro %} {% endmacro %}
<!DOCTYPE html> {% block title %}Income Statement for the {{ period }}{% endblock %}
<html>
<head> {% block report %}
<meta charset="utf-8"> <h1>Income Statement</h1>
<title>Income Statement for the {{ period }}</title> <h2>For the {{ period }}</h2>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}"> <table class="ledger onedesc">
</head> {{ do_accounts(ledger.get_account(config['income_account']), 'Income', True, True) }}
<body> <tr><td colspan="2">&nbsp;</td></tr>
<h1>Income Statement</h1>
<h2>For the {{ period }}</h2>
<table class="ledger onedesc"> {{ do_accounts(ledger.get_account(config['expenses_account']), 'Expenses', False, False) }}
{{ do_accounts(ledger.get_account(config['income_account']), 'Income', True, True) }} <tr><td colspan="2">&nbsp;</td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr class="total">
{{ do_accounts(ledger.get_account(config['expenses_account']), 'Expenses', False, False) }} <td>Net Surplus (Loss)</td>
<tr><td colspan="2">&nbsp;</td></tr> {% for pandl in pandls %}<td>{{ -(pandl.get_total(ledger.get_account(config['income_account'])) + pandl.get_total(ledger.get_account(config['expenses_account']))).exchange(report_currency, True)|a }}</td>{% endfor %}
</tr>
<tr class="total"> </table>
<td>Net Surplus (Loss)</td> {% endblock %}
{% for pandl in pandls %}<td>{{ -(pandl.get_total(ledger.get_account(config['income_account'])) + pandl.get_total(ledger.get_account(config['expenses_account']))).exchange(report_currency, True)|a }}</td>{% endfor %}
</tr>
</table>
</body>
</html>

View File

@ -16,105 +16,102 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
#} #}
<!DOCTYPE html> {% extends 'base_report.html' %}
<html>
<head> {% block title %}{% if account %}Account Transactions{% else %}General Ledger{% endif %} as at {{ date.strftime('%d %B %Y') }}{% endblock %}
<meta charset="utf-8">
<title>{% if account %}Account Transactions{% else %}General Ledger{% endif %} as at {{ date.strftime('%d %B %Y') }}</title> {% block report %}
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous"> {% if account %}
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}"> <h1>Account Transactions</h1>
</head> <h2 style="margin-bottom: 0;">For {{ account.name }}</h2>
<body> {% else %}
{% if account %} <h1>General Ledger</h1>
<h1>Account Transactions</h1> {% endif %}
<h2 style="margin-bottom: 0;">For {{ account.name }}</h2> <h2>For the {{ period }}</h2>
{% else %}
<h1>General Ledger</h1> <table class="ledger">
{% endif %} <tr>
<h2>As at {{ date.strftime('%d %B %Y') }}</h2> <th style="width: 5em;">Date</th>
<th>Description</th>
<th style="max-width: 8em;">Account</th>
<th class="h1" style="text-align: right; width: 5em;">Dr</th>
<th class="h1" style="text-align: right; width: 5em;">Cr</th>
{% if account %}<th class="h1" style="text-align: right; width: 6em;">Balance</th>{% endif %}
</tr>
<table class="ledger"> {% set ns = namespace(balance=None) %}
<tr> {% if account %}
<th style="width: 5em;">Date</th> <tr class="total">
<th>Description</th> <td>{{ pstart.strftime('%Y-%m-%d') }}</td>
<th style="max-width: 8em;">Account</th> <td><a href="/transactions?{{ {'date': (pstart - timedelta(days=1)).strftime('%Y-%m-%d'), 'pstart': pstart.replace(year=pstart.year-1).strftime('%Y-%m-%d'), 'account': account.name}|urlencode }}">Opening Balance</a></td>
<th class="h1" style="text-align: right; width: 5em;">Dr</th> <td></td>
<th class="h1" style="text-align: right; width: 5em;">Cr</th> <td style="text-align: right;"></td>
{% if account %}<th class="h1" style="text-align: right; width: 6em;">Balance</th>{% endif %} <td style="text-align: right;"></td>
</tr> <td style="text-align: right;">
<a href="/transactions?{{ {'date': (pstart - timedelta(days=1)).strftime('%Y-%m-%d'), 'pstart': pstart.replace(year=pstart.year-1).strftime('%Y-%m-%d'), 'account': account.name}|urlencode }}">
{% set ns = namespace(balance=None) %}
{% if account %}
<tr class="total">
<td>{{ pstart.strftime('%Y-%m-%d') }}</td>
<td>Opening Balance</td>
<td></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">
{% if opening_balance >= 0 %} {% if opening_balance >= 0 %}
{{ opening_balance|b }} Dr {{ opening_balance|b }} Dr
{% else %} {% else %}
{{ -opening_balance|b }} Cr {{ -opening_balance|b }} Cr
{% endif %} {% endif %}
</td> </a>
</tr> </td>
{% set ns.balance = opening_balance %} </tr>
{% endif %} {% set ns.balance = opening_balance %}
{% endif %}
{% for transaction in transactions %}
{% for posting in transaction.postings if (posting.amount.amount >= 0.05 or posting.amount.amount < -0.05) and posting.account != account %} {% for transaction in transactions %}
{% set amount = posting.exchange(report_currency, transaction.date) %} {% for posting in transaction.postings if (posting.amount.amount >= 0.05 or posting.amount.amount < -0.05) and posting.account != account %}
<tr> {% set amount = posting.exchange(report_currency, transaction.date) %}
<td>{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %}</td> <tr>
<td>{% if loop.first %}{{ transaction.description }}{% endif %}</td> <td>{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %}</td>
<td><a href="/transactions?{{ {'date': date.strftime('%Y-%m-%d'), 'pstart': pstart.strftime('%Y-%m-%d'), 'account': posting.account.name}|urlencode }}">{{ (posting.account.name|e).__str__().replace(':', ':<wbr>')|safe }}</a></td> <td>{% if loop.first %}{{ transaction.description }}{% endif %}</td>
{% if account %} <td><a href="/transactions?{{ {'date': date.strftime('%Y-%m-%d'), 'pstart': pstart.strftime('%Y-%m-%d'), 'account': posting.account.name}|urlencode }}">{{ (posting.account.name|e).__str__().replace(':', ':<wbr>')|safe }}</a></td>
{# Reverse Dr/Cr so it's from the "perspective" of this account #} {% if account %}
{% set ns.balance = ns.balance - amount %} {# Reverse Dr/Cr so it's from the "perspective" of this account #}
<td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td> {% 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 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
<td style="text-align: right;"> <td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
{% if loop.last %} <td style="text-align: right;">
{% if ns.balance >= 0 %} {% if loop.last %}
{{ ns.balance|b }} Dr {% if ns.balance >= 0 %}
{% else %} {{ ns.balance|b }} Dr
{{ -ns.balance|b }} Cr {% else %}
{% endif %} {{ -ns.balance|b }} Cr
{% endif %} {% endif %}
</td> {% endif %}
{% else %} </td>
<td style="text-align: right;">{% if amount > 0 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td> {% 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 %}<span title="{{ posting.amount.tostr(False) }}">{{ amount|b }}</span>{% endif %}</td>
{% endif %} <td style="text-align: right;">{% if amount < 0 %}<span title="{{ (-posting.amount).tostr(False) }}">{{ -amount|b }}</span>{% endif %}</td>
</tr> {% endif %}
{% endfor %} </tr>
{% endfor %} {% endfor %}
{% endfor %}
{% if account %}
<tr class="total"> {% if account %}
<td>{{ date.strftime('%Y-%m-%d') }}</td> <tr class="total">
<td>Closing Balance</td> <td>{{ date.strftime('%Y-%m-%d') }}</td>
<td></td> <td>Closing Balance</td>
<td style="text-align: right;"></td> <td></td>
<td style="text-align: right;"></td> <td style="text-align: right;"></td>
<td style="text-align: right;"> <td style="text-align: right;"></td>
{% if closing_balance >= 0 %} <td style="text-align: right;">
{{ closing_balance|b }} Dr {% if closing_balance >= 0 %}
{% else %} {{ closing_balance|b }} Dr
{{ -closing_balance|b }} Cr {% else %}
{% endif %} {{ -closing_balance|b }} Cr
</td> {% endif %}
</tr> </td>
{% else %} </tr>
<tr class="total"> {% else %}
<td>{{ date.strftime('%Y-%m-%d') }}</td> <tr class="total">
<td>Total</td> <td>{{ date.strftime('%Y-%m-%d') }}</td>
<td></td> <td>Total</td>
<td style="text-align: right;">{{ total_dr|b }}</td> <td></td>
<td style="text-align: right;">{{ -total_cr|b }}</td> <td style="text-align: right;">{{ total_dr|b }}</td>
</tr> <td style="text-align: right;">{{ -total_cr|b }}</td>
{% endif %} </tr>
</table> {% endif %}
</body> </table>
</html> {% endblock %}

View File

@ -16,41 +16,36 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
#} #}
<!DOCTYPE html> {% extends 'base_report.html' %}
<html>
<head> {% block title %}Trial Balance as at {{ trial_balance.date.strftime('%d %B %Y') }}{% endblock %}
<meta charset="utf-8">
<title>Trial Balance as at {{ trial_balance.date.strftime('%d %B %Y') }}</title> {% block report %}
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous"> <h1>Trial Balance</h1>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}"> <h2>As at {{ trial_balance.date.strftime('%d %B %Y') }}</h2>
</head>
<body> <table class="ledger onedesc">
<h1>Trial Balance</h1> <tr>
<h2>As at {{ trial_balance.date.strftime('%d %B %Y') }}</h2> <th></th>
<th class="h1">Dr</th>
<table class="ledger onedesc"> <th class="h1">Cr</th>
<tr> </tr>
<th></th> {% for account in accounts %}
<th class="h1">Dr</th> {# Display in "cost basis" as we have already accounted for unrealised gains #}
<th class="h1">Cr</th> {% set balance = trial_balance.get_balance(account).exchange(report_currency, True) %}
</tr> {% set trn_url = "/transactions?" + {'date': trial_balance.date.strftime('%Y-%m-%d'), 'pstart': trial_balance.pstart.strftime('%Y-%m-%d'), 'account': account.name}|urlencode %}
{% for account in accounts %} {% if balance != 0 %}
{# Display in "cost basis" as we have already accounted for unrealised gains #} <tr>
{% set balance = trial_balance.get_balance(account).exchange(report_currency, True) %} <td><a href="{{ trn_url }}">{{ account.name }}</a></td>
{% set trn_url = "/transactions?" + {'date': trial_balance.date.strftime('%Y-%m-%d'), 'pstart': trial_balance.pstart.strftime('%Y-%m-%d'), 'account': account.name}|urlencode %} <td>{% if balance > 0 %}<a href="{{ trn_url }}">{{ balance|b }}</a>{% endif %}</td>
{% if balance != 0 %} <td>{% if balance < 0 %}<a href="{{ trn_url }}">{{ -balance|b }}</a>{% endif %}</td>
<tr> </tr>
<td><a href="{{ trn_url }}">{{ account.name }}</a></td> {% endif %}
<td>{% if balance > 0 %}<a href="{{ trn_url }}">{{ balance|b }}</a>{% endif %}</td> {% endfor %}
<td>{% if balance < 0 %}<a href="{{ trn_url }}">{{ -balance|b }}</a>{% endif %}</td> <tr class="total">
</tr> <td></td>
{% endif %} <td>{{ total_dr|b }}</td>
{% endfor %} <td>{{ total_cr|b }}</td>
<tr class="total"> </tr>
<td></td> </table>
<td>{{ total_dr|b }}</td> {% endblock %}
<td>{{ total_cr|b }}</td>
</tr>
</table>
</body>
</html>

View File

@ -16,32 +16,27 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
#} #}
<!DOCTYPE html> {% extends 'base_report.html' %}
<html>
<head> {% block title %}Trial Balance as at {{ trial_balances[0].date.strftime('%d %B %Y') }}{% endblock %}
<meta charset="utf-8">
<title>Trial Balance as at {{ trial_balances[0].date.strftime('%d %B %Y') }}</title> {% block report %}
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" integrity="sha256-l85OmPOjvil/SOvVt3HnSSjzF1TUMyT9eV0c2BzEGzU=" crossorigin="anonymous"> <h1>Trial Balance</h1>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}"> <h2>As at {{ trial_balances[0].date.strftime('%d %B %Y') }}</h2>
</head>
<body> <table class="ledger onedesc">
<h1>Trial Balance</h1> <tr>
<h2>As at {{ trial_balances[0].date.strftime('%d %B %Y') }}</h2> <th></th>
{% for trial_balance in trial_balances %}<th class="h2">{{ trial_balance.date.strftime('%Y') }}&nbsp;</th>{% endfor %}
<table class="ledger onedesc"> </tr>
{% for account in accounts %}
<tr> <tr>
<th></th> <td>{{ account.name }}</td>
{% for trial_balance in trial_balances %}<th class="h2">{{ trial_balance.date.strftime('%Y') }}&nbsp;</th>{% endfor %} {% for trial_balance in trial_balances %}
{% set balance = trial_balance.get_balance(account).exchange(report_currency, True) %}
<td>{% if balance != 0 %}{{ balance|a }}{% endif %}</td>
{% endfor %}
</tr> </tr>
{% for account in accounts %} {% endfor %}
<tr> </table>
<td>{{ account.name }}</td> {% endblock %}
{% for trial_balance in trial_balances %}
{% set balance = trial_balance.get_balance(account).exchange(report_currency, True) %}
<td>{% if balance != 0 %}{{ balance|a }}{% endif %}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</body>
</html>

View File

@ -72,8 +72,21 @@ table.ledger a:hover {
text-decoration: underline; text-decoration: underline;
} }
a.homelink {
color: #888;
position: absolute;
top: 0;
left: 0;
}
@media screen { @media screen {
body { body {
padding: 2em; padding: 2em;
} }
} }
@media print {
a.homelink {
display: none;
}
}