Skip to content

Commit

Permalink
Skip transactions in non-open accounts (fixes #19)
Browse files Browse the repository at this point in the history
Now prints a warning instead of bailing.
  • Loading branch information
borsboom committed Dec 17, 2019
1 parent 9735fc1 commit a1a2272
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/foreign_transactions_processor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use chrono::{Duration, NaiveDate};
use log::debug;
use log::{debug, warn};
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};

Expand Down Expand Up @@ -181,18 +181,26 @@ impl<'a> ForeignTransactionsProcessor<'a> {
}
}
for parent_transaction in latest_transactions {
debug!("Processing transaction: {:?}", parent_transaction);
let parent_transaction_id = YnabTransactionId::new(parent_transaction.id);
let parent_transaction_account_id = YnabAccountId::new(parent_transaction.account_id);
let difference_key = match self
.foreign_accounts
.get_account_data(&YnabAccountId::new(parent_transaction.account_id))
.get_account_data(&parent_transaction_account_id)
{
Some(AccountData::Difference { .. }) => {
// Don't process transactions that are in difference accounts, since this tool created them.
continue;
}
Some(AccountData::Foreign { difference_key }) => Some(*difference_key),
Some(AccountData::Local { .. }) => None,
None => bail!("Could not find account for transaction"),
None => {
warn!(
"Could not find open account {} for transaction {}",
&parent_transaction_account_id, &parent_transaction_id
);
None
}
};
let common_data = ForeignCommonData {
difference_key,
Expand Down

0 comments on commit a1a2272

Please sign in to comment.