Delete statement line reconciliation when deleting transaction

This commit is contained in:
RunasSudo 2023-05-28 11:59:00 +10:00
parent 4aa6c610e4
commit bbd98ee8c4
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -78,6 +78,12 @@ def journal_edit_transaction():
if request.form.get('action', None) == 'delete': if request.form.get('action', None) == 'delete':
# Delete transaction # Delete transaction
db.session.delete(transaction) db.session.delete(transaction)
# Delete reconciliations if required
for posting in transaction.postings:
for reconciliation in StatementLineReconciliation.query.filter(StatementLineReconciliation.posting == posting):
db.session.delete(reconciliation)
db.session.commit() db.session.commit()
return redirect(url_for('journal')) return redirect(url_for('journal'))