feat(balance): Modified Dietz returns + transfer linking (#142) #151
1 changed files with 7 additions and 3 deletions
|
|
@ -129,16 +129,18 @@ fn read_cash_flows(
|
||||||
period_start: &str,
|
period_start: &str,
|
||||||
period_end: &str,
|
period_end: &str,
|
||||||
) -> Result<Vec<(NaiveDate, f64)>, String> {
|
) -> Result<Vec<(NaiveDate, f64)>, String> {
|
||||||
|
// NOTE: the transactions table column is `date` (not `transaction_date`).
|
||||||
|
// See `src-tauri/src/database/schema.sql:67`.
|
||||||
let mut stmt = conn
|
let mut stmt = conn
|
||||||
.prepare(
|
.prepare(
|
||||||
"SELECT t.transaction_date,
|
"SELECT t.date,
|
||||||
ABS(t.amount) AS abs_amount,
|
ABS(t.amount) AS abs_amount,
|
||||||
bat.direction
|
bat.direction
|
||||||
FROM balance_account_transfers bat
|
FROM balance_account_transfers bat
|
||||||
JOIN transactions t ON t.id = bat.transaction_id
|
JOIN transactions t ON t.id = bat.transaction_id
|
||||||
WHERE bat.account_id = ?1
|
WHERE bat.account_id = ?1
|
||||||
AND t.transaction_date BETWEEN ?2 AND ?3
|
AND t.date BETWEEN ?2 AND ?3
|
||||||
ORDER BY t.transaction_date",
|
ORDER BY t.date",
|
||||||
)
|
)
|
||||||
.map_err(|e| format!("prepare flows query: {}", e))?;
|
.map_err(|e| format!("prepare flows query: {}", e))?;
|
||||||
|
|
||||||
|
|
@ -146,6 +148,8 @@ fn read_cash_flows(
|
||||||
.query_map(
|
.query_map(
|
||||||
rusqlite::params![account_id, period_start, period_end],
|
rusqlite::params![account_id, period_start, period_end],
|
||||||
|row| {
|
|row| {
|
||||||
|
// `transactions.date` may come back as String (TEXT) — keep
|
||||||
|
// the decoder generic enough.
|
||||||
let date_str: String = row.get(0)?;
|
let date_str: String = row.get(0)?;
|
||||||
let amount: f64 = row.get(1)?;
|
let amount: f64 = row.get(1)?;
|
||||||
let direction: String = row.get(2)?;
|
let direction: String = row.get(2)?;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue