1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-06 22:15:20 +02:00

Migrate valuations controller to new reconciliation methods

This commit is contained in:
Zach Gollwitzer 2025-07-10 10:31:40 -04:00
parent 25f0c78c47
commit d80cb9f812
19 changed files with 187 additions and 171 deletions

View file

@ -30,6 +30,7 @@ class Account::OverviewFormTest < ActiveSupport::TestCase
)
@account.expects(:update!).with(name: "New Property Name").once
@account.expects(:lock_attr!).with(:name).once
@account.expects(:sync_later).never # Name change should not trigger sync
result = form.save
@ -84,6 +85,7 @@ class Account::OverviewFormTest < ActiveSupport::TestCase
# Simulate a validation error on opening balance update
@account.expects(:update!).with(name: "New Name").once
@account.expects(:lock_attr!).with(:name).once
@account.expects(:set_or_update_opening_balance!).raises(Account::Reconcileable::InvalidBalanceError.new("Cash balance cannot exceed balance"))
@account.expects(:sync_later).never # Should NOT sync if any update fails

View file

@ -6,16 +6,9 @@ class Account::ReconcileableTest < ActiveSupport::TestCase
@family = families(:dylan_family)
end
# Currency updates earn their own method because updating an account currency incurs
# side effects like recalculating balances, etc.
test "can update the account currency" do
@account.update_currency!("EUR")
assert_equal "EUR", @account.currency
assert_equal "EUR", @account.entries.valuations.first.currency
end
# If a user has an opening balance (valuation) for their manual account and has 1+ transactions, the intent of
# Scope: Depository Only
#
# If a user has an opening balance (valuation) for their manual *Depository* account and has 1+ transactions, the intent of
# "updating current balance" typically means that their start balance is incorrect. We follow that user intent
# by default and find the delta required, and update the opening balance so that the timeline reflects this current balance
#