1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-10 07:55:21 +02:00

Use new balance components in activity feed (#2511)

* Balance reconcilations with new components

* Fix materializer and test assumptions

* Fix investment valuation calculations and recon display

* Lint fixes

* Balance series uses new component fields
This commit is contained in:
Zach Gollwitzer 2025-07-23 18:15:14 -04:00 committed by GitHub
parent 3f92fe0f6f
commit f7f6ebb091
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 723 additions and 539 deletions

View file

@ -1,18 +1,15 @@
require "test_helper"
class Account::ReconciliationManagerTest < ActiveSupport::TestCase
include BalanceTestHelper
setup do
@account = accounts(:investment)
@manager = Account::ReconciliationManager.new(@account)
end
test "new reconciliation" do
@account.balances.create!(
date: Date.current,
balance: 1000,
cash_balance: 500,
currency: @account.currency
)
create_balance(account: @account, date: Date.current, balance: 1000, cash_balance: 500)
result = @manager.reconcile_balance(balance: 1200, date: Date.current)
@ -24,7 +21,7 @@ class Account::ReconciliationManagerTest < ActiveSupport::TestCase
end
test "updates existing reconciliation without date change" do
@account.balances.create!(date: Date.current, balance: 1000, cash_balance: 500, currency: @account.currency)
create_balance(account: @account, date: Date.current, balance: 1000, cash_balance: 500)
# Existing reconciliation entry
existing_entry = @account.entries.create!(name: "Test", amount: 1000, date: Date.current, entryable: Valuation.new(kind: "reconciliation"), currency: @account.currency)
@ -39,8 +36,8 @@ class Account::ReconciliationManagerTest < ActiveSupport::TestCase
end
test "updates existing reconciliation with date and amount change" do
@account.balances.create!(date: 5.days.ago, balance: 1000, cash_balance: 500, currency: @account.currency)
@account.balances.create!(date: Date.current, balance: 1200, cash_balance: 700, currency: @account.currency)
create_balance(account: @account, date: 5.days.ago, balance: 1000, cash_balance: 500)
create_balance(account: @account, date: Date.current, balance: 1200, cash_balance: 700)
# Existing reconciliation entry (5 days ago)
existing_entry = @account.entries.create!(name: "Test", amount: 1000, date: 5.days.ago, entryable: Valuation.new(kind: "reconciliation"), currency: @account.currency)
@ -63,12 +60,7 @@ class Account::ReconciliationManagerTest < ActiveSupport::TestCase
end
test "handles date conflicts" do
@account.balances.create!(
date: Date.current,
balance: 1000,
cash_balance: 1000,
currency: @account.currency
)
create_balance(account: @account, date: Date.current, balance: 1000, cash_balance: 1000)
# Existing reconciliation entry
@account.entries.create!(
@ -89,7 +81,7 @@ class Account::ReconciliationManagerTest < ActiveSupport::TestCase
end
test "dry run does not persist account" do
@account.balances.create!(date: Date.current, balance: 1000, cash_balance: 500, currency: @account.currency)
create_balance(account: @account, date: Date.current, balance: 1000, cash_balance: 500)
assert_no_difference "Valuation.count" do
@manager.reconcile_balance(balance: 1200, date: Date.current, dry_run: true)