Files
certain/backend/tests/test_transactions_offen.py
T
GuidoandClaude Opus 5 6390f7c325 feat: Seite "Buchungen ohne Kategorie" zum Abarbeiten
Bisher musste man in der Gesamtliste nach Luecken suchen. Der Endpunkt
kennt jetzt ?uncategorized=true; Uebertraege bleiben aussen vor, denn sie
ordnen kein Geld ein, sie verschieben es nur.

Die Seite zeigt die offenen Buchungen aelteste zuerst; nach dem Zuordnen
verschwindet die Zeile, sodass der Stapel sichtbar kleiner wird. Auf Wunsch
wird der Zweck gleich als Schlagwort gemerkt, damit die naechste gleiche
Buchung schon beim Import zugeordnet wird.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 20:40:52 +02:00

49 lines
2.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import io
import json
def _konto(admin, **kw):
body = {"name": "Giro", "type": "girokonto", "currency": "EUR", "opening_balance_cents": 0}
body.update(kw)
return admin.post("/api/accounts", json=body).json()
def _kategorie(admin):
for g in admin.get("/api/categories").json():
for c in g["categories"]:
if c["name"] == "Lebensmittel":
return c["id"]
raise AssertionError("Lebensmittel fehlt")
def test_offene_buchungen_listet_nur_unkategorisierte(admin):
"""Zum Abarbeiten braucht man die Buchungen ohne Kategorie – und zwar nur die."""
konto = _konto(admin, name="Abarbeiten")
kat = _kategorie(admin)
admin.post("/api/transactions", json={"type": "expense", "date": "2026-04-01",
"account_id": konto["id"], "amount_cents": 1000,
"payee": "Ohne Kategorie"})
admin.post("/api/transactions", json={"type": "expense", "date": "2026-04-02",
"account_id": konto["id"], "amount_cents": 2000,
"payee": "Mit Kategorie", "category_id": kat})
admin.post("/api/transactions", json={"type": "income", "date": "2026-04-03",
"account_id": konto["id"], "amount_cents": 3000,
"payee": "Einnahme ohne Kategorie"})
offen = admin.get("/api/transactions", params={"uncategorized": "true",
"account_id": konto["id"]}).json()
namen = sorted(t["payee"] for t in offen)
assert namen == ["Einnahme ohne Kategorie", "Ohne Kategorie"]
def test_offene_buchungen_lassen_uebertraege_aus(admin):
"""Ein Übertrag ordnet kein Geld ein, er verschiebt es – er gehört nicht auf die Liste."""
a = _konto(admin, name="Von")
b = _konto(admin, name="Nach")
admin.post("/api/transactions", json={"type": "transfer", "date": "2026-04-04",
"account_id": a["id"], "to_account_id": b["id"],
"amount_cents": 5000})
offen = admin.get("/api/transactions", params={"uncategorized": "true",
"account_id": a["id"]}).json()
assert offen == []