1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00
Maybe/app/models/account_balance.rb
Zach Gollwitzer fe2fa0eac1
Multi-currency support: Money + Currency class improvements (#553)
* Money improvements

* Replace all old money usage
2024-03-18 11:21:00 -04:00

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