From 23ff8466c04cf8460e4ea206548ddcab4d2d0460 Mon Sep 17 00:00:00 2001 From: le king fu Date: Sat, 25 Apr 2026 16:24:13 -0400 Subject: [PATCH] fix(balance): use transactions.date column (not transaction_date) The schema's transactions table uses `date` (see schema.sql:67), not `transaction_date`. Compile-checked the column name was correct. Co-Authored-By: Claude Opus 4.7 (1M context) --- src-tauri/src/commands/balance_commands.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/commands/balance_commands.rs b/src-tauri/src/commands/balance_commands.rs index 47f488b..ea196b5 100644 --- a/src-tauri/src/commands/balance_commands.rs +++ b/src-tauri/src/commands/balance_commands.rs @@ -129,16 +129,18 @@ fn read_cash_flows( period_start: &str, period_end: &str, ) -> Result, String> { + // NOTE: the transactions table column is `date` (not `transaction_date`). + // See `src-tauri/src/database/schema.sql:67`. let mut stmt = conn .prepare( - "SELECT t.transaction_date, + "SELECT t.date, ABS(t.amount) AS abs_amount, bat.direction FROM balance_account_transfers bat JOIN transactions t ON t.id = bat.transaction_id WHERE bat.account_id = ?1 - AND t.transaction_date BETWEEN ?2 AND ?3 - ORDER BY t.transaction_date", + AND t.date BETWEEN ?2 AND ?3 + ORDER BY t.date", ) .map_err(|e| format!("prepare flows query: {}", e))?; @@ -146,6 +148,8 @@ fn read_cash_flows( .query_map( rusqlite::params![account_id, period_start, period_end], |row| { + // `transactions.date` may come back as String (TEXT) — keep + // the decoder generic enough. let date_str: String = row.get(0)?; let amount: f64 = row.get(1)?; let direction: String = row.get(2)?;