Add Live Data to Account Page #464

Merged
zachgoll merged 10 commits from account-page-live-data into main 2024-02-20 22:07:55 +08:00
zachgoll commented 2024-02-17 21:52:10 +08:00 (Migrated from github.com)

This PR addresses the following:

  • Add seed data for account_balances and valuations tables
  • Hook up live data to D3 chart and valuations table
  • Add Trend model and helpers for time series trend calculations
  • Add CRUD for valuations in UI
  • Inline editing with Turbo

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:

  1. Appraisal - most common, and represents an "updated" value of an asset or debt
  2. 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.

This PR addresses the following: - [x] Add seed data for `account_balances` and `valuations` 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 ## 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: 1. `Appraisal` - most common, and represents an "updated" value of an asset or debt 2. `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.
Sign in to join this conversation.