From bbd98ee8c4613651da61c1e6ea5c1c1f8c519d0c Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Sun, 28 May 2023 11:59:00 +1000 Subject: [PATCH] Delete statement line reconciliation when deleting transaction --- drcr/journal/views.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drcr/journal/views.py b/drcr/journal/views.py index 757553c..15caaa1 100644 --- a/drcr/journal/views.py +++ b/drcr/journal/views.py @@ -78,6 +78,12 @@ def journal_edit_transaction(): if request.form.get('action', None) == 'delete': # 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() return redirect(url_for('journal'))