summaryrefslogtreecommitdiff
path: root/actualbudget_queries/tests/common/zero_budget_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_queries/tests/common/zero_budget_matchers.rs
parentc7ed1e61ce2218be0b9e60577454124c4e43a366 (diff)
Tidier folders
Diffstat (limited to 'actualbudget_queries/tests/common/zero_budget_matchers.rs')
-rw-r--r--actualbudget_queries/tests/common/zero_budget_matchers.rs285
1 files changed, 0 insertions, 285 deletions
diff --git a/actualbudget_queries/tests/common/zero_budget_matchers.rs b/actualbudget_queries/tests/common/zero_budget_matchers.rs
deleted file mode 100644
index ac88d3b..0000000
--- a/actualbudget_queries/tests/common/zero_budget_matchers.rs
+++ /dev/null
@@ -1,285 +0,0 @@
-use std::collections::HashMap;
-
-use actualbudget_models::{ActualbudgetCategory, ActualbudgetZeroBudget};
-
-use super::category_names::CATEGORY_NAMES_DICT;
-
-pub fn get_zero_budget_matchers() -> Vec<Box<dyn Fn(&ActualbudgetZeroBudget, &HashMap<String, ActualbudgetCategory>) -> bool>> {
- vec![
- Box::new(|t, c| matches_food_budget(t, c, "08")),
- Box::new(|t, c| matches_food_budget(t, c, "09")),
- Box::new(|t, c| matches_food_budget(t, c, "10")),
- Box::new(|t, c| matches_food_budget(t, c, "11")),
- Box::new(|t, c| matches_zero_food_budget(t, c, "12")),
- Box::new(|t, c| matches_general_budget(t, c, "08")),
- Box::new(|t, c| matches_general_budget(t, c, "09")),
- Box::new(|t, c| matches_general_budget(t, c, "10")),
- Box::new(|t, c| matches_general_budget(t, c, "11")),
- Box::new(|t, c| matches_zero_general_budget(t, c, "12")),
- Box::new(|t, c| matches_bills_budget(t, c, "08")),
- Box::new(|t, c| matches_bills_budget(t, c, "09")),
- Box::new(|t, c| matches_bills_budget(t, c, "10")),
- Box::new(|t, c| matches_bills_budget(t, c, "11")),
- Box::new(|t, c| matches_zero_bills_budget(t, c, "12")),
- Box::new(|t, c| matches_bills_flexible_budget(t, c, "08")),
- Box::new(|t, c| matches_bills_flexible_budget(t, c, "09")),
- Box::new(|t, c| matches_bills_flexible_budget(t, c, "10")),
- Box::new(|t, c| matches_bills_flexible_budget(t, c, "11")),
- Box::new(|t, c| matches_zero_bills_flexible_budget(t, c, "12")),
- Box::new(|t, c| matches_savings_budget(t, c, "08")),
- Box::new(|t, c| matches_savings_budget(t, c, "09")),
- Box::new(|t, c| matches_savings_budget(t, c, "10")),
- Box::new(|t, c| matches_savings_budget(t, c, "11")),
- Box::new(|t, c| matches_zero_savings_budget(t, c, "12")),
- ]
-}
-
-fn matches_food_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let food_category_id = categories
- .get(CATEGORY_NAMES_DICT.food)
- .expect("failed to find food category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 200_00,
- do_carry_over: false,
- ..
- } =>
- *category_id == food_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_zero_food_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let food_category_id = categories
- .get(CATEGORY_NAMES_DICT.food)
- .expect("failed to find food category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 0,
- do_carry_over: false,
- ..
- } =>
- *category_id == food_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_general_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let general_category_id = categories
- .get(CATEGORY_NAMES_DICT.general)
- .expect("failed to find general category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 100_00,
- do_carry_over: false,
- ..
- } =>
- *category_id == general_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_zero_general_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let general_category_id = categories
- .get(CATEGORY_NAMES_DICT.general)
- .expect("failed to find general category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 0,
- do_carry_over: false,
- ..
- } =>
- *category_id == general_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_bills_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let bills_category_id = categories
- .get(CATEGORY_NAMES_DICT.bills)
- .expect("failed to find bills category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 125_00,
- do_carry_over: false,
- ..
- } =>
- *category_id == bills_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_zero_bills_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let bills_category_id = categories
- .get(CATEGORY_NAMES_DICT.bills)
- .expect("failed to find bills category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 0,
- do_carry_over: false,
- ..
- } =>
- *category_id == bills_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_bills_flexible_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let bills_flexible_category_id = categories
- .get(CATEGORY_NAMES_DICT.bills_flexible)
- .expect("failed to find bills (flexible) category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 25_00,
- do_carry_over: false,
- ..
- } =>
- *category_id == bills_flexible_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_zero_bills_flexible_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let bills_flexible_category_id = categories
- .get(CATEGORY_NAMES_DICT.bills_flexible)
- .expect("failed to find bills (flexible) category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 0,
- do_carry_over: false,
- ..
- } =>
- *category_id == bills_flexible_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_savings_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let savings_category_id = categories
- .get(CATEGORY_NAMES_DICT.savings)
- .expect("failed to find savings category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 400_00,
- do_carry_over: false,
- ..
- } =>
- *category_id == savings_category_id
- && date.month() == month,
- _ => false,
- }
-}
-
-fn matches_zero_savings_budget(
- t: &ActualbudgetZeroBudget,
- categories: &HashMap<String, ActualbudgetCategory>,
- month: &str,
-) -> bool {
- let savings_category_id = categories
- .get(CATEGORY_NAMES_DICT.savings)
- .expect("failed to find savings category")
- .id
- .clone();
-
- match t {
- ActualbudgetZeroBudget {
- month: date,
- category_id,
- amount: 0,
- do_carry_over: false,
- ..
- } =>
- *category_id == savings_category_id
- && date.month() == month,
- _ => false,
- }
-}