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)
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')
def pandl():
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):
accounts.remove(account)
if date_end == (date_beg.replace(year=date_beg.year + 1) - timedelta(days=1)):
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)
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)
@app.route('/transactions')
def transactions():
@ -154,7 +155,7 @@ def transactions():
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)
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')
def filter_amount(amt):

View File

@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
{% extends 'base_report.html' %}
{% macro print_rows(account, invert=False, level=0) %}
<tr>
<td style="padding-left: calc(2px + {{ level }}em);">
@ -80,40 +82,33 @@
</tr>
{% endmacro %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Balance Sheet as at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</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>
<h1>Balance Sheet</h1>
<h2>As at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</h2>
{% block title %}Balance Sheet as at {{ balance_sheets[0].date.strftime('%d %B %Y') }}{% endblock %}
<table class="ledger onedesc">
{# Assets #}
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Assets</th></tr>
{{ do_accounts(ledger.get_account(config['assets_account']), 'Assets', False, True) }}
<tr><td colspan="2">&nbsp;</td></tr>
{% block report %}
<h1>Balance Sheet</h1>
<h2>As at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</h2>
{# Liabilities #}
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Liabilities</th></tr>
{{ do_accounts(ledger.get_account(config['liabilities_account']), 'Liabilities', True, False) }}
<tr><td colspan="2">&nbsp;</td></tr>
<table class="ledger onedesc">
{# Assets #}
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Assets</th></tr>
{{ do_accounts(ledger.get_account(config['assets_account']), 'Assets', False, True) }}
<tr><td colspan="2">&nbsp;</td></tr>
{# Equity #}
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Equity</th></tr>
{# Liabilities #}
<tr><th class="h1" colspan="{{ balance_sheets|length + 1 }}">Liabilities</th></tr>
{{ do_accounts(ledger.get_account(config['liabilities_account']), 'Liabilities', True, False) }}
<tr><td colspan="2">&nbsp;</td></tr>
{% for account in ledger.get_account(config['equity_account']).children if account in accounts %}
{{ 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 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>
{% for account in ledger.get_account(config['equity_account']).children if account in accounts %}
{{ print_rows(account, invert=True) }}
{% endfor %}
<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>
{% endblock %}

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/>.
#}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ledger-pyreport</title>
</head>
<body>
<ul>
<li><form action="{{ url_for('trial') }}">
<button type="submit">Trial balance</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>
{% extends 'base.html' %}
<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>
{% block title %}ledger-pyreport{% endblock %}
<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>
{% block body %}
<ul>
<li><form action="{{ url_for('trial') }}">
<button type="submit">Trial balance</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('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>
<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>
<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;
}
<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) {
for (var e2 of document.querySelectorAll('input[name="' + el.name + '"]')) {
e2.checked = el.checked;
}
// Ditto for checkboxes
function chbc(el) {
for (var e2 of document.querySelectorAll('input[name="' + el.name + '"]')) {
e2.checked = el.checked;
}
</script>
</body>
</html>
}
</script>
{% endblock %}

View File

@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
{% extends 'base_report.html' %}
{% macro print_rows(account, invert=False, level=0) %}
<tr>
<td style="padding-left: calc(2px + {{ level }}em);">
@ -57,29 +59,22 @@
</tr>
{% endmacro %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Income Statement for the {{ period }}</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>
<h1>Income Statement</h1>
<h2>For the {{ period }}</h2>
{% block title %}Income Statement for the {{ period }}{% endblock %}
<table class="ledger onedesc">
{{ do_accounts(ledger.get_account(config['income_account']), 'Income', True, True) }}
<tr><td colspan="2">&nbsp;</td></tr>
{% block report %}
<h1>Income Statement</h1>
<h2>For the {{ period }}</h2>
{{ do_accounts(ledger.get_account(config['expenses_account']), 'Expenses', False, False) }}
<tr><td colspan="2">&nbsp;</td></tr>
<table class="ledger onedesc">
{{ do_accounts(ledger.get_account(config['income_account']), 'Income', True, True) }}
<tr><td colspan="2">&nbsp;</td></tr>
<tr class="total">
<td>Net Surplus (Loss)</td>
{% 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>
{{ do_accounts(ledger.get_account(config['expenses_account']), 'Expenses', False, False) }}
<tr><td colspan="2">&nbsp;</td></tr>
<tr class="total">
<td>Net Surplus (Loss)</td>
{% 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>
{% endblock %}

View File

@ -16,105 +16,102 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% if account %}Account Transactions{% else %}General Ledger{% endif %} as at {{ date.strftime('%d %B %Y') }}</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>
{% extends 'base_report.html' %}
{% block title %}{% if account %}Account Transactions{% else %}General Ledger{% endif %} as at {{ date.strftime('%d %B %Y') }}{% endblock %}
{% block report %}
{% if account %}
<h1>Account Transactions</h1>
<h2 style="margin-bottom: 0;">For {{ account.name }}</h2>
{% else %}
<h1>General Ledger</h1>
{% endif %}
<h2>For the {{ period }}</h2>
<table class="ledger">
<tr>
<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>
{% set ns = namespace(balance=None) %}
{% if account %}
<h1>Account Transactions</h1>
<h2 style="margin-bottom: 0;">For {{ account.name }}</h2>
{% else %}
<h1>General Ledger</h1>
{% endif %}
<h2>As at {{ date.strftime('%d %B %Y') }}</h2>
<table class="ledger">
<tr>
<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>
{% 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;">
<tr class="total">
<td>{{ pstart.strftime('%Y-%m-%d') }}</td>
<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>
<td></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<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 }}">
{% if opening_balance >= 0 %}
{{ opening_balance|b }} Dr
{% else %}
{{ -opening_balance|b }} Cr
{% endif %}
</td>
</tr>
{% set ns.balance = opening_balance %}
{% endif %}
</a>
</td>
</tr>
{% 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 %}
{% set amount = posting.exchange(report_currency, transaction.date) %}
<tr>
<td>{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %}</td>
<td>{% if loop.first %}{{ transaction.description }}{% 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>
{% if account %}
{# Reverse Dr/Cr so it's from the "perspective" of this account #}
{% 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;">
{% if loop.last %}
{% if ns.balance >= 0 %}
{{ ns.balance|b }} Dr
{% else %}
{{ -ns.balance|b }} Cr
{% 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 %}
{% set amount = posting.exchange(report_currency, transaction.date) %}
<tr>
<td>{% if loop.first %}{{ transaction.date.strftime('%Y-%m-%d') }}{% endif %}</td>
<td>{% if loop.first %}{{ transaction.description }}{% 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>
{% if account %}
{# Reverse Dr/Cr so it's from the "perspective" of this account #}
{% 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;">
{% if loop.last %}
{% if ns.balance >= 0 %}
{{ ns.balance|b }} Dr
{% else %}
{{ -ns.balance|b }} Cr
{% 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 %}
</tr>
{% endfor %}
{% 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 %}
</tr>
{% endfor %}
{% endfor %}
{% if account %}
<tr class="total">
<td>{{ date.strftime('%Y-%m-%d') }}</td>
<td>Closing Balance</td>
<td></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">
{% if closing_balance >= 0 %}
{{ closing_balance|b }} Dr
{% else %}
{{ -closing_balance|b }} Cr
{% endif %}
</td>
</tr>
{% else %}
<tr class="total">
<td>{{ date.strftime('%Y-%m-%d') }}</td>
<td>Total</td>
<td></td>
<td style="text-align: right;">{{ total_dr|b }}</td>
<td style="text-align: right;">{{ -total_cr|b }}</td>
</tr>
{% endif %}
</table>
</body>
</html>
{% if account %}
<tr class="total">
<td>{{ date.strftime('%Y-%m-%d') }}</td>
<td>Closing Balance</td>
<td></td>
<td style="text-align: right;"></td>
<td style="text-align: right;"></td>
<td style="text-align: right;">
{% if closing_balance >= 0 %}
{{ closing_balance|b }} Dr
{% else %}
{{ -closing_balance|b }} Cr
{% endif %}
</td>
</tr>
{% else %}
<tr class="total">
<td>{{ date.strftime('%Y-%m-%d') }}</td>
<td>Total</td>
<td></td>
<td style="text-align: right;">{{ total_dr|b }}</td>
<td style="text-align: right;">{{ -total_cr|b }}</td>
</tr>
{% endif %}
</table>
{% endblock %}

View File

@ -16,41 +16,36 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Trial Balance as at {{ trial_balance.date.strftime('%d %B %Y') }}</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>
<h1>Trial Balance</h1>
<h2>As at {{ trial_balance.date.strftime('%d %B %Y') }}</h2>
{% extends 'base_report.html' %}
<table class="ledger onedesc">
<tr>
<th></th>
<th class="h1">Dr</th>
<th class="h1">Cr</th>
</tr>
{% for account in accounts %}
{# Display in "cost basis" as we have already accounted for unrealised gains #}
{% set balance = trial_balance.get_balance(account).exchange(report_currency, True) %}
{% set trn_url = "/transactions?" + {'date': trial_balance.date.strftime('%Y-%m-%d'), 'pstart': trial_balance.pstart.strftime('%Y-%m-%d'), 'account': account.name}|urlencode %}
{% if balance != 0 %}
<tr>
<td><a href="{{ trn_url }}">{{ account.name }}</a></td>
<td>{% if balance > 0 %}<a href="{{ trn_url }}">{{ balance|b }}</a>{% endif %}</td>
<td>{% if balance < 0 %}<a href="{{ trn_url }}">{{ -balance|b }}</a>{% endif %}</td>
</tr>
{% endif %}
{% endfor %}
<tr class="total">
<td></td>
<td>{{ total_dr|b }}</td>
<td>{{ total_cr|b }}</td>
</tr>
</table>
</body>
</html>
{% block title %}Trial Balance as at {{ trial_balance.date.strftime('%d %B %Y') }}{% endblock %}
{% block report %}
<h1>Trial Balance</h1>
<h2>As at {{ trial_balance.date.strftime('%d %B %Y') }}</h2>
<table class="ledger onedesc">
<tr>
<th></th>
<th class="h1">Dr</th>
<th class="h1">Cr</th>
</tr>
{% for account in accounts %}
{# Display in "cost basis" as we have already accounted for unrealised gains #}
{% set balance = trial_balance.get_balance(account).exchange(report_currency, True) %}
{% set trn_url = "/transactions?" + {'date': trial_balance.date.strftime('%Y-%m-%d'), 'pstart': trial_balance.pstart.strftime('%Y-%m-%d'), 'account': account.name}|urlencode %}
{% if balance != 0 %}
<tr>
<td><a href="{{ trn_url }}">{{ account.name }}</a></td>
<td>{% if balance > 0 %}<a href="{{ trn_url }}">{{ balance|b }}</a>{% endif %}</td>
<td>{% if balance < 0 %}<a href="{{ trn_url }}">{{ -balance|b }}</a>{% endif %}</td>
</tr>
{% endif %}
{% endfor %}
<tr class="total">
<td></td>
<td>{{ total_dr|b }}</td>
<td>{{ total_cr|b }}</td>
</tr>
</table>
{% endblock %}

View File

@ -16,32 +16,27 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
#}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Trial Balance as at {{ trial_balances[0].date.strftime('%d %B %Y') }}</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>
<h1>Trial Balance</h1>
<h2>As at {{ trial_balances[0].date.strftime('%d %B %Y') }}</h2>
{% extends 'base_report.html' %}
<table class="ledger onedesc">
{% block title %}Trial Balance as at {{ trial_balances[0].date.strftime('%d %B %Y') }}{% endblock %}
{% block report %}
<h1>Trial Balance</h1>
<h2>As at {{ trial_balances[0].date.strftime('%d %B %Y') }}</h2>
<table class="ledger onedesc">
<tr>
<th></th>
{% for trial_balance in trial_balances %}<th class="h2">{{ trial_balance.date.strftime('%Y') }}&nbsp;</th>{% endfor %}
</tr>
{% for account in accounts %}
<tr>
<th></th>
{% for trial_balance in trial_balances %}<th class="h2">{{ trial_balance.date.strftime('%Y') }}&nbsp;</th>{% endfor %}
<td>{{ account.name }}</td>
{% 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>
{% for account in accounts %}
<tr>
<td>{{ account.name }}</td>
{% 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>
{% endfor %}
</table>
{% endblock %}

View File

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