manusimidt / py-xbrl

Python-based parser for parsing XBRL and iXBRL files
https://py-xbrl.readthedocs.io/en/latest/
GNU General Public License v3.0
111 stars 40 forks source link

Sign missing #52

Closed mrx23dot closed 3 years ago

mrx23dot commented 3 years ago

In https://www.sec.gov/ix?doc=/Archives/edgar/data/0000320193/000032019321000010/aapl-20201226.htm

for IncreaseDecreaseInAccountsReceivable

The html displays: (10,945), but the lib returns positive number, weirdly Sign=Positive is stated in xbrl, but the minus sign is needed for change_in_working_capital calculation.

mrx23dot commented 3 years ago

Any chance you could look into this one? It's a blocking one for me.

Cheers!

manusimidt commented 3 years ago

Ok, I will look into it tomorrow :)

manusimidt commented 3 years ago

The parser correctly reads in both facts. So this has something to do with the accounting background of the concept. Unfortunately, my knowledge of accounting is very limited. But what I noticed is that the fact of the previous time period is positive, but has a negative sign.

image

in XBRL:

<td>
   <span>
      (
      <ix:nonFraction 
         unitRef="usd" contextRef="i6e431846933d461fb8c8c0bdf98c9758_D20200927-20201226" 
         decimals="-6" format="ixt:numdotdecimal" 
         name="us-gaap:IncreaseDecreaseInAccountsReceivable" scale="6">10,945
      </ix:nonFraction>
      )
   </span>
</td>
<td>
   <span>
      <ix:nonFraction 
         unitRef="usd" contextRef="i142aac6a7c14434fb2a1a08f0f6ae9b9_D20190929-20191228" 
         decimals="-6" sign="-" format="ixt:numdotdecimal" 
         name="us-gaap:IncreaseDecreaseInAccountsReceivable" scale="6">2,015
      </ix:nonFraction>
   </span>
</td>

This means that for some reason Facts tagged with the concept IncreaseDecreaseInAccountsReceivable have a positive sign if Accounts Recievable decreases and a negative sign if the value increases.

I suspect that this has something to do with the balance of the Concept, it is set to credit for the concept IncreaseDecreaseInAccountsReceivable. image

In a nutshell: debits (dr) record all of the money flowing into an account, while credits (cr) record all of the money flowing out of an account. https://bench.co/blog/bookkeeping/debits-credits/

mrx23dot commented 3 years ago

Ah, it just needs inverting to match up with the web view, easy enough, cheers!