edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

Rendered statements scale and format tax rates, share counts and per-share values as money unless the concept is in two built-in lists

Open synfonia-llc opened this issue 1 month ago • 2 comments

Issue Type

  • [ ] Data Quality Issue (incorrect financial values, missing data)
  • [x] XBRL Parsing Issue (statement rendering, concept mapping)
  • [ ] Filing Access Issue (download failures, attachment problems)
  • [ ] Performance Issue (slow operations, memory problems)
  • [ ] Compatibility Issue (platform/dependency conflicts)
  • [ ] Documentation Issue (unclear instructions, missing examples)

Environment

EdgarTools Version: 5.62.0 (main at commit 2323d732 reports 5.62.0; the v5.62.0 tag at commit 5068cc54 gives the same rendered output) Python Version: 3.14 Operating System: Windows 11

Bug Description

What you expected to happen: Display follows the element's item type, or at least the fact's unit: monetary amounts take the statement's money scale and currency symbol, share counts take a share scale and no currency symbol, and per-share, pure and percent values are not scaled. Rates are shown as filed, not multiplied by 100 (XBRL 2.1 section 4.8.2, Table 3; Data Type Registry percentItemType and perShareItemType).

What actually happened: On Apple's FY2023 10-K (the repository fixture tests/fixtures/xbrl/aapl/10k_2023), the income-tax reconciliation renders the effective tax rate as 0.00 for all three years (filed 0.147, 0.162 and 0.133, unit number, decimals 3), and the EPS computation renders "Effect of dilutive share-based awards" as 68.32, 109.86 and 163.65 between unscaled share counts (filed 68,316,000, 109,856,000 and 163,647,000, unit shares, decimals -3; fact f-413 for FY2023).

The renderer hard-codes 9 share concepts and 13 EPS concepts (share_concepts and eps_concepts, edgar/xbrl/rendering.py lines 833-859) and classifies a value by those two lists, or by whether its label contains 'ratio', 'percentage' or 'per cent' (_format_value_for_display_as_string, lines 1443-1462). Every other value on a balance sheet, income statement or cash flow statement goes through core.format_value (edgar/xbrl/core.py line 382), which divides by the statement's monetary scale (lines 401-408) and adds the currency symbol. The scale itself is chosen by label keywords (core.py lines 241-249). The formatter does not read the element's item type or the fact's unit, although each row carries its units per period. The label test is a substring test, so a monetary row labelled "Income from operations" loses its currency symbol because "operations" contains "ratio".

The DataFrame values are correct; only the rendered statement and its text output are affected.

Error message (if any):

N/A: no error is raised. The rendered values are wrong.

Reproduction

Company/Ticker: Apple Inc. (AAPL), repository fixture tests/fixtures/xbrl/aapl/10k_2023 Time Period: FY2023, FY2022, FY2021 (10-K for the year ended 2023-09-30) Relevant Forms: 10-K

Minimal code to reproduce:

# Run from the root of a clone of the repository (the fixture path is relative).
from edgar import set_identity
from edgar.xbrl import XBRL
from edgar.xbrl import rendering

set_identity("Your Name [email protected]")

x = XBRL.from_directory("tests/fixtures/xbrl/aapl/10k_2023")
roles = [
    "http://www.apple.com/role/IncomeTaxesReconciliationofProvisionforIncomeTaxestoAmountComputedbyApplyingtheStatutoryFederalIncomeTaxRatetoIncomeBeforeProvisionforIncomeTaxesDetails",
    "http://www.apple.com/role/EarningsPerShareComputationofBasicandDilutedEarningsPerShareDetails",
]
for role in roles:
    for line in str(x.render_statement(role)).splitlines():
        if any(k in line for k in ("Effective tax rate", "Weighted-average", "dilutive")):
            print(line.rstrip())

