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
100 stars 37 forks source link

"no" vs 0 represantation #46

Closed mrx23dot closed 2 years ago

mrx23dot commented 3 years ago

In https://www.sec.gov/ix?doc=/Archives/edgar/data/0001733257/000156459021027625/fnch-10q_20210331.htm

for InventoryNet the lib extracts "no", but the website says Fact: 0

So I think there is a special case for interpreting "no" as 0 in the following xml context:

source:

no
manusimidt commented 3 years ago

As you have already correctly recognized, the fact "InventoryNet" in the iXBRL Instance document only holds "no" as value:

<ix:nonFraction 
  unitRef="U_iso4217USD" 
  id="F_000403" 
  name="us-gaap:InventoryNet" 
  contextRef="C_0001733257_srt[...]_20201231" 
  decimals="INF" 
  format="ixt-sec:numwordsen" 
  scale="6">
    no
</ix:nonFraction>

It is also true that the SEC's iXBRL viewer interprets this "no" value as 0. The inline XBRL Specification 1.1 defines the ix:nonFraction as follows:

The ix:nonFraction element denotes an XBRL numeric item which is an element which is not of type, nor derived from type, fractionItemType [...]. https://www.xbrl.org/specification/inlinexbrl-part1/rec-2013-11-18/inlinexbrl-part1-rec-2013-11-18.html#sec-nonFractions

Since a nonFraction element should never be text, I think it would be really useful for the parser to replace the original value "no" with 0 (as you proposed). I just wonder if there can be other text values which should be unconverted to numeric values. The fact could also hypothetically contain the text value "zero", however I haven't seen this in real submissions yet.

mrx23dot commented 3 years ago

For numeric value I also saw these:

    elif val.lower() in [u'☒', 'true', 'yes']:
      val = True
    elif val.lower() in [u'☐', 'false', 'no']:
      val = False
    elif val.lower() in [u'—', '-']: # considered 0 for numeric values
      val = 0

Just make sure '☐', 'false' won't be 0. (like tick boxes)