1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Multi-currency support: Money + Currency class improvements (#553)

* Money improvements

* Replace all old money usage
This commit is contained in:
Zach Gollwitzer 2024-03-18 11:21:00 -04:00 committed by GitHub
parent e5750d1a13
commit fe2fa0eac1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
43 changed files with 2982 additions and 196 deletions

View file

@ -1,9 +1,13 @@
class Family < ApplicationRecord
include Monetizable
has_many :users, dependent: :destroy
has_many :accounts, dependent: :destroy
has_many :transactions, through: :accounts
has_many :transaction_categories, dependent: :destroy, class_name: "Transaction::Category"
monetize :net_worth, :assets, :liabilities
def snapshot(period = Period.all)
query = accounts.active.joins(:balances)
.where("account_balances.currency = ?", self.currency)
@ -35,7 +39,7 @@ class Family < ApplicationRecord
end
def assets
accounts.active.assets.sum(:balance)
accounts.active.assets.sum(:balance)
end
def liabilities