1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-05 13:35:21 +02:00

Net worth calculation (#508)

* Add classification generated column to account

* Add basic net worth calculation

* Add net worth tests

* Fix lint errors
This commit is contained in:
Zach Gollwitzer 2024-03-04 08:31:22 -05:00 committed by GitHub
parent 19f15e9391
commit facd74f733
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 156 additions and 40 deletions

View file

@ -0,0 +1,18 @@
class AddClassificationToAccounts < ActiveRecord::Migration[7.2]
def change
change_table :accounts do |t|
t.virtual(
:classification,
type: :string,
stored: true,
as: <<-SQL
CASE
WHEN accountable_type IN ('Account::Loan', 'Account::Credit', 'Account::OtherLiability')
THEN 'liability'
ELSE 'asset'
END
SQL
)
end
end
end