DrCr/drcr/templates/report.html

80 lines
2.8 KiB
HTML

{# DrCr: Web-based double-entry bookkeeping framework
Copyright (C) 2022–2024 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_tailwind.html' %}
{% block title %}{{ report.title }}{% endblock %}
{% macro render_section(section) %}
{% if section.title %}
<tr>
<th class="py-0.5 text-gray-900 font-semibold text-start">{{ section.title }}</th>
<th></th>
</tr>
{% endif %}
{% for entry in section.entries %}
{{ render_entry(entry) }}
{% endfor %}
{% endmacro %}
{% macro render_entry(entry) %}
{% if entry.visible %}
{% if entry.__class__.__name__ == 'Section' %}
{{ render_section(entry) }}
{% elif entry.__class__.__name__ == 'Subtotal' %}
<tr{% if entry.bordered %} class="border-y border-gray-200"{% endif %}>
<th class="py-0.5 text-gray-900 font-semibold text-start">{{ entry.text }}</th>
<th class="py-0.5 text-gray-900 font-semibold text-end">{{ entry.amount.format_accounting() }}</th>
</tr>
{% elif entry.__class__.__name__ == 'Spacer' %}
<tr><td colspan="2" class="py-0.5">&nbsp;</td></tr>
{% else %}
<tr{% if entry.bordered %} class="border-y border-gray-200"{% endif %}>
{% if entry.heading %}<th class="py-0.5 text-gray-900 font-semibold text-start">{% else %}<td class="py-0.5 text-gray-900 text-start">{% endif %}
{% if entry.link %}
<a href="{{ entry.link }}" class="hover:text-blue-700 hover:underline">{{ entry.text }}</a>
{% else %}
{{ entry.text }}
{% endif %}
</{{ 'th' if entry.heading else 'td' }}>
{% if entry.heading %}<th class="py-0.5 text-gray-900 font-semibold text-end">{% else %}<td class="py-0.5 text-gray-900 text-end">{% endif %}
{{ entry.amount.format_accounting() }}
</{{ 'th' if entry.heading else 'td' }}>
</tr>
{% endif %}
{% endif %}
{% endmacro %}
{% block content %}
<h1 class="text-3xl text-gray-900">
{{ report.title }}
</h1>
<table class="min-w-full">
<thead>
<tr class="border-b border-gray-300">
<th></th>
<th class="py-0.5 text-gray-900 font-semibold text-end">$&nbsp;</th>
</tr>
</thead>
<tbody>
{% for entry in report.entries %}
{{ render_entry(entry) }}
{% endfor %}
</tbody>
</table>
{% endblock %}