The personal finance app for everyone (by everyone)
Ruby
FIX AI categorization & Twelvedata currency (#354)
soky srm1234fd556802
diff --git a/app/models/family/auto_categorizer.rb b/app/models/family/auto_categorizer.rbindex f9a83f1f29..2448f16e17 100644--- a/app/models/family/auto_categorizer.rb+++ b/app/models/family/auto_categorizer.rb@@ -45,9 +45,8 @@ class Family::AutoCategorizercategory_id,source: "ai")+ transaction.lock_attr!(:category_id)end-- transaction.lock_attr!(:category_id)endenddiff --git a/app/models/family/auto_merchant_detector.rb b/app/models/family/auto_merchant_detector.rbindex 96bfa41449..7831212692 100644--- a/app/models/family/auto_merchant_detector.rb+++ b/app/models/family/auto_merchant_detector.rb@@ -50,11 +50,9 @@ class Family::AutoMerchantDetectormerchant_id,source: "ai")-+ # We lock the attribute so that this Rule doesn't try to run again+ transaction.lock_attr!(:merchant_id)end-- # We lock the attribute so that this Rule doesn't try to run again- transaction.lock_attr!(:merchant_id)endenddiff --git a/app/models/provider/twelve_data.rb b/app/models/provider/twelve_data.rbindex 8f347d9fba..ff46038b44 100644--- a/app/models/provider/twelve_data.rb+++ b/app/models/provider/twelve_data.rb@@ -187,7 +187,7 @@ class Provider::TwelveData < Providersymbol: symbol,date: date.to_date,price: price,- currency: parsed.dig("currency"),+ currency: parsed.dig("meta", "currency") || parsed.dig("currency"),exchange_operating_mic: exchange_operating_mic)end.compactdiff --git a/test/models/family/auto_categorizer_test.rb b/test/models/family/auto_categorizer_test.rbindex c9440919d5..296ac8e936 100644--- a/test/models/family/auto_categorizer_test.rb+++ b/test/models/family/auto_categorizer_test.rb@@ -33,8 +33,9 @@ class Family::AutoCategorizerTest < ActiveSupport::TestCaseassert_equal test_category, txn2.reload.categoryassert_nil txn3.reload.category- # After auto-categorization, all transactions are locked and no longer enrichable- assert_equal 0, @account.transactions.reload.enrichable(:category_id).count+ # After auto-categorization, only successfully categorized transactions are locked+ # txn3 remains enrichable since it didn't get a category (allows retry)+ assert_equal 1, @account.transactions.reload.enrichable(:category_id).countendprivatediff --git a/test/models/family/auto_merchant_detector_test.rb b/test/models/family/auto_merchant_detector_test.rbindex aa4a56be61..296569b1f2 100644--- a/test/models/family/auto_merchant_detector_test.rb+++ b/test/models/family/auto_merchant_detector_test.rb@@ -34,8 +34,9 @@ class Family::AutoMerchantDetectorTest < ActiveSupport::TestCaseassert_equal "https://cdn.brandfetch.io/chipotle.com/icon/fallback/lettermark/w/40/h/40?c=123", txn2.reload.merchant.logo_urlassert_nil txn3.reload.merchant- # After auto-detection, all transactions are locked and no longer enrichable- assert_equal 0, @account.transactions.reload.enrichable(:merchant_id).count+ # After auto-detection, only successfully detected transactions are locked+ # txn3 remains enrichable since it didn't get a merchant (allows retry)+ assert_equal 1, @account.transactions.reload.enrichable(:merchant_id).countendprivate