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)?;