feat: split provider check and remove hardcoded synth check (#45)

This commit is contained in:
Vincent Teo
2025-08-01 16:07:34 +10:00
committed by GitHub
parent 66a87c852c
commit d04c87449d
2 changed files with 8 additions and 5 deletions

View File

@@ -69,10 +69,12 @@ class Family < ApplicationRecord
country != "US" && country != "CA"
end
def requires_data_provider?
def requires_securities_data_provider?
# If family has any trades, they need a provider for historical prices
return true if trades.any?
trades.any?
end
def requires_exchange_rates_data_provider?
# If family has any accounts not denominated in the family's currency, they need a provider for historical exchange rates
return true if accounts.where.not(currency: self.currency).any?
@@ -85,7 +87,8 @@ class Family < ApplicationRecord
end
def missing_data_provider?
requires_data_provider? && Provider::Registry.get_provider(:synth).nil?
(requires_securities_data_provider? && Security.provider.nil?) ||
(requires_exchange_rates_data_provider? && ExchangeRate.provider.nil?)
end
def oldest_entry_date

View File

@@ -12,10 +12,10 @@
<%= icon("chevron-down", color: "warning", class: "group-open:transform group-open:rotate-180") %>
</summary>
<div class="text-xs py-2 space-y-2">
<p>Maybe uses Synth API to fetch historical exchange rates, security prices, and more. This data is required to calculate accurate historical account balances.</p>
<p>Sure uses third party providers to fetch historical exchange rates, security prices, and more. This data is required to calculate accurate historical account balances.</p>
<p>
<%= link_to "Add your Synth API key here.", settings_hosting_path, class: "text-yellow-600 underline" %>
<%= link_to "Configure your providers here.", settings_hosting_path, class: "text-yellow-600 underline" %>
</p>
</div>
</details>