summaryrefslogtreecommitdiff
path: root/rust/actualbudget_to_schist_transformer/tests/common/account_matchers.rs
blob: 599f31ffab644a55c07b705f707f7e8a44349e57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use schist_models::account::Account;

pub fn get_account_matchers() -> Vec<Box<dyn Fn(&Account) -> bool>> {
    vec![
        Box::new(|a| matches_bank_account(a)),
        Box::new(|a| matches_cash_account(a)),
    ]
}

fn matches_bank_account(account: &Account) -> bool {
    match account {
        Account {
            name,
            opening_balance: 0,
            opening_date,
            ..
        } => name == "My bank account" && *opening_date == "2024-08-01".parse().unwrap(),
        _ => false,
    }
}

fn matches_cash_account(account: &Account) -> bool {
    match account {
        Account {
            name,
            opening_balance: 0,
            opening_date,
            ..
        } => name == "My cash account" && *opening_date == "2024-08-01".parse().unwrap(),
        _ => false,
    }
}