1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 13:35:21 +02:00

Encapsulate enrichment actions, add tests

This commit is contained in:
Zach Gollwitzer 2025-05-20 11:33:35 -04:00
parent dd605a577e
commit 94a807c3c9
9 changed files with 149 additions and 71 deletions

View file

@ -77,14 +77,14 @@ class PlaidItem < ApplicationRecord
category = alias_matcher.match(transaction.plaid_category_detailed)
if category.present?
PlaidItem.transaction do
transaction.log_enrichment!(
attribute_name: "category_id",
attribute_value: category.id,
source: "plaid"
)
transaction.set_category!(category)
# Matcher could either return a string or a Category object
user_category = if category.is_a?(String)
family.categories.find_or_create_by!(name: category)
else
category
end
transaction.enrich_attribute(:category_id, user_category.id, source: "plaid")
end
end
end