DrCr/drcr/templates/report.html

66 lines
2.1 KiB
HTML

{# DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 2022–2023 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 title %}{{ report.title }}{% endblock %}
{% macro render_section(section) %}
<tr>
<th>{{ section.title }}</th>
<th></th>
</tr>
{% for entry in section.entries %}
{{ render_entry(entry) }}
{% endfor %}
{% endmacro %}
{% macro render_entry(entry) %}
{% if entry.__class__.__name__ == 'Section' %}
{{ render_section(entry) }}
{% elif entry.__class__.__name__ == 'Subtotal' %}
<tr{% if entry.bordered %} style="border-width:1px 0"{% endif %}>
<th>{{ entry.text }}</th>
<th class="text-end">{{ entry.amount.format_accounting() }}</th>
</tr>
{% elif entry.__class__.__name__ == 'Spacer' %}
<tr><td colspan="2">&nbsp;</td></tr>
{% else %}
<tr{% if entry.bordered %} style="border-width:1px 0"{% endif %}>
<{{ 'th' if entry.heading else 'td' }}>{{ entry.text }}</{{ 'th' if entry.heading else 'td' }}>
<{{ 'th' if entry.heading else 'td' }} class="text-end">{{ entry.amount.format_accounting() }}</{{ 'th' if entry.heading else 'td' }}>
</tr>
{% endif %}
{% endmacro %}
{% block content %}
<h1 class="h2 mt-4">{{ report.title }}</h1>
<table class="table table-borderless table-sm">
<thead>
<tr style="border-bottom-width:1px">
<th></th>
<th class="text-end">$&nbsp;</th>
</tr>
</thead>
<tbody>
{% for entry in report.entries %}
{{ render_entry(entry) }}
{% endfor %}
</tbody>
</table>
{% endblock %}