2022-12-24 12:31:45 +11:00
|
|
|
{# DrCr: Web-based double-entry bookkeeping framework
|
2023-01-02 18:08:30 +11:00
|
|
|
Copyright (C) 2022–2023 Lee Yingtong Li (RunasSudo)
|
2022-12-24 12:31:45 +11:00
|
|
|
|
|
|
|
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 %}Statement lines{% endblock %}
|
|
|
|
|
2022-12-24 16:57:53 +11:00
|
|
|
{% block content %}
|
|
|
|
<h1 class="h2 my-4">Statement lines</h1>
|
|
|
|
|
|
|
|
<form method="POST">
|
2023-01-04 18:23:25 +11:00
|
|
|
<div class="mb-2 d-flex">
|
2023-01-02 18:50:49 +11:00
|
|
|
{#<button type="submit" class="btn btn-outline-secondary" formaction="/statement-lines/reconcile-transfer">Reconcile selected as transfer</button>#}
|
2023-01-04 18:23:25 +11:00
|
|
|
<div class="flex-grow-1">
|
2023-01-07 19:01:05 +11:00
|
|
|
<a href="{{ url_for('statement_lines_import') }}" class="btn btn-outline-secondary">Import statement</a>
|
2023-01-04 18:23:25 +11:00
|
|
|
</div>
|
|
|
|
<nav class="flex-end">
|
|
|
|
<ul class="pagination">
|
|
|
|
{% if page.prev_num %}<li class="page-item"><a class="page-link" href="?page={{ page.prev_num }}">‹</a></li>{% endif %}
|
|
|
|
{% for pageno in page.iter_pages() %}
|
|
|
|
{% if pageno %}
|
|
|
|
<li class="page-item{% if pageno == page.page %} active{% endif %}"><a class="page-link" href="?page={{ pageno }}">{{ pageno }}</a></li>
|
|
|
|
{% else %}
|
|
|
|
<li class="page-item disabled"><a class="page-link">…</a></li>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% if page.next_num %}<li class="page-item"><a class="page-link" href="?page={{ page.next_num }}">›</a></li>{% endif %}
|
|
|
|
</ul>
|
|
|
|
</nav>
|
2023-01-02 18:50:49 +11:00
|
|
|
</div>
|
2022-12-24 12:31:45 +11:00
|
|
|
|
2022-12-24 16:57:53 +11:00
|
|
|
<table class="table">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th></th>
|
|
|
|
<th>Source account</th>
|
|
|
|
<th>Date</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Charged to</th>
|
2022-12-25 17:05:39 +11:00
|
|
|
<th class="text-end">Dr</th>
|
|
|
|
<th class="text-end">Cr</th>
|
|
|
|
<th class="text-end">Balance</th>
|
2022-12-24 16:57:53 +11:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2023-01-04 18:23:25 +11:00
|
|
|
{% for line in page.items %}
|
2022-12-24 16:57:53 +11:00
|
|
|
<tr data-line-id="{{ line.id }}">
|
|
|
|
<td><input type="checkbox" name="sel-line-id" value="{{ line.id }}"></td>
|
2023-01-27 22:20:51 +11:00
|
|
|
<td><a href="{{ url_for('statement_lines', account=line.source_account) }}">{{ line.source_account }}</a></td>
|
2022-12-24 16:57:53 +11:00
|
|
|
<td>{{ line.dt.strftime('%Y-%m-%d') }}</td>
|
|
|
|
<td>{{ line.description }}</td>
|
|
|
|
<td class="charge-account">
|
2023-01-02 18:08:30 +11:00
|
|
|
{% if not line.reconciliation %}
|
2022-12-24 16:57:53 +11:00
|
|
|
<a href="#" class="text-danger" onclick="classifyLine({{ line.id }});return false;">Unclassified</a>
|
2023-01-27 22:19:08 +11:00
|
|
|
<a href="{{ url_for('statement_line_charge_complex') }}?line-id={{ line.id }}" class="text-muted"><i class="bi bi-pencil"></i></a>
|
2022-12-24 16:57:53 +11:00
|
|
|
{% elif line.is_complex() %}
|
|
|
|
<i>(Complex)</i>
|
2023-01-07 19:01:05 +11:00
|
|
|
<a href="{{ url_for('journal_edit_transaction', id=line.reconciliation.posting.transaction.id) }}" class="text-muted"><i class="bi bi-pencil"></i></a>
|
2022-12-24 16:57:53 +11:00
|
|
|
{% else %}
|
2023-01-02 18:08:30 +11:00
|
|
|
{% for posting in line.reconciliation.posting.transaction.postings if posting.account != line.source_account %}
|
|
|
|
<a href="#" class="text-body" onclick="classifyLine({{ line.id }});return false;">{{ posting.account }}</a>
|
|
|
|
{% endfor %}
|
2023-01-07 19:01:05 +11:00
|
|
|
<a href="{{ url_for('journal_edit_transaction', id=line.reconciliation.posting.transaction.id) }}" class="text-muted"><i class="bi bi-pencil"></i></a>
|
2022-12-24 16:57:53 +11:00
|
|
|
{% endif %}
|
|
|
|
</td>
|
2022-12-25 17:05:39 +11:00
|
|
|
<td class="text-end">{{ line.amount().format() if line.quantity >= 0 else '' }}</td>
|
|
|
|
<td class="text-end">{{ (line.amount()|abs).format() if line.quantity < 0 else '' }}</td>
|
|
|
|
<td class="text-end">{{ line.balance or '' }}</td>
|
2022-12-24 12:31:45 +11:00
|
|
|
</tr>
|
2022-12-24 16:57:53 +11:00
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block scripts %}
|
2022-12-24 12:31:45 +11:00
|
|
|
<script>
|
|
|
|
function classifyLine(lineId) {
|
|
|
|
let chargeAccount = prompt('Charge to:');
|
|
|
|
if (!chargeAccount) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
|
xhr.addEventListener('load', function() {
|
|
|
|
if (xhr.status === 200) {
|
|
|
|
document.querySelector('[data-line-id="' + lineId + '"] .charge-account a').innerText = chargeAccount;
|
|
|
|
document.querySelector('[data-line-id="' + lineId + '"] .charge-account a').className = 'text-body';
|
2023-01-02 18:57:25 +11:00
|
|
|
} else {
|
|
|
|
alert('Error when charging statement line');
|
2022-12-24 12:31:45 +11:00
|
|
|
}
|
|
|
|
});
|
2023-01-07 19:01:05 +11:00
|
|
|
xhr.open('POST', '{{ url_for("statement_line_charge") }}');
|
2022-12-24 12:31:45 +11:00
|
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
|
|
xhr.send('line-id=' + lineId + '&charge-account=' + chargeAccount);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|