2022-12-24 16:43:08 +11:00
|
|
|
{# DrCr: Web-based double-entry bookkeeping framework
|
|
|
|
Copyright (C) 2022 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 %}
|
|
|
|
|
2022-12-24 16:57:53 +11:00
|
|
|
{% block content %}
|
|
|
|
<h1 class="h2 my-4">Account transactions</h1>
|
|
|
|
|
2022-12-25 17:31:31 +11:00
|
|
|
<div class="mb-2">
|
|
|
|
<a href="?account={{ account }}&commodity-detail=1" class="btn btn-outline-secondary">Show commodity detail</a>
|
|
|
|
</div>
|
|
|
|
|
2022-12-24 16:57:53 +11:00
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Date</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Related Account</th>
|
|
|
|
<th class="text-end">Dr</th>
|
|
|
|
<th class="text-end">Cr</th>
|
|
|
|
<th class="text-end">Balance</th>
|
|
|
|
<th></th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for transaction in transactions %}
|
|
|
|
{% if transaction.postings|length == 2 %}
|
|
|
|
{% for posting in transaction.postings if posting.account == account %}
|
2022-12-24 19:45:34 +11:00
|
|
|
{% set _ = running_total.__setattr__('quantity', running_total.quantity + posting.amount().as_cost().quantity) %}
|
2022-12-24 16:43:08 +11:00
|
|
|
<tr>
|
|
|
|
<td>{{ transaction.dt.strftime('%Y-%m-%d') }}</td>
|
2023-01-04 10:56:17 +11:00
|
|
|
<td>
|
|
|
|
{{ transaction.description }}
|
|
|
|
{% if transaction.id %}<a href="/journal/edit-transaction?id={{ transaction.id }}"><i class="bi bi-pencil text-muted"></i></a>{% endif %}
|
|
|
|
</td>
|
2022-12-24 16:57:53 +11:00
|
|
|
<td>{% for p in transaction.postings if p.account != account %}{{ p.account }}{% endfor %}</td>
|
2022-12-25 17:05:39 +11:00
|
|
|
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
|
|
|
|
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
|
2022-12-24 16:57:53 +11:00
|
|
|
<td class="text-end">{{ (running_total|abs).format() }}</td>
|
|
|
|
<td>{{ 'Dr' if running_total.quantity >= 0 else 'Cr' }}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
{% else %}
|
|
|
|
<tr>
|
|
|
|
<td>{{ transaction.dt.strftime('%Y-%m-%d') }}</td>
|
2023-01-04 10:56:17 +11:00
|
|
|
<td colspan="2">
|
|
|
|
{{ transaction.description }}
|
|
|
|
{% if transaction.id %}<a href="/journal/edit-transaction?id={{ transaction.id }}"><i class="bi bi-pencil text-muted"></i></a>{% endif %}
|
|
|
|
</td>
|
2022-12-24 16:57:53 +11:00
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
{% for posting in transaction.postings if posting.account == account %}
|
2022-12-24 19:45:34 +11:00
|
|
|
{% set _ = running_total.__setattr__('quantity', running_total.quantity + posting.amount().as_cost().quantity) %}
|
2022-12-24 16:57:53 +11:00
|
|
|
<tr>
|
2022-12-24 16:43:08 +11:00
|
|
|
<td></td>
|
2022-12-24 16:57:53 +11:00
|
|
|
<td class="text-end"><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i></td>
|
|
|
|
<td>{{ account }}</td>
|
2022-12-25 17:05:39 +11:00
|
|
|
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
|
|
|
|
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
|
2022-12-24 16:57:53 +11:00
|
|
|
<td class="text-end">{{ (running_total|abs).format() }}</td>
|
|
|
|
<td>{{ 'Dr' if running_total.quantity >= 0 else 'Cr' }}</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
{% for posting in transaction.postings if posting.account != account %}
|
|
|
|
<tr>
|
2022-12-24 16:43:08 +11:00
|
|
|
<td></td>
|
2022-12-24 16:57:53 +11:00
|
|
|
<td class="text-end"><i>{{ 'Dr' if posting.quantity >= 0 else 'Cr' }}</i></td>
|
|
|
|
<td>{{ posting.account }}</td>
|
2022-12-25 17:05:39 +11:00
|
|
|
<td class="text-end">{{ posting.amount().as_cost().format() if posting.quantity >= 0 else '' }}</td>
|
|
|
|
<td class="text-end">{{ (posting.amount()|abs).as_cost().format() if posting.quantity < 0 else '' }}</td>
|
2022-12-24 16:43:08 +11:00
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
2022-12-24 16:57:53 +11:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2022-12-24 16:43:08 +11:00
|
|
|
{% endblock %}
|