diff --git a/src/components/TransactionEditor.vue b/src/components/TransactionEditor.vue
index d22bf6c..b221abb 100644
--- a/src/components/TransactionEditor.vue
+++ b/src/components/TransactionEditor.vue
@@ -86,7 +86,7 @@
-
+
@@ -244,4 +244,36 @@
await getCurrentWindow().close();
}
+
+ async function deleteTransaction() {
+ if (!confirm('Are you sure you want to delete this transaction? This operation is irreversible.')) {
+ return;
+ }
+
+ const session = await db.load();
+
+ // Delete atomically
+ await session.execute(
+ `BEGIN;
+
+ -- Cascade delete statement line reconciliations
+ DELETE FROM statement_line_reconciliations
+ WHERE posting_id IN (
+ SELECT postings.id FROM postings WHERE transaction_id = $1
+ );
+
+ -- Delete postings
+ DELETE FROM postings
+ WHERE transaction_id = $1;
+
+ -- Delete transaction
+ DELETE FROM transactions
+ WHERE id = $1;
+
+ COMMIT;`,
+ [transaction.id]
+ );
+
+ await getCurrentWindow().close();
+ }