mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-07 14:35:23 +02:00
Centralize entry naming (#2454)
* Centralize entry naming * Lint fixes, code style
This commit is contained in:
parent
afbfb474c2
commit
9110ab27d2
12 changed files with 187 additions and 16 deletions
|
@ -8,6 +8,13 @@ class Trade < ApplicationRecord
|
|||
validates :qty, presence: true
|
||||
validates :price, :currency, presence: true
|
||||
|
||||
class << self
|
||||
def build_name(type, qty, ticker)
|
||||
prefix = type == "buy" ? "Buy" : "Sell"
|
||||
"#{prefix} #{qty.to_d.abs} shares of #{ticker}"
|
||||
end
|
||||
end
|
||||
|
||||
def unrealized_gain_loss
|
||||
return nil if qty.negative?
|
||||
current_price = security.current_price
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue