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)
|
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):
|
||||||
|
@ -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,15 +82,9 @@
|
|||||||
</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">
|
|
||||||
<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>
|
<h1>Balance Sheet</h1>
|
||||||
<h2>As at {{ balance_sheets[0].date.strftime('%d %B %Y') }}</h2>
|
<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 %}
|
{% 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>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
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/>.
|
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>
|
|
||||||
<body>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li><form action="{{ url_for('trial') }}">
|
<li><form action="{{ url_for('trial') }}">
|
||||||
<button type="submit">Trial balance</button>
|
<button type="submit">Trial balance</button>
|
||||||
@ -71,5 +69,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
@ -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,15 +59,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
{% block title %}Income Statement for the {{ period }}{% endblock %}
|
||||||
<html>
|
|
||||||
<head>
|
{% block report %}
|
||||||
<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>
|
<h1>Income Statement</h1>
|
||||||
<h2>For the {{ period }}</h2>
|
<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 %}
|
{% 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>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
@ -16,22 +16,18 @@
|
|||||||
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">
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
{% if account %}
|
{% if account %}
|
||||||
<h1>Account Transactions</h1>
|
<h1>Account Transactions</h1>
|
||||||
<h2 style="margin-bottom: 0;">For {{ account.name }}</h2>
|
<h2 style="margin-bottom: 0;">For {{ account.name }}</h2>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1>General Ledger</h1>
|
<h1>General Ledger</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h2>As at {{ date.strftime('%d %B %Y') }}</h2>
|
<h2>For the {{ period }}</h2>
|
||||||
|
|
||||||
<table class="ledger">
|
<table class="ledger">
|
||||||
<tr>
|
<tr>
|
||||||
@ -47,16 +43,18 @@
|
|||||||
{% if account %}
|
{% if account %}
|
||||||
<tr class="total">
|
<tr class="total">
|
||||||
<td>{{ pstart.strftime('%Y-%m-%d') }}</td>
|
<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></td>
|
||||||
<td style="text-align: right;"></td>
|
<td style="text-align: right;"></td>
|
||||||
<td style="text-align: right;"></td>
|
<td style="text-align: right;"></td>
|
||||||
<td style="text-align: right;">
|
<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 %}
|
{% if opening_balance >= 0 %}
|
||||||
{{ opening_balance|b }} Dr
|
{{ opening_balance|b }} Dr
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ -opening_balance|b }} Cr
|
{{ -opening_balance|b }} Cr
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% set ns.balance = opening_balance %}
|
{% set ns.balance = opening_balance %}
|
||||||
@ -116,5 +114,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
@ -16,15 +16,11 @@
|
|||||||
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">
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Trial Balance</h1>
|
<h1>Trial Balance</h1>
|
||||||
<h2>As at {{ trial_balance.date.strftime('%d %B %Y') }}</h2>
|
<h2>As at {{ trial_balance.date.strftime('%d %B %Y') }}</h2>
|
||||||
|
|
||||||
@ -52,5 +48,4 @@
|
|||||||
<td>{{ total_cr|b }}</td>
|
<td>{{ total_cr|b }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
@ -16,15 +16,11 @@
|
|||||||
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">
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Trial Balance</h1>
|
<h1>Trial Balance</h1>
|
||||||
<h2>As at {{ trial_balances[0].date.strftime('%d %B %Y') }}</h2>
|
<h2>As at {{ trial_balances[0].date.strftime('%d %B %Y') }}</h2>
|
||||||
|
|
||||||
@ -43,5 +39,4 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</body>
|
{% endblock %}
|
||||||
</html>
|
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user