From 8736aa451198a246692e3d386116017f1c7e52b2 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 12 Aug 2019 03:54:23 -0400 Subject: also display total amounts --- src/views/txn_table.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/views/txn_table.rs b/src/views/txn_table.rs index e1ecfa6..8ace7b0 100644 --- a/src/views/txn_table.rs +++ b/src/views/txn_table.rs @@ -6,6 +6,7 @@ enum TxnColumn { Date, Payee, Amount, + TotalAmount, } type TxnTableView = @@ -53,6 +54,13 @@ impl cursive_table_view::TableViewItem TxnColumn::Date => self.date.clone(), TxnColumn::Payee => self.payee.clone(), TxnColumn::Amount => crate::ynab::format_amount(self.amount), + TxnColumn::TotalAmount => { + if self.amount == self.total_amount { + "".to_string() + } else { + crate::ynab::format_amount(self.total_amount) + } + } } } @@ -65,6 +73,7 @@ impl cursive_table_view::TableViewItem TxnColumn::Date => self.date.cmp(&other.date), TxnColumn::Payee => self.payee.cmp(&other.payee), TxnColumn::Amount => self.amount.cmp(&other.amount), + TxnColumn::TotalAmount => self.amount.cmp(&other.total_amount), } } } @@ -100,6 +109,9 @@ fn txn_table( .column(TxnColumn::Amount, "Amount", |c| { c.align(cursive::align::HAlign::Right).width(10) }) + .column(TxnColumn::TotalAmount, "", |c| { + c.align(cursive::align::HAlign::Right).width(10) + }) .default_column(TxnColumn::Date) .on_submit(move |s, _, _| { let total_outflow = s -- cgit v1.2.3-54-g00ecf