summaryrefslogtreecommitdiff
path: root/actualbudget_to_schist_transformer/tests/common/transaction_matchers.rs
diff options
context:
space:
mode:
authorJoe Carstairs <jcarstairs@scottlogic.com>2025-07-28 13:22:53 +0100
committerJoe Carstairs <jcarstairs@scottlogic.com>2025-07-28 13:30:27 +0100
commit2361adeb0ca77904138e3466d51c2f44cf6df613 (patch)
treef6e7192908f99fab62061913d8a1e9d2b918414b /actualbudget_to_schist_transformer/tests/common/transaction_matchers.rs
parentc7ed1e61ce2218be0b9e60577454124c4e43a366 (diff)
Tidier folders
Diffstat (limited to 'actualbudget_to_schist_transformer/tests/common/transaction_matchers.rs')
-rw-r--r--actualbudget_to_schist_transformer/tests/common/transaction_matchers.rs130
1 files changed, 0 insertions, 130 deletions
diff --git a/actualbudget_to_schist_transformer/tests/common/transaction_matchers.rs b/actualbudget_to_schist_transformer/tests/common/transaction_matchers.rs
deleted file mode 100644
index c3763c1..0000000
--- a/actualbudget_to_schist_transformer/tests/common/transaction_matchers.rs
+++ /dev/null
@@ -1,130 +0,0 @@
-use schist_models::{account::Account, transaction::Transaction};
-
-use super::ACCOUNT_NAMES_DICT;
-
-pub fn get_transaction_matchers(
-) -> Vec<Box<dyn Fn(&Transaction, &[Account]) -> bool>> {
- vec![
- Box::new(|t, a| matches_bank_account_initial_transaction(t, a)),
- Box::new(|t, a| matches_cash_account_initial_transaction(t, a)),
- Box::new(|t, a| matches_income_transaction(t, a, "08")),
- Box::new(|t, a| matches_income_transaction(t, a, "09")),
- Box::new(|t, a| matches_income_transaction(t, a, "10")),
- Box::new(|t, a| matches_income_transaction(t, a, "11")),
- Box::new(|t, a| matches_food_transaction(t, a, "08")),
- Box::new(|t, a| matches_food_transaction(t, a, "09")),
- Box::new(|t, a| matches_food_transaction(t, a, "10")),
- Box::new(|t, a| matches_food_transaction(t, a, "11")),
- ]
-}
-
-pub fn matches_bank_account_initial_transaction(
- t: &Transaction,
- accounts: &[Account],
-) -> bool {
- let bank_account_id = accounts
- .iter()
- .find(|a| a.name == ACCOUNT_NAMES_DICT.bank_account)
- .expect("failed to find bank account")
- .id
- .clone();
-
- match t {
- Transaction {
- account_id,
- date,
- id: _id,
- description,
- payee,
- quantity: 1200_00,
- } => *account_id == bank_account_id
- && *date == "2024-08-01".parse().unwrap()
- && description == ""
- && payee == "Starting Balance",
- _ => false,
- }
-}
-
-pub fn matches_cash_account_initial_transaction(
- t: &Transaction,
- accounts: &[Account],
-) -> bool {
- let bank_account_id = accounts
- .iter()
- .find(|a| a.name == ACCOUNT_NAMES_DICT.cash_account)
- .expect("failed to find cash account")
- .id
- .clone();
-
- match t {
- Transaction {
- account_id,
- date,
- id: _id,
- description,
- payee,
- quantity: 45_10,
- } => *account_id == bank_account_id
- && *date == "2024-08-01".parse().unwrap()
- && description == ""
- && payee == "Starting Balance",
- _ => false,
- }
-}
-
-pub fn matches_income_transaction(
- t: &Transaction,
- accounts: &[Account],
- month: &str,
-) -> bool {
- let bank_account_id = accounts
- .iter()
- .find(|a| a.name == ACCOUNT_NAMES_DICT.bank_account)
- .expect("failed to find bank account")
- .id
- .clone();
-
- match t {
- Transaction {
- account_id,
- date,
- description,
- id: _id,
- payee,
- quantity: 846_46,
- } =>
- *account_id == bank_account_id
- && *date == format!("2024-{}-21", month).parse().unwrap()
- && description == "Salary"
- && payee == "Employer Ltd",
- _ => false,
- }
-}
-
-pub fn matches_food_transaction(
- t: &Transaction,
- accounts: &[Account],
- month: &str,
-) -> bool {
- let bank_account_id = accounts
- .iter()
- .find(|a| a.name == ACCOUNT_NAMES_DICT.bank_account)
- .expect("failed to find bank account")
- .id
- .clone();
-
- match t {
- Transaction {
- account_id,
- date,
- description,
- id: _id,
- payee,
- quantity: -200_00,
- } => *account_id == bank_account_id
- && *date == format!("2024-{}-08", month).parse().unwrap()
- && description == ""
- && payee == "Tesco",
- _ => false,
- }
-}