mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-06 14:05:20 +02:00
Migrate valuations controller to new reconciliation methods
This commit is contained in:
parent
25f0c78c47
commit
d80cb9f812
19 changed files with 187 additions and 171 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
#
|
||||
|
|
|
@ -31,4 +31,13 @@ class AccountTest < ActiveSupport::TestCase
|
|||
assert_equal "Investments", account.short_subtype_label
|
||||
assert_equal "Investments", account.long_subtype_label
|
||||
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
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue