Skip to content

Commit

Permalink
Ignore zero dollar transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
ollien committed Feb 5, 2024
1 parent 69731bd commit 6b3a8ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ynab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ impl Client {
let ynab_transaction =
YNABTransaction::from_transaction_for_account(transaction, account_id)?;

if ynab_transaction.amount == 0 {
info!("Ignoring zero dollar transaction (likely an authorization charge)");
return Ok(());
}

let request_data = YNABTransactionRequestData {
transaction: ynab_transaction,
};
Expand Down Expand Up @@ -186,6 +191,7 @@ mod tests {
#[test_case("$1.00", -1000)]
#[test_case("4.50", -4500; "no dollar sign")]
#[test_case("$4,526.00", -4_526_000; "comma separated")]
#[test_case("$0.00", 0)]
fn test_converts_dollar_amount_to_ynab_form(raw: &str, expected: i32) {
let converted = convert_amount_to_ynab_form(raw).expect("failed to convert");
assert_eq!(converted, expected);
Expand Down

0 comments on commit 6b3a8ab

Please sign in to comment.