mirror of
https://github.com/we-promise/sure.git
synced 2026-04-20 12:34:12 +00: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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user