Open-source personal finance manager. Self-hosted, privacy-first.
fix: allow removing category from transactions
Tássio Noronha4dc7c666d63c
diff --git a/backend/tests/test_transactions_api.py b/backend/tests/test_transactions_api.pyindex 286e7373..13b393fe 100644--- a/backend/tests/test_transactions_api.py+++ b/backend/tests/test_transactions_api.py@@ -177,6 +177,30 @@ async def test_update_transaction(assert data["category_id"] == str(test_categories[0].id)+async def test_update_transaction_remove_category(+ client: AsyncClient, auth_headers, test_transactions: list[Transaction],+ test_categories: list[Category],+):+ """Setting category_id to null must clear an existing category."""+ txn_id = str(test_transactions[1].id) # IFOOD — has category (Alimentação)+ assert test_transactions[1].category_id is not None++ response = await client.patch(+ f"/api/transactions/{txn_id}",+ headers=auth_headers,+ json={"category_id": None},+ )+ assert response.status_code == 200+ data = response.json()+ assert data["category_id"] is None++ # Verify the change persisted+ response = await client.get(f"/api/transactions/{txn_id}", headers=auth_headers)+ assert response.status_code == 200+ assert response.json()["category_id"] is None++@pytest.mark.asyncioasync def test_update_transaction_date(client: AsyncClient, auth_headers, test_transactions: list[Transaction],diff --git a/frontend/src/components/transaction-dialog.tsx b/frontend/src/components/transaction-dialog.tsxindex d1faf87b..776b9951 100644--- a/frontend/src/components/transaction-dialog.tsx+++ b/frontend/src/components/transaction-dialog.tsx@@ -198,7 +198,7 @@ function TransactionForm({}const txData = isSynced? {- category_id: categoryId || undefined,+ category_id: categoryId || null,notes: notes.trim() || undefined,} as Partial<Transaction>: {@@ -207,7 +207,7 @@ function TransactionForm({date,type,currency,- category_id: categoryId || undefined,+ category_id: categoryId || null,account_id: accountId || undefined,notes: notes.trim() || undefined,...fxFields,