feat: Datenmodell (SQLAlchemy) und Alembic-Migration
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
24
finance/tests/test_models.py
Normal file
24
finance/tests/test_models.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
from app.models.tables import Account, Statement, Transaction
|
||||
|
||||
|
||||
def test_account_transaction_roundtrip(db):
|
||||
acc = Account(bank="DKB", iban="DE02120300000000202051", name="Giro", type="giro")
|
||||
db.add(acc)
|
||||
db.flush()
|
||||
st = Statement(filename="a.pdf", bank="DKB", account_id=acc.id,
|
||||
period_start=date(2026, 6, 1), period_end=date(2026, 6, 30),
|
||||
opening_balance=Decimal("100.00"), closing_balance=Decimal("50.00"),
|
||||
status="draft")
|
||||
db.add(st)
|
||||
db.flush()
|
||||
tx = Transaction(account_id=acc.id, statement_id=st.id,
|
||||
booking_date=date(2026, 6, 3), value_date=date(2026, 6, 3),
|
||||
amount=Decimal("-50.00"), purpose="Miete Juni",
|
||||
counterparty="Vermieter GmbH", status="draft",
|
||||
dedup_hash="abc", is_duplicate=False)
|
||||
db.add(tx)
|
||||
db.commit()
|
||||
assert db.query(Transaction).one().amount == Decimal("-50.00")
|
||||
Reference in New Issue
Block a user