Display existing statement line transaction when editing
This commit is contained in:
parent
3debfb1122
commit
ee6d91d811
@ -62,16 +62,19 @@ def statement_line_edit_transaction():
|
||||
abort(404)
|
||||
|
||||
if request.method == 'GET':
|
||||
# FIXME: Show existing transaction details
|
||||
return render_template('statement_line_edit_transaction.html', statement_line=statement_line)
|
||||
if len(statement_line.postings) == 0:
|
||||
return render_template('statement_line_edit_transaction.html', statement_line=statement_line, transaction=None)
|
||||
|
||||
if len(statement_line.postings) > 1:
|
||||
# NYI
|
||||
raise Exception('Cannot display a StatementLine with >2 postings')
|
||||
|
||||
# Get existing transaction
|
||||
return render_template('statement_line_edit_transaction.html', statement_line=statement_line, transaction=statement_line.postings[0].transaction)
|
||||
|
||||
# Delete existing postings
|
||||
if len(statement_line.postings) > 0:
|
||||
for posting in statement_line.postings:
|
||||
if len(posting.transaction.postings) > 2:
|
||||
# Complex posting
|
||||
raise Exception('Cannot automatically delete a StatementLineTransaction with >2 postings')
|
||||
|
||||
# Queue for deletion
|
||||
db_session.delete(posting.transaction)
|
||||
|
||||
|
@ -73,14 +73,35 @@
|
||||
{% if statement_line.quantity >= 0 %}<td class="has-amount">{{ statement_line.amount().format() }}</td>{% else %}<td></td>{% endif %}
|
||||
{% if statement_line.quantity < 0 %}<td class="has-amount">{{ (statement_line.amount()|abs).format() }}</td>{% else %}<td></td>{% endif %}
|
||||
</tr>
|
||||
{# Charge lines #}
|
||||
{% if transaction == None %}
|
||||
<tr data-side="charge">
|
||||
{# Charge line #}
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><i>{{ 'Cr' if statement_line.quantity >= 0 else 'Dr' }}</i> <input type="text" name="charge-account"> <a class="text-primary" href="#" onclick="addPosting(this);return false;"><i class="bi bi-plus-circle-fill"></i></a></td>
|
||||
{% if statement_line.quantity < 0 %}<td class="has-amount">{{ (statement_line.amount()|abs).format() }}</td>{% else %}<td></td>{% endif %}
|
||||
{% if statement_line.quantity >= 0 %}<td class="has-amount">{{ statement_line.amount().format() }}</td>{% else %}<td></td>{% endif %}
|
||||
</tr>
|
||||
{% elif transaction.postings|length == 2 %}
|
||||
<tr data-side="charge">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><i>{{ 'Cr' if statement_line.quantity >= 0 else 'Dr' }}</i> <input type="text" name="charge-account" value="{{ transaction.charge_account(statement_line.source_account) }}"> <a class="text-primary" href="#" onclick="addPosting(this);return false;"><i class="bi bi-plus-circle-fill"></i></a></td>
|
||||
{% if statement_line.quantity < 0 %}<td class="has-amount">{{ (statement_line.amount()|abs).format() }}</td>{% else %}<td></td>{% endif %}
|
||||
{% if statement_line.quantity >= 0 %}<td class="has-amount">{{ statement_line.amount().format() }}</td>{% else %}<td></td>{% endif %}
|
||||
</tr>
|
||||
{% else %}
|
||||
{% for posting in transaction.postings if posting.account != statement_line.source_account %}
|
||||
<tr data-side="charge">
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><i>{{ 'Cr' if statement_line.quantity >= 0 else 'Dr' }}</i> <input type="text" name="charge-account" value="{{ posting.account }}"> <a class="text-primary" href="#" onclick="addPosting(this);return false;"><i class="bi bi-plus-circle-fill"></i></a></td>
|
||||
{% if statement_line.quantity < 0 %}<td class="has-amount">{{ posting.commodity }}<input type="number" name="charge-amount" step="0.01" value="{{ posting.amount().quantity_string() }}"></td>{% else %}<td></td>{% endif %}
|
||||
{% if statement_line.quantity >= 0 %}<td class="has-amount">{{ posting.commodity }}<input type="number" name="charge-amount" step="0.01" value="{{ (posting.amount()|abs).quantity_string() }}"></td>{% else %}<td></td>{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -40,13 +40,16 @@
|
||||
<td>{{ line.source_account }}</td>
|
||||
<td>{{ line.dt.strftime('%Y-%m-%d') }}</td>
|
||||
<td>{{ line.description }}</td>
|
||||
<td class="charge-account">
|
||||
{% if line.postings|length == 0 %}
|
||||
<td class="charge-account"><a href="#" class="text-danger" onclick="classifyLine({{ line.id }});return false;">Unclassified</a> <a href="/statement-lines/edit-transaction?line-id={{ line.id }}" class="text-muted"><i class="bi bi-pencil"></i></a></td>
|
||||
<a href="#" class="text-danger" onclick="classifyLine({{ line.id }});return false;">Unclassified</a>
|
||||
{% elif line.is_complex() %}
|
||||
<td class="charge-account"><i>(Complex)</i></td>
|
||||
<i>(Complex)</i>
|
||||
{% else %}
|
||||
<td class="charge-account"><a href="#" class="text-body" onclick="classifyLine({{ line.id }});return false;">{{ line.postings[0].transaction.charge_account(line.source_account) }}</a> <a href="/statement-lines/edit-transaction?line-id={{ line.id }}" class="text-muted"><i class="bi bi-pencil"></i></a></td>
|
||||
<a href="#" class="text-body" onclick="classifyLine({{ line.id }});return false;">{{ line.postings[0].transaction.charge_account(line.source_account) }}</a>
|
||||
{% endif %}
|
||||
<a href="/statement-lines/edit-transaction?line-id={{ line.id }}" class="text-muted"><i class="bi bi-pencil"></i></a>
|
||||
</td>
|
||||
<td>{{ line.amount().format() if line.quantity >= 0 else '' }}</td>
|
||||
<td>{{ (line.amount()|abs).format() if line.quantity < 0 else '' }}</td>
|
||||
<td>{{ line.balance or '' }}</td>
|
||||
|
Loading…
Reference in New Issue
Block a user