mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 13:35:21 +02:00
* Consolidate modal form structure into partial + helper * Scaffold out trade transaction form * Normalize translations * Add buy and sell trade form with tests * Move entryable lists to dedicated controllers * Delegate entry group contents rendering * More cleanup * Extract transaction and valuation update logic from entries controller * Delegate edit and show actions to entryables * Trade builder * Update paths for transaction updates
28 lines
424 B
Ruby
28 lines
424 B
Ruby
class Account::Trade < ApplicationRecord
|
|
include Account::Entryable, Monetizable
|
|
|
|
monetize :price
|
|
|
|
belongs_to :security
|
|
|
|
validates :qty, presence: true, numericality: { other_than: 0 }
|
|
validates :price, :currency, presence: true
|
|
|
|
class << self
|
|
def search(_params)
|
|
all
|
|
end
|
|
|
|
def requires_search?(_params)
|
|
false
|
|
end
|
|
end
|
|
|
|
def sell?
|
|
qty < 0
|
|
end
|
|
|
|
def buy?
|
|
qty > 0
|
|
end
|
|
end
|