summaryrefslogtreecommitdiff
path: root/schist_desktop_gui/src/gui/components/transactions_view
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-02-22 21:34:24 +0000
committerJoe Carstairs <me@joeac.net>2026-02-22 21:34:24 +0000
commit4030a63ac6fe61df87dca07e4143a6b84a9e8475 (patch)
treeb7455e7f865bf638f0ceaad7b6bbfca51b988824 /schist_desktop_gui/src/gui/components/transactions_view
parent96e1b8a6158e5ac3b56c03718de5650ff805d41b (diff)
task-085: include account transfers
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.rs61
1 files changed, 22 insertions, 39 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 4f61493..1427830 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,5 +1,3 @@
-use std::collections::HashMap;
-
use iced::{
alignment,
widget::{
@@ -11,11 +9,10 @@ use iced::{
},
Element, Length,
};
-use schist_models::{Bucket, Transaction};
use crate::{gui::components::Text, style::SPACING_LG, traits::Viewable};
-use super::{Message, TransactionsView};
+use super::{Message, TransactionRow, TransactionsView};
impl<'a> Viewable<'a, Message> for TransactionsView {
fn view(&'a self) -> Element<'a, Message> {
@@ -28,7 +25,7 @@ impl<'a> Viewable<'a, Message> for TransactionsView {
),
column(
Text::default("Bucket").width(iced::Length::Fixed(128.0)),
- |t: Transaction| view_bucket_cell(t, &self.buckets),
+ view_bucket_cell,
),
column(
Text::default("Payee").width(iced::Length::Fixed(256.0)),
@@ -40,7 +37,7 @@ impl<'a> Viewable<'a, Message> for TransactionsView {
),
column(
Text::default("Balance").width(iced::Length::Fixed(96.0)),
- |t: Transaction| view_balance_cell(t, &self.account_balances_by_transaction_id),
+ view_balance_cell,
),
];
@@ -49,7 +46,7 @@ impl<'a> Viewable<'a, Message> for TransactionsView {
.active_option
.clone()
.map_or_else(Vec::default, |option| {
- self.transactions_by_account_id
+ self.transaction_rows_by_account_id
.get(&option.account.id)
.cloned()
.unwrap_or_else(Vec::default)
@@ -71,54 +68,40 @@ impl<'a> Viewable<'a, Message> for TransactionsView {
}
}
-fn view_date_cell(transaction: Transaction) -> Text {
- Text::default(transaction.date.format("%e %b %Y").as_str())
+fn view_date_cell(row: TransactionRow) -> Text {
+ Text::default(row.date.format("%e %b %Y").as_str())
.width(iced::Length::Fixed(128.0))
.small()
.clip()
}
-fn view_bucket_cell(t: Transaction, buckets: &[Bucket]) -> Text {
- (t.bucket_id.map_or_else(
- || Text::default("None").italic(),
- |id| {
- buckets.iter().find(|b| b.id == id).map_or_else(
- || Text::default(format!("<{}>", id).as_str()).italic(),
- |b| Text::default(&b.name),
- )
- },
- ))
- .width(iced::Length::Fixed(128.0))
- .small()
- .clip()
+fn view_bucket_cell(row: TransactionRow) -> Text {
+ Text::default(&row.bucket)
+ .style(row.bucket_font_style)
+ .width(iced::Length::Fixed(128.0))
+ .small()
+ .clip()
}
-fn view_payee_cell(t: Transaction) -> Text {
- Text::default(&t.counterparty)
+fn view_payee_cell(row: TransactionRow) -> Text {
+ Text::default(&row.payee)
+ .style(row.payee_font_style)
.width(iced::Length::Fixed(256.0))
.small()
.clip()
}
-fn view_quantity_cell(t: Transaction) -> Text {
- Text::currency(t.amount)
+fn view_quantity_cell(row: TransactionRow) -> Text {
+ Text::currency(row.amount)
.width(iced::Length::Fixed(96.0))
.small()
.clip()
.align_right()
}
-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()
+fn view_balance_cell(row: TransactionRow) -> Text {
+ Text::currency(row.balance)
+ .width(iced::Length::Fixed(96.0))
+ .small()
+ .clip()
}