# The formatter on a monetary statement in millions with a dollar symbol
cases = [
    ("us-gaap_EffectiveIncomeTaxRateContinuingOperations", "Effective tax rate", 0.213),
    ("us-gaap_IncomeLossFromContinuingOperationsPerBasicAndDilutedShare", "Loss per share", -0.37),
    ("us-gaap_WeightedAverageNumberOfShareOutstandingBasicAndDiluted", "Weighted average shares", 150000000),
    ("us-gaap_OperatingIncomeLoss", "Income from operations", 5000000000),
]
for concept, label, value in cases:
    item = {"concept": concept, "label": label, "decimals": {"p": -3}}
    print(label, value, "->", repr(rendering._format_value_for_display_as_string(
        value, item, "p", True, -6, None, None, "$")))

Additional Context

Output observed on main at commit 2323d732 (the rendered lines are identical on v5.62.0 at commit 5068cc54):

      Effective tax rate                                      0.00           0.00           0.00
          Weighted-average basic shares outstanding (in shares)     15,744,231     16,215,963     16,701,272
          Effect of dilutive share-based awards (in shares)              68.32         109.86         163.65
        Weighted-average diluted shares (in shares)                 15,812,547     16,325,819     16,864,919
Effective tax rate 0.213 -> '$0.00'
Loss per share -0.37 -> '$(0.00)'
Weighted average shares 150000000 -> '$150.00'
Income from operations 5000000000 -> '5,000.00'

The filed values were read from the fixture's instance document aapl-20230930_htm.xml: us-gaap:EffectiveIncomeTaxRateContinuingOperations 0.147 / 0.162 / 0.133 (unitRef="number", decimals="3") and us-gaap:IncrementalCommonSharesAttributableToShareBasedPaymentArrangements 68316000 / 109856000 / 163647000 (unitRef="shares", decimals="-3").

edgar/xbrl/viewer_validation.py (around lines 401-410) already scales by type, so the same approach may apply to the renderer. Since the units are already on each row, most cases can be fixed without loading the imported taxonomy.


This issue will be handled using EdgarTools' systematic issue resolution workflow. A reproduction test will be created to verify the fix.

synfonia-llc avatar Oct 22 '26 15:10 synfonia-llc

@dgunning, here is our current thinking on the root cause, proposed behavior, and coordination with other issues.

Root Cause:

Statement formatting relies on concept lists, label words and the statement's monetary scale instead of each selected cell's complete unit. This can round a tax-rate fraction to zero or display scaled shares beneath an actual-shares caption.

Proposed Behavior:

Format each selected cell from its complete unit and available accuracy, keeping monetary scale, share scale, per-share values and dimensionless values separate. Preserve source-basis rates such as Apple's 0.147, and show unknown units explicitly without guessing dollars. Keep the selected amount, source period, unit, accuracy and presentation sign together. Selected zero remains zero in source fields and keeps today's blank display, as unavailable cells do; the direct helper's U+0014 defect and a shared visible-zero choice remain separate work.

Coordination:

I recommend a separate PR after agreeing #1747's shared descriptor/classifier and #1746's label contract, resolving #1793's unit-design hold. Coordinate #1655's selected-cell binding independently, and keep unit display separate from the proposed exact scale/sign, retained-input and raw-precision PR.

Below, please find the full design document. Please let me know your thoughts.

Brian

Attachment: design-public.md, Format statement values by their measurement units — proposal for #1737.

AI assistance: Codex; GPT-6.1 Sol (High) performed current-main scouting, source verification, final writing, author revisions and dedicated focused financial review; GPT-6 Astra (Max) developed the architecture and performed the earlier independent financial-statement review; Claude Opus 5.5 (High) performed adversarial review and independent resolution.

synfonia-llc avatar Oct 27 '26 11:10 synfonia-llc

Thanks Brian. This only changes how statements display, not what the API returns, so it doesn't need a major release. I'll do it in 6.x once #1747 and #1746 are settled, since the formatting depends on both.

dgunning avatar Nov 01 '26 17:11 dgunning