mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Basic trade and holdings view (#1271)
* Add trade view * Lint fix * Fix stale placeholder variable * Add holding view
This commit is contained in:
parent
f5cb13b42f
commit
4bfe47540d
25 changed files with 387 additions and 68 deletions
|
@ -37,6 +37,19 @@ class Account::Holding < ApplicationRecord
|
|||
@trend ||= calculate_trend
|
||||
end
|
||||
|
||||
def trades
|
||||
account.entries.where(entryable: account.trades.where(security: security)).reverse_chronological
|
||||
end
|
||||
|
||||
def destroy_holding_and_entries!
|
||||
transaction do
|
||||
account.entries.where(entryable: account.trades.where(security: security)).destroy_all
|
||||
destroy
|
||||
end
|
||||
|
||||
account.sync_later
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def calculate_trend
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue