maybe
maybe copied to clipboard
Add Live Data to Account Page
This PR addresses the following:
- [x] Add seed data for
account_balances
andvaluations
tables - [x] Hook up live data to D3 chart and valuations table
- [x] Add
Trend
model and helpers for time series trend calculations - [x] Add CRUD for
valuations
in UI - [x] Inline editing with Turbo
- [ ] Background job to sync daily balances to
account_balances
table
Notes
This is a rough sketch of the system. Plenty of refactoring to be done in the future.
What is Valuation
for?
A Valuation
represents a "point-in-time" value assignment for an Account
. This is an STI table of two types:
-
Appraisal
- most common, and represents an "updated" value of an asset or debt -
Adjustment
- less common, used as a manual adjustment of account value (user overrides for missing txns)
What is AccountBalance
for?
This is a "cache table" that stores daily account balances.
It is a function of Valuation
and Transaction
(not created yet). By replaying the history of Valuation
and Transaction
records starting at the current balance of an account and working backwards, we can construct daily balances for an account that can be displayed in a time series chart.
This table requires a trigger and sync mechanism. Every time a Valuation
or Transaction
or bulk update happens on an Account
, a sync is triggered which updates AccountBalance
. Furthermore, a daily sync or client-side locf (last observation carried forward) will be required to keep balances up-to-date with the latest value of the account.