25 lines
1017 B
Python
25 lines
1017 B
Python
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")
|