Skip to content

Open-source personal finance manager. Self-hosted, privacy-first.

fix(import): show import history totals in the account currency (#1003)

Tássio Noronha77616fb63494
diff --git a/backend/app/api/import_logs.py b/backend/app/api/import_logs.py
index bb96defd..3bf7f290 100644
--- a/backend/app/api/import_logs.py
+++ b/backend/app/api/import_logs.py
@@ -35,6 +35,7 @@ async def list_import_logs(
user_id=log.user_id,
account_id=log.account_id,
account_name=log.account.name if log.account else None,
+ account_currency=log.account.currency if log.account else None,
entity=log.entity,
filename=log.filename,
format=log.format,
diff --git a/backend/app/schemas/import_log.py b/backend/app/schemas/import_log.py
index 777d477b..4ca50468 100644
--- a/backend/app/schemas/import_log.py
+++ b/backend/app/schemas/import_log.py
@@ -12,6 +12,8 @@ class ImportLogRead(BaseModel):
#: Null for an order import, which lands on holdings rather than an account.
account_id: Optional[uuid.UUID] = None
account_name: Optional[str] = None
+ #: Currency of the totals; null when the import has no account.
+ account_currency: Optional[str] = None
#: "transactions" for a bank statement, "asset_orders" for a broker file.
entity: str = "transactions"
filename: str
diff --git a/backend/tests/test_import_api.py b/backend/tests/test_import_api.py
index 335f2436..24db3cd2 100644
--- a/backend/tests/test_import_api.py
+++ b/backend/tests/test_import_api.py
@@ -264,6 +264,46 @@ async def test_list_import_logs(client: AsyncClient, auth_headers, test_account:
assert log["transaction_count"] == 1
+async def test_list_import_logs_returns_account_currency(
+ client: AsyncClient, auth_headers, session: AsyncSession, test_user, test_workspace
+):
+ """Totals are in the account's currency, not the user's display one (#881)."""
+ test_user.preferences = {**(test_user.preferences or {}), "currency_display": "USD"}
+ test_workspace.default_currency = "USD"
+ eur_account = Account(
+ id=uuid.uuid4(),
+ user_id=test_user.id,
+ workspace_id=test_workspace.id,
+ name="Euro Account",
+ type="checking",
+ balance=0,
+ currency="EUR",
+ )
+ session.add(eur_account)
+ await session.commit()
+
+ resp = await client.post(
+ "/api/transactions/import",
+ headers=auth_headers,
+ json={
+ "account_id": str(eur_account.id),
+ "transactions": [
+ {"description": "EUR TXN", "amount": "25.00", "date": "2026-02-20", "type": "debit"},
+ ],
+ "filename": "eur.csv",
+ "detected_format": "csv",
+ },
+ )
+ assert resp.status_code == 201
+
+ logs = (await client.get("/api/import-logs", headers=auth_headers)).json()
+ log = next(entry for entry in logs if entry["filename"] == "eur.csv")
+ assert log["account_currency"] == "EUR"
+ assert log["account_name"] == "Euro Account"
+ assert float(log["total_debit"]) == 25.0
+
+
@pytest.mark.asyncio
async def test_delete_import_log(client: AsyncClient, auth_headers, test_account: Account):
# Create an import
diff --git a/frontend/src/components/import-history.tsx b/frontend/src/components/import-history.tsx
index 9fc92a89..be2eddc9 100644
--- a/frontend/src/components/import-history.tsx
+++ b/frontend/src/components/import-history.tsx
@@ -116,10 +116,10 @@ export function ImportHistory({ entity }: ImportHistoryProps) {
{isStatement && (
<>
<td className="hidden px-4 py-3 text-right font-medium text-emerald-600 sm:table-cell">
- {formatCurrency(log.total_credit, userCurrency, locale)}
+ {formatCurrency(log.total_credit, log.account_currency ?? userCurrency, locale)}
</td>
<td className="hidden px-4 py-3 text-right font-medium text-rose-600 sm:table-cell">
- {formatCurrency(log.total_debit, userCurrency, locale)}
+ {formatCurrency(log.total_debit, log.account_currency ?? userCurrency, locale)}
</td>
</>
)}
diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts
index 0a7693d0..38f49998 100644
--- a/frontend/src/types/index.ts
+++ b/frontend/src/types/index.ts
@@ -549,6 +549,8 @@ export interface ImportLog {
/** Null for an order import, which lands on holdings rather than an account. */
account_id: string | null
account_name: string | null
+ /** Currency of the totals; null when the import has no account. */
+ account_currency: string | null
entity: 'transactions' | 'asset_orders'
filename: string
format: string