Skip to content

Commit

Permalink
Add the financials repr to the tenk repr
Browse files Browse the repository at this point in the history
  • Loading branch information
dgunning committed Nov 12, 2024
1 parent 906ed9d commit 0a5e0ea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
18 changes: 11 additions & 7 deletions edgar/company_reports.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
from datetime import datetime
from functools import lru_cache, partial
from typing import Dict, List
from rich.table import Table

from rich import box
from rich import print
from rich.console import Group, Text
from rich.panel import Panel
from rich.tree import Tree
from edgar.core import datefmt
from rich.padding import Padding

from edgar._filings import Attachments, Attachment
from edgar._markdown import MarkdownContent
from edgar.richtools import repr_rich
from edgar.core import datefmt
from edgar.documents import HtmlDocument
from edgar.financials import Financials
from edgar.htmltools import ChunkedDocument, chunks2df, detect_decimal_items, adjust_for_empty_items
from edgar.richtools import repr_rich

__all__ = [
'TenK',
Expand All @@ -26,7 +28,6 @@
]



class CompanyReport:

def __init__(self, filing):
Expand Down Expand Up @@ -300,16 +301,19 @@ def __rich__(self):
(f"{self.form}", "bold"),
)
periods = Text.assemble(
(f"Period ending ", ""),
(f"Period ending ", "grey70"),
(f"{datefmt(self.period_of_report, '%B %d, %Y')}", "bold"),
(f" filed on ", ""),
(" filed on ", "grey70"),
(f"{datefmt(self.filing_date, '%B %d, %Y')}", "bold"),

)
panel = Panel(
Group(
periods,
self.get_structure()
Padding(" ", (1, 0, 0, 0)),
self.get_structure(),
Padding(" ", (1, 0, 0, 0)),
self.financials or Text("No financial data available", style="italic")
),
title=title,
box=box.ROUNDED,
Expand Down
26 changes: 13 additions & 13 deletions edgar/financials.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rich.text import Text
import asyncio

from edgar.core import run_async_or_sync
from edgar.core import run_async_or_sync, datefmt
from edgar.richtools import repr_rich
from edgar.xbrl.presentation import FinancialStatementMapper, XBRLPresentation
from edgar.xbrl.xbrldata import XBRLData, Statement
Expand Down Expand Up @@ -408,19 +408,19 @@ def compare_statement_dimensions(self, statement_name: str, dimension: str, valu
return self.xbrl_data.compare_dimension_values(statement_name, dimension, value1, value2)

def __rich__(self):
statements_table = Table(Column(""), Column("Standard Financial Statements", justify="left"),
box=box.ROUNDED, show_header=True)
title = Text.assemble((self.xbrl_data.company, "bold deep_sky_blue1"),
" Financials"
)
subtitle = Text.assemble(("Period ending ", "grey70"), (f"{datefmt(self.xbrl_data.period_end, '%B %d, %Y')}", "bold"))
statements_table = Table(Column(""), Column("Standard Financial Statements",
justify="left"),
box=box.ROUNDED,
show_header=False,
title=title,
caption=subtitle)
for index, statement in enumerate(self.list_standard_statements()):
statements_table.add_row(str(index + 1), statement)

contents = [statements_table]

panel = Panel(
Group(*contents),
title=Text.assemble((self.xbrl_data.company, "bold deep_sky_blue1"), " financials",
(f" period ended {self.xbrl_data.period_end}", "bold green")),
)
return panel
statements_table.add_row(str(index + 1), Text(statement, style="bold"))
return statements_table

def __repr__(self):
return repr_rich(self.__rich__())
Expand Down

0 comments on commit 0a5e0ea

Please sign in to comment.