mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Add scope to filter transactions from active accounts (#1810)
* Add scope to filter transactions from active accounts * Add test for transfer match candidates with active accounts * Refactor active account filtering for transactions and entries
This commit is contained in:
parent
cf014bc24f
commit
4aba9d1c0b
5 changed files with 69 additions and 1 deletions
|
@ -81,4 +81,27 @@ class Account::EntryTest < ActiveSupport::TestCase
|
|||
assert_equal 200, totals.expense_total
|
||||
assert_equal "USD", totals.currency
|
||||
end
|
||||
|
||||
test "active scope only returns entries from active, non-scheduled-for-deletion accounts" do
|
||||
# Create transactions for all account types
|
||||
active_transaction = create_transaction(account: accounts(:depository), name: "Active transaction")
|
||||
inactive_transaction = create_transaction(account: accounts(:credit_card), name: "Inactive transaction")
|
||||
deletion_transaction = create_transaction(account: accounts(:investment), name: "Scheduled for deletion transaction")
|
||||
|
||||
# Update account statuses
|
||||
accounts(:credit_card).update!(is_active: false)
|
||||
accounts(:investment).update!(scheduled_for_deletion: true)
|
||||
|
||||
# Test the scope
|
||||
active_entries = Account::Entry.active
|
||||
|
||||
# Should include entry from active account
|
||||
assert_includes active_entries, active_transaction
|
||||
|
||||
# Should not include entry from inactive account
|
||||
assert_not_includes active_entries, inactive_transaction
|
||||
|
||||
# Should not include entry from account scheduled for deletion
|
||||
assert_not_includes active_entries, deletion_transaction
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue