summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/transactions_view
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-02-22 09:32:21 +0000
committerJoe Carstairs <me@joeac.net>2026-02-22 09:32:21 +0000
commit96e1b8a6158e5ac3b56c03718de5650ff805d41b (patch)
tree7fb37d9acc354488b611cec5da76e02ce78439f6 /schist_desktop_gui/src/gui/components/transactions_view
parent6137e4bec5fd7f34c66162b32424343a30b3c5f2 (diff)
task-085: displays running balances
Diffstat (limited to 'schist_desktop_gui/src/gui/components/transactions_view')
-rw-r--r--schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs b/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs
index f43ee48..4f61493 100644
--- a/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs
+++ b/schist_desktop_gui/src/gui/components/transactions_view/view_transactions_view.rs
@@ -1,3 +1,5 @@
+use std::collections::HashMap;
+
use iced::{
alignment,
widget::{
@@ -38,7 +40,7 @@ impl<'a> Viewable<'a, Message> for TransactionsView {
),
column(
Text::default("Balance").width(iced::Length::Fixed(96.0)),
- |_t: Transaction| view_balance_cell(),
+ |t: Transaction| view_balance_cell(t, &self.account_balances_by_transaction_id),
),
];
@@ -106,9 +108,17 @@ fn view_quantity_cell(t: Transaction) -> Text {
.align_right()
}
-fn view_balance_cell() -> Text {
- Text::default("TODO")
- .width(iced::Length::Fixed(96.0))
- .small()
- .clip()
+fn view_balance_cell(
+ transaction: Transaction,
+ account_balances_by_transaction_id: &HashMap<i32, i32>,
+) -> Text {
+ (account_balances_by_transaction_id
+ .get(&transaction.id)
+ .map_or_else(
+ || Text::default("Error").danger(),
+ |&balance| Text::currency(balance),
+ ))
+ .width(iced::Length::Fixed(96.0))
+ .small()
+ .clip()
}