mirror of
https://github.com/we-promise/sure.git
synced 2026-04-18 19:44:09 +00:00
* Add classification generated column to account * Add basic net worth calculation * Add net worth tests * Fix lint errors
19 lines
440 B
Ruby
19 lines
440 B
Ruby
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
|