80 lines
2.9 KiB
HTML
80 lines
2.9 KiB
HTML
{#
|
|
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/>.
|
|
#}
|
|
|
|
{% macro print_rows(account, invert=False, level=0) %}
|
|
<tr>
|
|
<td style="padding-left: calc(2px + {{ level }}em);">{{ account.bits[-1] }}</td>
|
|
{% for pandl in pandls %}
|
|
{% set amount = pandl.get_balance(account.name) * (-1 if invert else 1) %}
|
|
<td>{% if amount != 0 %}{{ amount|a }}{% endif %}</td>
|
|
{% endfor %}
|
|
</tr>
|
|
|
|
{% for child in account.children if child in accounts %}
|
|
{{ print_rows(child, invert, level + 1) }}
|
|
{% endfor %}
|
|
{% endmacro %}
|
|
|
|
{% macro do_accounts(root, label, invert, year_headers) %}
|
|
<tr>
|
|
{% if year_headers %}
|
|
{# CSS hackery to centre-align the heading #}
|
|
<th class="h1" style="padding-left: calc(2px + {{ dates_end|length * 6 }}em);">{{ label }}</th>
|
|
{% for date in dates_end %}<th class="h2">{{ date.strftime('%Y') }} </th>{% endfor %}
|
|
{% else %}
|
|
<th class="h1" colspan="{{ dates_end|length + 1 }}">{{ label }}</th>
|
|
{% endif %}
|
|
</tr>
|
|
|
|
{% for account in pandls[0].get_account(root).children if account in accounts %}
|
|
{{ print_rows(account, invert=invert) }}
|
|
{% endfor %}
|
|
|
|
<tr class="total">
|
|
<td>Total {{ label }}</td>
|
|
{% for pandl in pandls %}<td>{{ (pandl.get_total(root) * (-1 if invert else 1))|a }}</td>{% endfor %}
|
|
</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>
|
|
|
|
<table class="ledger">
|
|
{{ do_accounts(config['income_account'], 'Income', True, True) }}
|
|
<tr><td colspan="2"> </td></tr>
|
|
|
|
{{ do_accounts(config['expenses_account'], 'Expenses', False, False) }}
|
|
<tr><td colspan="2"> </td></tr>
|
|
|
|
<tr class="total">
|
|
<td>Net Surplus (Loss)</td>
|
|
{% for pandl in pandls %}<td>{{ -(pandl.get_total(config['income_account']) + pandl.get_total(config['expenses_account']))|a }}</td>{% endfor %}
|
|
</tr>
|
|
</table>
|
|
</body>
|
|
</html>
|