37 lines
1.5 KiB
Python
37 lines
1.5 KiB
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")
|
|
|
|
|
|
def test_scenario_planned_item_roundtrip(db):
|
|
from app.models.tables import Scenario, ScenarioPlannedItem
|
|
sc = Scenario(name="SPI-Test", description="")
|
|
db.add(sc)
|
|
db.flush()
|
|
db.add(ScenarioPlannedItem(scenario_id=sc.id, name="Einmalzahlung",
|
|
amount=Decimal("5000.00"), due=date(2026, 7, 30)))
|
|
db.commit()
|
|
item = db.query(ScenarioPlannedItem).one()
|
|
assert item.amount == Decimal("5000.00") and item.scenario_id == sc.id
|