Add button to delete balance assertion

This commit is contained in:
RunasSudo 2024-04-06 00:39:36 +11:00
parent ff0a18f83b
commit 9206c21025
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 10 additions and 1 deletions

View File

@ -174,6 +174,12 @@ def balance_assertions_edit():
if request.method == 'GET':
return render_template('journal/balance_assertions_edit.html', assertion=assertion)
if request.form.get('action', None) == 'delete':
# Delete balance assertion
db.session.delete(assertion)
db.session.commit()
return redirect(request.form.get('referrer', '') or url_for('balance_assertions'))
quantity = round(float(request.form['amount']) * (10**AMOUNT_DPS))
if request.form['sign'] == 'cr':
quantity = -quantity

View File

@ -54,7 +54,10 @@
</div>
</div>
<div class="text-end">
<div class="flex justify-end mt-4 space-x-2">
{% if assertion and assertion.id %}
<button type="submit" name="action" value="delete" class="btn-secondary text-red-600 ring-red-500" onclick="confirm('Are you sure you want to delete this balance assertion? This operation is irreversible.')">Delete</button>
{% endif %}
<button type="submit" class="btn-primary">Save</button>
</div>
</form>