edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

Depreciation expense missing in Cash Flow statement (TSLA)

Open gafzan opened this issue 1 year ago • 5 comments

First want to say how an amazing library this is!

One issue I have is that depreciation & amortization expense seems to be missing from the Cash Flow statement when it should be there. Is it becuase there is code not looking for this item since it assumes (incorrectly) that it should always be in Income Statement?

Here is TSLA as an example (I have same issue with GM and MSFT just to name a few)

(Cash Flow TSLA 10-Q March 31, 2025 - Accession number: 0001628280-25-018911)

Image

You can use the below code to look at all the concept and labels for this cash flow statement. There is no row for depreciation & amortization expense even though it should be included.

"""no_depreciation_expense.py"""

import os

from edgar import XBRL, Company, set_identity

my_email = os.environ.get('MY_EMAIL')  # Just replace this with your identifier

set_identity(my_email)

ticker = 'tsla'
accession_no = '0001628280-25-018911'  # TSLA 10-Q March 31, 2025
company = Company(ticker)
filing = company.get_filings().filter(accession_number=accession_no).latest(1)  # Get latest 10-Q report
xbrl = XBRL.from_filing(filing=filing)  # XBRL data for the given filing
cf_df = xbrl.statements.cashflow_statement().to_dataframe(standard=False)  # Cash flow statement DataFrame

for index, row in cf_df.iterrows():
    concept = row['concept']
    label = row['label']
    print(f"Concept: {concept} | Label: {label}")

As can be seen below, depreciation, amortization and impariment expense is missing

Image

gafzan avatar Jun 19 '25 09:06 gafzan

The library does not currently handle custom concepts e.g. tsla:DepreciationAmortizationAndImpairment. I will take a look at adding this.

filing = Filing(form='10-Q',
                    filing_date='2025-04-23',
                    company='Tesla, Inc.',
                    cik=1318605,
                    accession_no='0001628280-25-018911')
    xb = XBRL.from_filing(filing)
    facts = (xb.query().by_text('Depreciation')
             .to_dataframe('concept', 'label', 'value', 'statement_type')
             )
    print(facts)

Image

dgunning avatar Jun 20 '25 15:06 dgunning

Thanks @dgunning! That explains why I could not find any debt on the balance sheet for the same report. That concept also has the 'ticker:' prefix (see first screenshot below). Appreciate you looking into this :)

Image

(Balance Sheet TSLA 10-Q March 31, 2025 - Accession number: 0001628280-25-018911)

Image

gafzan avatar Jun 21 '25 00:06 gafzan

@dgunning You are probably looking for an elegant solution to this.

A quick fix would be to:

  1. Check if a custom concept has values in get_raw_data() method. Like here with Tesla it's an obvious error: c = Company("TSLA") filings = c.latest("10-Q", 5) xbrl = XBRL.from_filing(filings[0]) statements = xbrl.statements s = statements.cashflow_statement() raw_xbrl_data = s.get_raw_data()

{'concept': '**tsla_**DepreciationAmortizationAndImpairment', 'name': 'DepreciationAmortizationAndImpairment', 'all_names': ['DepreciationAmortizationAndImpairment'], 'label': 'Depreciation, amortization and impairment', 'values': {}, 'decimals': {}, 'level': 3, 'preferred_label': 'http://www.xbrl.org/2003/role/terseLabel', 'is_abstract': False, 'children': [], 'has_values': False}, Why would a company include non-Abstract custom concept with no values?

  1. When we found such instances, we can take values from this filing's facts:

`table = list(xbrl.to_pandas().items()) facts = table[1][1]

replace _ with :

filtered_df = facts[facts['element_id'] == 'tsla:DepreciationAmortizationAndImpairment'] ` Which produces expected values:

Image

We can also filter by fact_key with startswith method without replacing _ with :

25fin avatar Jun 24 '25 06:06 25fin

This is a bug I've identified and I think I know how to fix. Should be fixed in the next release

dgunning avatar Jun 29 '25 16:06 dgunning

Should be fixed in the latest release. Please update and test

Image

dgunning avatar Jul 06 '25 16:07 dgunning