mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Show UI warning to user when they need provider data but have not setup Synth yet (#1926)
* Simplify provider concerns * Update tests * Add UI warning for missing Synth key if family requires external data
This commit is contained in:
parent
624faa10d0
commit
fa0248056d
22 changed files with 184 additions and 136 deletions
|
@ -1,5 +1,5 @@
|
|||
class Family < ApplicationRecord
|
||||
include Providable, Plaidable, Syncable, AutoTransferMatchable
|
||||
include Synthable, Plaidable, Syncable, AutoTransferMatchable
|
||||
|
||||
DATE_FORMATS = [
|
||||
[ "MM-DD-YYYY", "%m-%d-%Y" ],
|
||||
|
@ -92,22 +92,25 @@ class Family < ApplicationRecord
|
|||
).link_token
|
||||
end
|
||||
|
||||
def synth_usage
|
||||
self.class.synth_provider&.usage
|
||||
end
|
||||
|
||||
def synth_overage?
|
||||
self.class.synth_provider&.usage&.utilization.to_i >= 100
|
||||
end
|
||||
|
||||
def synth_valid?
|
||||
self.class.synth_provider&.healthy?
|
||||
end
|
||||
|
||||
def subscribed?
|
||||
stripe_subscription_status == "active"
|
||||
end
|
||||
|
||||
def requires_data_provider?
|
||||
# If family has any trades, they need a provider for historical prices
|
||||
return true if trades.any?
|
||||
|
||||
# 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?
|
||||
|
||||
# If family has any entries in different currencies, they need a provider for historical exchange rates
|
||||
uniq_currencies = entries.pluck(:currency).uniq
|
||||
return true if uniq_currencies.count > 1
|
||||
return true if uniq_currencies.first != self.currency
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def primary_user
|
||||
users.order(:created_at).first
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue