mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
Add accounts management list (#522)
* Add accounts management * Normalize i18n file * Get turbo streams working * Ignore disabled accounts in calculations * Add empty state
This commit is contained in:
parent
0e77bab00b
commit
ad7136cb63
12 changed files with 164 additions and 25 deletions
|
@ -4,15 +4,15 @@ class Family < ApplicationRecord
|
|||
has_many :transactions, through: :accounts
|
||||
|
||||
def net_worth
|
||||
accounts.sum("CASE WHEN classification = 'asset' THEN balance ELSE -balance END")
|
||||
accounts.active.sum("CASE WHEN classification = 'asset' THEN balance ELSE -balance END")
|
||||
end
|
||||
|
||||
def assets
|
||||
accounts.where(classification: "asset").sum(:balance)
|
||||
accounts.active.where(classification: "asset").sum(:balance)
|
||||
end
|
||||
|
||||
def liabilities
|
||||
accounts.where(classification: "liability").sum(:balance)
|
||||
accounts.active.where(classification: "liability").sum(:balance)
|
||||
end
|
||||
|
||||
def net_worth_series(period = nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue