From efa42415a95cfa96cd63272b87dac9a9a037fb47 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Mon, 18 Nov 2024 21:16:08 +1100 Subject: [PATCH] Invalidate running balances when classifying statement line --- src/pages/StatementLinesView.vue | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pages/StatementLinesView.vue b/src/pages/StatementLinesView.vue index 49799e1..c63b692 100644 --- a/src/pages/StatementLinesView.vue +++ b/src/pages/StatementLinesView.vue @@ -206,6 +206,20 @@ [statementLine.id, accountPostingId] ); + // Invalidate running balances + await dbTransaction.execute( + `UPDATE postings + SET running_balance = NULL + FROM ( + SELECT postings.id + FROM transactions + JOIN postings ON transactions.id = postings.transaction_id + WHERE DATE(dt) >= DATE($1) AND account IN ($2, $3) + ) p + WHERE postings.id = p.id`, + [statementLine.dt, statementLine.source_account, chargeAccount] + ); + dbTransaction.commit(); // Reload transactions and re-render the table