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

Add auto-update strategies for current balance on manual accounts (#2460)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* Add auto-update strategies for current balance on manual accounts

* Remove deprecated BalanceUpdater, replace with new methods
This commit is contained in:
Zach Gollwitzer 2025-07-17 06:49:56 -04:00 committed by GitHub
parent 52333e3fa6
commit 3eea5a9891
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 311 additions and 136 deletions

View file

@ -114,11 +114,6 @@ class Account < ApplicationRecord
.order(amount: :desc)
end
def update_balance(balance:, date: Date.current, currency: nil, notes: nil, existing_valuation_id: nil)
Account::BalanceUpdater.new(self, balance:, currency:, date:, notes:, existing_valuation_id:).update
end
def start_date
first_entry_date = entries.minimum(:date) || Date.current
first_entry_date - 1.day
@ -146,4 +141,23 @@ class Account < ApplicationRecord
def long_subtype_label
accountable_class.long_subtype_label_for(subtype) || accountable_class.display_name
end
# The balance type determines which "component" of balance is being tracked.
# This is primarily used for balance related calculations and updates.
#
# "Cash" = "Liquid"
# "Non-cash" = "Illiquid"
# "Investment" = A mix of both, including brokerage cash (liquid) and holdings (illiquid)
def balance_type
case accountable_type
when "Depository", "CreditCard"
:cash
when "Property", "Vehicle", "OtherAsset", "Loan", "OtherLiability"
:non_cash
when "Investment", "Crypto"
:investment
else
raise "Unknown account type: #{accountable_type}"
end
end
end