1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-20 21:59:38 +02:00
Maybe/app/models/valuation.rb

20 lines
429 B
Ruby
Raw Normal View History

class Valuation < ApplicationRecord
include Monetizable
belongs_to :account
validates :account, :date, :value, presence: true
after_commit :sync_account
monetize :value
scope :in_period, ->(period) { period.date_range.nil? ? all : where(date: period.date_range) }
def self.to_series
TimeSeries.from_collection all, :value_money
end
private
def sync_account
self.account.sync_later
end
end