mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 21:45:23 +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:
parent
19f15e9391
commit
facd74f733
12 changed files with 156 additions and 40 deletions
|
@ -9,24 +9,8 @@ class Account < ApplicationRecord
|
|||
|
||||
delegated_type :accountable, types: Accountable::TYPES, dependent: :destroy
|
||||
|
||||
delegate :type_name, to: :accountable
|
||||
before_create :check_currency
|
||||
|
||||
def classification
|
||||
classifications = {
|
||||
"Account::Depository" => :asset,
|
||||
"Account::Investment" => :asset,
|
||||
"Account::Property" => :asset,
|
||||
"Account::Vehicle" => :asset,
|
||||
"Account::OtherAsset" => :asset,
|
||||
"Account::Loan" => :liability,
|
||||
"Account::Credit" => :liability,
|
||||
"Account::OtherLiability" => :liability
|
||||
}
|
||||
|
||||
classifications[accountable_type]
|
||||
end
|
||||
|
||||
def balance_series(period)
|
||||
MoneySeries.new(
|
||||
balances.in_period(period).order(:date),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue