mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 23:59:40 +02:00
Add loan and credit card views (#1268)
* Add loan and credit card views * Lint fix * Clean up overview card markup * Lint fix * Test fix
This commit is contained in:
parent
9263dd3bbe
commit
fd941d714d
34 changed files with 564 additions and 102 deletions
|
@ -82,6 +82,10 @@ class Account < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def original_balance
|
||||
balances.chronological.first&.balance || balance
|
||||
end
|
||||
|
||||
def owns_ticker?(ticker)
|
||||
security_id = Security.find_by(ticker: ticker)&.id
|
||||
entries.account_trades
|
||||
|
@ -93,6 +97,15 @@ class Account < ApplicationRecord
|
|||
classification == "asset" ? "up" : "down"
|
||||
end
|
||||
|
||||
def update_with_sync!(attributes)
|
||||
transaction do
|
||||
update!(attributes)
|
||||
update_balance!(attributes[:balance]) if attributes[:balance]
|
||||
end
|
||||
|
||||
sync_later
|
||||
end
|
||||
|
||||
def update_balance!(balance)
|
||||
valuation = entries.account_valuations.find_by(date: Date.current)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue