1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-29 18:19:39 +02:00

Remove manual merchant management (rules will replace)

This commit is contained in:
Zach Gollwitzer 2025-04-02 17:48:34 -04:00
parent f07940bf45
commit 83dcbd9ff0
44 changed files with 123 additions and 386 deletions

View file

@ -8,14 +8,13 @@ class Rule::ConditionTest < ActiveSupport::TestCase
@transaction_rule = @family.rules.create!(resource_type: "transaction")
@account = @family.accounts.create!(name: "Rule test", balance: 1000, currency: "USD", accountable: Depository.new)
@grocery_category = @family.categories.create!(name: "Grocery")
@whole_foods_merchant = @family.merchants.create!(name: "Whole Foods")
@shopping_category = @family.categories.create!(name: "Shopping")
# Some sample transactions to work with
create_transaction(date: Date.current, account: @account, amount: 100, name: "Rule test transaction1", merchant: @whole_foods_merchant)
create_transaction(date: Date.current, account: @account, amount: 100, name: "Rule test transaction1", merchant: merchants(:amazon))
create_transaction(date: Date.current, account: @account, amount: -200, name: "Rule test transaction2")
create_transaction(date: 1.day.ago.to_date, account: @account, amount: 50, name: "Rule test transaction3")
create_transaction(date: 1.year.ago.to_date, account: @account, amount: 10, name: "Rule test transaction4", merchant: @whole_foods_merchant)
create_transaction(date: 1.year.ago.to_date, account: @account, amount: 10, name: "Rule test transaction4", merchant: merchants(:amazon))
create_transaction(date: 1.year.ago.to_date, account: @account, amount: 1000, name: "Rule test transaction5")
@rule_scope = @account.transactions
@ -53,7 +52,7 @@ class Rule::ConditionTest < ActiveSupport::TestCase
rule: @transaction_rule,
condition_type: "transaction_merchant",
operator: "=",
value: "Whole Foods"
value: "Amazon"
)
filtered = condition.apply(@rule_scope)
@ -69,7 +68,7 @@ class Rule::ConditionTest < ActiveSupport::TestCase
Rule::Condition.new(
condition_type: "transaction_merchant",
operator: "=",
value: "Whole Foods"
value: "Amazon"
),
Rule::Condition.new(
condition_type: "transaction_amount",
@ -92,7 +91,7 @@ class Rule::ConditionTest < ActiveSupport::TestCase
Rule::Condition.new(
condition_type: "transaction_merchant",
operator: "=",
value: "Whole Foods"
value: "Amazon"
),
Rule::Condition.new(
condition_type: "transaction_amount",