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
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use anyhow::Context;
use schist_models::{account::Account, account_transfer::AccountTransfer};
use super::ACCOUNT_NAMES_DICT;
pub fn get_account_transfer_matchers(
) -> Vec<Box<dyn Fn(&AccountTransfer, &[Account]) -> bool>> {
vec![
Box::new(|at, a| matches_cash_withdrawal_10_sept_2024(at, a)),
]
}
fn matches_cash_withdrawal_10_sept_2024(
account_transfer: &AccountTransfer,
accounts: &[Account],
) -> bool {
let bank_account = accounts
.iter()
.filter(|a| a.name == ACCOUNT_NAMES_DICT.bank_account)
.next()
.with_context(|| "failed to find bank account")
.unwrap();
let cash_account = accounts
.iter()
.filter(|a| a.name == ACCOUNT_NAMES_DICT.cash_account)
.next()
.with_context(|| "failed to find cash account")
.unwrap();
match account_transfer {
AccountTransfer {
id: _id,
date,
description,
quantity: 80_00,
from_account_id,
to_account_id,
} => *date == "2024-09-10".parse().unwrap()
&& *description == ""
&& *from_account_id == bank_account.id
&& *to_account_id == cash_account.id,
_ => false,
}
}
|