mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 03:33:55 +02:00
update data based on selected company (#122)
Added UI elements to select a company and update shown data depending on chosen company --------- Co-authored-by: Philipp Horstenkamp <philipp@horstenkamp.de>
This commit is contained in:
@ -3,6 +3,7 @@ import datetime
|
||||
import os
|
||||
from collections.abc import Generator
|
||||
from inspect import getmembers, isfunction
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from sqlalchemy.engine import Engine
|
||||
@ -49,7 +50,60 @@ def empty_db() -> Generator[Session, None, None]:
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def full_db(empty_db: Session) -> Session:
|
||||
def finance_statements() -> list[dict[str, Any]]:
|
||||
"""Creates a list of finance statements."""
|
||||
return [
|
||||
{
|
||||
"id": 1,
|
||||
"company_id": 1,
|
||||
"date": datetime.date.fromisoformat("2023-01-01"),
|
||||
"total_volume": 1000.0,
|
||||
"ebit": 1000.0,
|
||||
"ebitda": 1000.0,
|
||||
"ebit_margin": 1000.0,
|
||||
"total_balance": 1000.0,
|
||||
"equity": 1000.0,
|
||||
"debt": 1000.0,
|
||||
"return_on_equity": 1000.0,
|
||||
"capital_turnover_rate": 1000.0,
|
||||
"current_liabilities": 1000.0,
|
||||
"dividends": float("NaN"),
|
||||
"net_income": float("NaN"),
|
||||
"assets": 1000.0,
|
||||
"long_term_debt": 1000.0,
|
||||
"short_term_debt": 1000.0,
|
||||
"revenue": 1000.0,
|
||||
"cash_flow": 1000.0,
|
||||
"current_assets": 1000.0,
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"company_id": 1,
|
||||
"date": datetime.date.fromisoformat("2022-01-01"),
|
||||
"total_volume": 1100.0,
|
||||
"ebit": 1100.0,
|
||||
"ebitda": 1100.0,
|
||||
"ebit_margin": 1100.0,
|
||||
"total_balance": 1100.0,
|
||||
"equity": 1100.0,
|
||||
"debt": 1100.0,
|
||||
"return_on_equity": 1100.0,
|
||||
"capital_turnover_rate": 1100.0,
|
||||
"current_liabilities": 1100.0,
|
||||
"dividends": float("NaN"),
|
||||
"net_income": float("NaN"),
|
||||
"assets": 1100.0,
|
||||
"long_term_debt": 1100.0,
|
||||
"short_term_debt": 1100.0,
|
||||
"revenue": 1100.0,
|
||||
"cash_flow": 1100.0,
|
||||
"current_assets": 1100.0,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def full_db(empty_db: Session, finance_statements: list[dict[str, Any]]) -> Session:
|
||||
"""Fills a db with some test data."""
|
||||
empty_db.add_all(
|
||||
[
|
||||
@ -112,5 +166,13 @@ def full_db(empty_db: Session) -> Session:
|
||||
]
|
||||
)
|
||||
empty_db.commit()
|
||||
|
||||
empty_db.add_all(
|
||||
[
|
||||
entities.AnnualFinanceStatement(**finance_statement)
|
||||
for finance_statement in finance_statements
|
||||
]
|
||||
)
|
||||
empty_db.commit()
|
||||
# print(pd.read_sql_table("company", empty_db.bind).to_string())
|
||||
return empty_db
|
||||
|
Reference in New Issue
Block a user