Visualize financials (#206)

Adds the financial graph to the company page. The graph is only
available for companies with existing financial data.
This commit is contained in:
KM-R
2023-10-14 17:08:34 +02:00
committed by GitHub
parent c8d3c7395b
commit 9f7d714403
10 changed files with 723 additions and 250 deletions

View File

@ -21,18 +21,4 @@ def test_create_company_stats(full_db: Session) -> None:
def test_create_tabs(full_db: Session) -> None:
"""Checks if the tabs of the company page can be created."""
selected_company_id = 1
finance_df = data_elements.get_finance_data(full_db)
selected_finance_df = finance_df.loc[
finance_df["company_id"] == selected_company_id
]
company_elements.create_tabs(selected_company_id, selected_finance_df)
def test_kennzahlen_layout(full_db: Session) -> None:
"""Checks if the financial metric layout of the company page can be created."""
selected_company_id = 1
finance_df = data_elements.get_finance_data(full_db)
selected_finance_df = finance_df.loc[
finance_df["company_id"] == selected_company_id
]
company_elements.kennzahlen_layout(selected_finance_df)
company_elements.create_tabs(full_db, selected_company_id)

View File

@ -0,0 +1,39 @@
"""Tests for finance ui elements."""
import pandas as pd
from sqlalchemy.orm import Session
from aki_prj23_transparenzregister.models.company import FinancialKPIEnum
from aki_prj23_transparenzregister.ui import data_elements, finance_elements
def test_financial_metrics_layout(full_db: Session) -> None:
"""Checks if the financial metric layout of the company page can be created."""
selected_company_id = 1
finance_elements.financial_metrics_layout(full_db, selected_company_id)
def test_complete_metrics() -> None:
"""Tests if names for all the FinancialKPIEnum are there."""
assert set(finance_elements.METRICS.keys()).issubset(
{_.value for _ in FinancialKPIEnum}
)
def test_update_figure(full_db: Session) -> None:
"""Checks if the output after choosing a metric can be updated."""
company_id = 1
value = "equity"
data = data_elements.get_finance_data_of_one_company(full_db, company_id).to_json(
date_format="iso"
)
finance_elements.update_figure(value, data)
def test_finance_figure(full_db: Session) -> None:
"""Checks if the financial graph can be created."""
company_id = 1
metric = "equity"
data = data_elements.get_finance_data_of_one_company(full_db, company_id)
selected_finance_df = pd.DataFrame(data)
finance_elements.financials_figure(selected_finance_df, metric)