aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-08-12 03:54:23 -0400
committerJesse Luehrs <doy@tozt.net>2019-08-12 03:54:23 -0400
commit8736aa451198a246692e3d386116017f1c7e52b2 (patch)
tree42505f0ad7257be284298cc2524607f98ad5cfb2
parent16edecef23a3c8f965b9310527eb731ba0b5bf7a (diff)
downloadynab-api-8736aa451198a246692e3d386116017f1c7e52b2.tar.gz
ynab-api-8736aa451198a246692e3d386116017f1c7e52b2.zip
also display total amounts
-rw-r--r--src/views/txn_table.rs12
1 files changed, 12 insertions, 0 deletions
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>
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>
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