mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-06 22:15:20 +02:00
Additional cache columns on balances for activity view breakdowns (#2505)
* Initial schema iteration * Add new balance components * Add existing data migrator to backfill components * Update calculator test assertions for new balance components * Update flow assertions for forward calculator * Update reverse calculator flows assumptions * Forward calculator tests passing * Get all calculator tests passing * Assert flows factor
This commit is contained in:
parent
347c0a7906
commit
da2045dbd8
13 changed files with 1159 additions and 177 deletions
|
@ -2,8 +2,16 @@ class Balance < ApplicationRecord
|
|||
include Monetizable
|
||||
|
||||
belongs_to :account
|
||||
|
||||
validates :account, :date, :balance, presence: true
|
||||
monetize :balance, :cash_balance
|
||||
validates :flows_factor, inclusion: { in: [ -1, 1 ] }
|
||||
|
||||
monetize :balance, :cash_balance,
|
||||
:start_cash_balance, :start_non_cash_balance, :start_balance,
|
||||
:cash_inflows, :cash_outflows, :non_cash_inflows, :non_cash_outflows, :net_market_flows,
|
||||
:cash_adjustments, :non_cash_adjustments,
|
||||
:end_cash_balance, :end_non_cash_balance, :end_balance
|
||||
|
||||
scope :in_period, ->(period) { period.nil? ? all : where(date: period.date_range) }
|
||||
scope :chronological, -> { order(:date) }
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue