1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00

perf(transactions): add kind to Transaction model and remove expensive Transfer joins in aggregations (#2388)

* add kind to transaction model

* Basic transfer creator

* Fix method naming conflict

* Creator form pattern

* Remove stale methods

* Tweak migration

* Remove BaseQuery, write entire query in each class for clarity

* Query optimizations

* Remove unused exchange rate query lines

* Remove temporary cache-warming strategy

* Fix test

* Update transaction search

* Decouple transactions endpoint from IncomeStatement

* Clean up transactions controller

* Update cursor rules

* Cleanup comments, logic in search

* Fix totals logic on transactions view

* Fix pagination

* Optimize search totals query

* Default to last 30 days on transactions page if no filters

* Decouple transactions list from transfer details

* Revert transfer route

* Migration reset

* Bundle update

* Fix matching logic, tests

* Remove unused code
This commit is contained in:
Zach Gollwitzer 2025-06-20 13:31:58 -04:00 committed by GitHub
parent 7aca5a2277
commit 1aae00f586
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 1749 additions and 705 deletions

View file

@ -93,36 +93,6 @@ class TransferTest < ActiveSupport::TestCase
assert_equal "Must be from same family", transfer.errors.full_messages.first
end
test "from_accounts converts amounts to the to_account's currency" do
accounts(:depository).update!(currency: "EUR")
eur_account = accounts(:depository).reload
usd_account = accounts(:credit_card)
ExchangeRate.create!(
from_currency: "EUR",
to_currency: "USD",
rate: 1.1,
date: Date.current,
)
transfer = Transfer.from_accounts(
from_account: eur_account,
to_account: usd_account,
date: Date.current,
amount: 500,
)
assert_equal 500, transfer.outflow_transaction.entry.amount
assert_equal "EUR", transfer.outflow_transaction.entry.currency
assert_equal -550, transfer.inflow_transaction.entry.amount
assert_equal "USD", transfer.inflow_transaction.entry.currency
assert_difference -> { Transfer.count } => 1 do
transfer.save!
end
end
test "transaction can only belong to one transfer" do
outflow_entry = create_transaction(date: Date.current, account: accounts(:depository), amount: 500)
inflow_entry1 = create_transaction(date: Date.current, account: accounts(:credit_card), amount: -500)