edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

Balance metadata gives share counts 'credit', the operating cash total 'debit', and leaves 87 of 135 USD us-gaap concepts without a balance

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: main@2323d732 (reports 5.62.0); also compared on v5.62.0 (5068cc54), same output Python Version: 3.14.4 Operating System: Windows 11

Bug Description

What you expected to happen: The balance value of a concept comes from its taxonomy declaration (the xbrli:balance attribute, or crdr in MetaLinks). It is None only when the declaration has no balance, and a non-monetary item never gets one: XBRL 2.1 §5.1.1.2 allows balance only on monetary item types. In the 2025 US-GAAP schema, CostsAndExpenses is monetaryItemType with balance debit, CommonStockSharesOutstanding is sharesItemType with no balance, and NetCashProvidedByUsedInOperatingActivities is monetaryItemType with no balance.

What actually happened: For Comcast's 10-Q (accession 0001628280-26-049360), xbrl.facts.to_dataframe() gives CostsAndExpenses no balance, CommonStockSharesOutstanding 'credit' and NetCashProvidedByUsedInOperatingActivities 'debit'. Of the 135 us-gaap concepts the filing reports in USD, 87 have no balance on any fact.

Imported concepts have balance None in the element catalog (edgar/xbrl/parsers/labels.py lines 152-157). Statement items (xbrl.py lines 1736-1743), the facts DataFrame (facts.py lines 1600-1609) and the balance column of Statement.to_dataframe (statements.py lines 1704-1724) then fall back to get_balance_type (parsers/concepts.py lines 333-382), which reads the hand-written table US_GAAP_BALANCE_TYPES (concepts.py lines 155-331): 124 keys, 117 of them us-gaap. Ten of its keys are not in the 2025 taxonomy (for example Inventory, SalesRevenueNet, CostOfServices). The table gives CommonStockSharesIssued and CommonStockSharesOutstanding 'credit' (lines 227-228) and NetCashProvidedByUsedInOperatingActivities 'debit' (line 309). srt, dei and ecd concepts always get None, and CalculationNode.balance_type (calculation.py line 261) has no fallback at all.

Output on main@2323d732:

us-gaap:CostsAndExpenses -> [nan]
us-gaap:CommonStockSharesOutstanding -> ['credit']
us-gaap:NetCashProvidedByUsedInOperatingActivities -> ['debit']
us-gaap USD concepts: 135 with no balance: 87
get_balance_type('us-gaap:CommonStockSharesOutstanding') = credit

v5.62.0 (5068cc54) prints the same five lines.

Error message (if any):

No exception is raised.

Reproduction

Company/Ticker: CMCSA (Comcast) Time Period: 10-Q, accession 0001628280-26-049360 Relevant Forms: 10-Q

Minimal code to reproduce:

from edgar import set_identity
set_identity("Your Name [email protected]")
from edgar import find
from edgar.xbrl.parsers.concepts import get_balance_type

x = find("0001628280-26-049360").xbrl()
df = x.facts.to_dataframe()
for c in ["us-gaap:CostsAndExpenses", "us-gaap:CommonStockSharesOutstanding",
          "us-gaap:NetCashProvidedByUsedInOperatingActivities"]:
    print(c, "->", sorted(set(df.loc[df["concept"] == c, "balance"].astype(str))))
usd = df[df["concept"].str.startswith("us-gaap:") & (df["unit_ref"].astype(str).str.upper() == "USD")]
by_concept = usd.groupby("concept")["balance"].apply(lambda s: s.notna().any())
print("us-gaap USD concepts:", len(by_concept), "with no balance:", int((~by_concept).sum()))
print("get_balance_type('us-gaap:CommonStockSharesOutstanding') =",
      get_balance_type("us-gaap:CommonStockSharesOutstanding"))

Additional Context

The balance column exists to classify lines by debit and credit (#463). In this filing about two-thirds of the USD us-gaap concepts carry no balance, and share counts get a balance the standard does not allow. EdgarTools itself changes no value, sign or rendering by balance, so the effect is on callers that classify lines by it.

References: the 2025 US-GAAP schema for the three declarations above, and XBRL 2.1 §5.1.1.2 for the rule that balance is optional and applies only to monetary item types. The existing fallback treats an unknown balance and a declared absence the same way, so reading an imported declaration that has no balance would still reach the incorrect table entries.

Related: #1425 (element catalog metadata for standard concepts), #1426 (public accessor for standard-concept metadata), #463 (introduced the balance column).


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:

Financial metadata falls back to an incomplete static balance mapping, presenting guesses as source declarations and conflating unread metadata with declared absence. The demonstrated errors include credits on two share-count concepts and a debit on the operating-cash total; the historical missing-balance count is not a completeness target.

Proposed Behavior:

Use loaded or explicitly supplied source metadata for existing balance outputs, with provenance distinguishing declared values, declared absence and unknown declarations. Correct the four demonstrated helper entries while retaining deliberate access to that compatibility mapping and preserving amounts, calculation weights and display signs. The recommended source-only output reduces non-null coverage; a corrected fallback explicitly labelled unverified remains an alternative for your decision. Imported balances such as CostsAndExpenses remain unknown without source metadata, so this first remedy leaves imported-taxonomy coverage unresolved.

Coordination:

Agree the provenance contract with #1426 and #1730, then keep separate PRs. Automatic metadata loading remains a separate decision; closed #1680 remains a fact-lookup control.

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

Brian

Attachment: design-public.md, Proposal: stop presenting inferred balances as source metadata — #1728.

AI assistance: Codex; GPT-6.1 Sol (High) performed current-main scouting, retained-fixture checks and final writing; GPT-6 Astra (Max) developed the architecture; a separate GPT-6 Astra (Max) reviewed financial source fidelity, balance semantics and the remaining imported-coverage limitation; Claude Opus 5.5 (High) performed adversarial review and independent resolution; GPT-6.1 Sol (High) revised the four-entry correction, consumer coverage and compatibility choice. A separate GPT-6.1 Sol (High) completed focused financial/source and public-text review of the revised proposal.

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

Thanks Brian. I'm splitting this in two. The four wrong entries, the credits on the two share counts and the debit on operating cash, are plain mistakes, so I'll fix those as a bug fix now.

Whether to report only what the filing declares, or keep a fallback marked as unverified, is a bigger call because either way some values become None. I'd rather decide that together with #1426 and #1730, so it moves to 6.x.

dgunning avatar Nov 01 '26 17:11 dgunning