diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-08-18 12:58:09 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-08-18 12:58:09 -0400 |
commit | 5f4468ad1fc515aadd06cfcb59e26cc30c5ba6df (patch) | |
tree | f0ed4dd804d3379fed07d2c2a1e10a1657dd6f68 /src/checks.rs | |
parent | 4bfd73b6fb39f112e45780dea0d7acc2046d46b3 (diff) | |
download | ynab-reimbursements-5f4468ad1fc515aadd06cfcb59e26cc30c5ba6df.tar.gz ynab-reimbursements-5f4468ad1fc515aadd06cfcb59e26cc30c5ba6df.zip |
run checks on refresh too
Diffstat (limited to 'src/checks.rs')
-rw-r--r-- | src/checks.rs | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/src/checks.rs b/src/checks.rs deleted file mode 100644 index dfd5362..0000000 --- a/src/checks.rs +++ /dev/null @@ -1,32 +0,0 @@ -pub fn run_checks(budget: &crate::ynab::Budget) { - check_reconciled(budget); - check_has_inflows(budget); -} - -fn check_reconciled(budget: &crate::ynab::Budget) { - let reconciled_amount: i64 = budget - .reimbursables() - .iter() - .filter(|t| t.reimbursed) - .map(|t| t.amount) - .sum(); - if reconciled_amount != 0 { - eprintln!( - "reconciled reimbursables don't sum to $0.00: ${}", - crate::ynab::format_amount(reconciled_amount) - ); - std::process::exit(1); - } -} - -fn check_has_inflows(budget: &crate::ynab::Budget) { - let txns = budget - .reimbursables() - .iter() - .filter(|t| !t.reimbursed && t.amount > 0) - .count(); - if txns == 0 { - eprintln!("no transactions to reconcile"); - std::process::exit(1); - } -} |