mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
16 lines
430 B
Ruby
16 lines
430 B
Ruby
class AccountBalance < ApplicationRecord
|
|
include Monetizable
|
|
|
|
belongs_to :account
|
|
validates :account, :date, :balance, presence: true
|
|
monetize :balance
|
|
|
|
scope :in_period, ->(period) { period.date_range.nil? ? all : where(date: period.date_range) }
|
|
|
|
def self.to_series(account, period = Period.all)
|
|
MoneySeries.new(
|
|
in_period(period).order(:date),
|
|
{ trend_type: account.classification }
|
|
)
|
|
end
|
|
end
|