mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-10 16:05:22 +02:00
Clean up account creational methods
This commit is contained in:
parent
a7cd046563
commit
3b6a5a573f
6 changed files with 313 additions and 135 deletions
|
@ -128,6 +128,15 @@ class Account < ApplicationRecord
|
|||
Account::BalanceUpdater.new(self, balance:, currency:, date:, notes:).update
|
||||
end
|
||||
|
||||
def update_currency!(new_currency)
|
||||
raise "Currency cannot be changed" if linked?
|
||||
|
||||
transaction do
|
||||
update!(currency: new_currency)
|
||||
entries.valuations.update_all(currency: new_currency)
|
||||
end
|
||||
end
|
||||
|
||||
def update_current_balance(balance:, cash_balance:)
|
||||
raise InvalidBalanceError, "Cash balance cannot exceed balance" if cash_balance > balance
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue