DrCr/drcr/templates/transactions_commodity_deta...

78 lines
2.6 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.html' %}
{% block title %}Account transactions{% endblock %}
{% block content %}
<h1 class="h2 my-4">Account transactions</h1>
<div class="mb-2">
<a href="{{ url_for('account_transactions', account=account) }}" class="btn btn-outline-secondary">Hide commodity detail</a>
</div>
<table class="table table-sm table-borderless">
<thead>
<tr>
<th>Date</th>
<th>Description</th>
<th></th>
<th class="text-end">Amount</th>
<th class="text-end">Balance</th>
<th></th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<tr style="border-width:1px 0 0 0">
<td>{{ transaction.dt.strftime('%Y-%m-%d') }}</td>
<td>
{{ transaction.description }}
{% if transaction.id %}<a href="{{ url_for('journal_edit_transaction', id=transaction.id) }}"><i class="bi bi-pencil text-muted"></i></a>{% endif %}
</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
{% for amount in running_totals[transaction].amounts %}
{# FIXME: Assumes at most one posting per commodity #}
{% for posting in transaction.postings if posting.commodity == amount.commodity and posting.account == account %}
<tr>
<td></td>
<td></td>
<td>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</td>
<td class="text-end">{{ (posting.amount()|abs).format('force') }}</td>
<td class="text-end">{{ (amount|abs).format('force') }}</td>
<td>{{ 'Dr' if amount.quantity >= 0 else 'Cr' }}</td>
</tr>
{% else %}
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="text-end">{{ (amount|abs).format('force') }}</td>
<td>{{ 'Dr' if amount.quantity >= 0 else 'Cr' }}</td>
</tr>
{% endfor %}
{% endfor %}
{% endfor %}
</tbody>
</table>
{% endblock %}