Add home link and tweak transactions report heading
This commit is contained in:
parent
1c217fd8d4
commit
f5f59a7098
@ -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):
|
||||
|
@ -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,15 +82,9 @@
|
||||
</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>
|
||||
{% block title %}Balance Sheet as at {{ balance_sheets[0].date.strftime('%d %B %Y') }}{% endblock %}
|
||||
|
||||
{% block report %}
|
||||
<h1>Balance Sheet</h1>
|
||||
<h2>As at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</h2>
|
||||
|
||||
@ -115,5 +111,4 @@
|
||||
{% 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>
|
||||
{% endblock %}
|
||||
|
30
ledger_pyreport/jinja2/base.html
Normal file
30
ledger_pyreport/jinja2/base.html
Normal 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>
|
26
ledger_pyreport/jinja2/base_report.html
Normal file
26
ledger_pyreport/jinja2/base_report.html
Normal 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 %}
|
@ -16,13 +16,11 @@
|
||||
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>
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}ledger-pyreport{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<ul>
|
||||
<li><form action="{{ url_for('trial') }}">
|
||||
<button type="submit">Trial balance</button>
|
||||
@ -71,5 +69,4 @@
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
@ -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,15 +59,9 @@
|
||||
</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>
|
||||
{% block title %}Income Statement for the {{ period }}{% endblock %}
|
||||
|
||||
{% block report %}
|
||||
<h1>Income Statement</h1>
|
||||
<h2>For the {{ period }}</h2>
|
||||
|
||||
@ -81,5 +77,4 @@
|
||||
{% 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>
|
||||
{% endblock %}
|
||||
|
@ -16,22 +16,18 @@
|
||||
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>As at {{ date.strftime('%d %B %Y') }}</h2>
|
||||
<h2>For the {{ period }}</h2>
|
||||
|
||||
<table class="ledger">
|
||||
<tr>
|
||||
@ -47,16 +43,18 @@
|
||||
{% if account %}
|
||||
<tr class="total">
|
||||
<td>{{ pstart.strftime('%Y-%m-%d') }}</td>
|
||||
<td>Opening Balance</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 %}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% set ns.balance = opening_balance %}
|
||||
@ -116,5 +114,4 @@
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
@ -16,15 +16,11 @@
|
||||
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>
|
||||
{% extends 'base_report.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>
|
||||
|
||||
@ -52,5 +48,4 @@
|
||||
<td>{{ total_cr|b }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
@ -16,15 +16,11 @@
|
||||
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>
|
||||
{% extends 'base_report.html' %}
|
||||
|
||||
{% 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>
|
||||
|
||||
@ -43,5 +39,4 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user