mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Scaffold out Account Syncing (#474)
* Add trends, time series, seed data * Remove test data * Replace old view values with helpers * Fix tooltip bugs in D3 chart * Fix tests * Fix smoke test * Add CRUD actions for valuations * Scaffold out inline editing with Turbo * Refactor series logic * Scaffold out basic sync process for accounts * Fix tests
This commit is contained in:
parent
b5b2d335fd
commit
7e324f1b53
25 changed files with 328 additions and 185 deletions
|
@ -1,5 +1,20 @@
|
|||
# STI model to represent a point-in-time "valuation" of an account's value
|
||||
# Types include: Appraisal, Adjustment
|
||||
class Valuation < ApplicationRecord
|
||||
belongs_to :account
|
||||
|
||||
after_commit :sync_account_balances, on: [ :create, :update ]
|
||||
after_destroy :sync_account_balances_after_destroy
|
||||
|
||||
def trend(previous)
|
||||
Trend.new(value, previous&.value)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sync_account_balances_after_destroy
|
||||
AccountBalanceSyncJob.perform_later(account_id: account_id, valuation_date: date, sync_type: "valuation", sync_action: "destroy")
|
||||
end
|
||||
|
||||
def sync_account_balances
|
||||
AccountBalanceSyncJob.perform_later(account_id: account_id, valuation_date: date, sync_type: "valuation", sync_action: "update")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue