Open-source personal finance manager. Self-hosted, privacy-first.
fix: sort transactions by their converted amount (#1092)
Albert Dolkun055d78a113a6
diff --git a/backend/app/services/transaction_service.py b/backend/app/services/transaction_service.pyindex 933e5d89..ba15cd3e 100644--- a/backend/app/services/transaction_service.py+++ b/backend/app/services/transaction_service.py@@ -482,7 +482,7 @@ async def get_transactions(# would otherwise float old purchases to the top because their# bill due date is in the future."transaction_date": Transaction.date,- "amount": Transaction.amount,+ "amount": func.coalesce(Transaction.amount_primary, Transaction.amount),"description": Transaction.description,"payee": Payee.name,"category": Category.name,diff --git a/backend/tests/test_transaction_service_coverage.py b/backend/tests/test_transaction_service_coverage.pyindex 19f02ade..d5c193e3 100644--- a/backend/tests/test_transaction_service_coverage.py+++ b/backend/tests/test_transaction_service_coverage.py@@ -378,15 +378,20 @@ async def test_get_transactions_user_pnl_only_returns_only_dashboard_reportable_async def test_get_transactions_sorting(session, test_user, test_workspace, acct):- await _mk_txn(session, test_user, acct, description="Aaa", amount=Decimal("30"))- await _mk_txn(session, test_user, acct, description="Zzz", amount=Decimal("10"))+ await _mk_txn(+ session, test_user, acct, description="Aaa",+ amount=Decimal("30"), amount_primary=Decimal("5"),+ )+ await _mk_txn(+ session, test_user, acct, description="Zzz",+ amount=Decimal("10"), amount_primary=Decimal("40"),+ )await _mk_txn(session, test_user, acct, description="Mmm", amount=Decimal("20"))asc, _, _ = await get_transactions(session, test_workspace.id, test_user.id, sort_by="amount", sort_dir="asc")- amts = [t.amount for t in asc]- assert amts == sorted(amts)+ assert [t.description for t in asc] == ["Aaa", "Mmm", "Zzz"]desc, _, _ = await get_transactions(session, test_workspace.id, test_user.id, sort_by="description", sort_dir="desc"