aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 46f8042..0bba75a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,13 +4,41 @@ fn main() {
let key = std::env::args().nth(1).unwrap();
let client = ynab::Client::new(&key);
let budget = client.default_budget();
+ let reimbursables = budget.reimbursables();
println!("using budget {} ({})", budget.name(), budget.id());
- for t in budget.reimbursables() {
- if t.reimbursed {
- continue;
- }
+ let reconciled_amount: i64 = reimbursables
+ .iter()
+ .filter(|t| t.reimbursed)
+ .map(|t| t.amount)
+ .sum();
+ if reconciled_amount != 0 {
+ eprintln!(
+ "reconciled reimbursables don't sum to $0.00: ${}",
+ ynab::format_amount(reconciled_amount)
+ );
+ std::process::exit(1);
+ }
+ println!("reconciled reimbursables correctly sum to $0.00");
+
+ println!("ready for reconciliation:");
+ for t in reimbursables
+ .iter()
+ .filter(|t| !t.reimbursed && t.amount > 0)
+ {
+ println!(
+ "{} | {} | {}",
+ t.date,
+ t.payee,
+ ynab::format_amount(t.amount)
+ )
+ }
+ println!("match against reconcilable:");
+ for t in reimbursables
+ .iter()
+ .filter(|t| !t.reimbursed && t.amount <= 0)
+ {
println!(
"{} | {} | {}",
t.date,