uktrade / stream-read-xbrl

Python package to parse Companies House accounts data in a streaming way
https://stream-read-xbrl.docs.trade.gov.uk/
MIT License
17 stars 2 forks source link

latest number for average number employees wrong #182

Open vi0815 opened 2 weeks ago

vi0815 commented 2 weeks ago

Hi,

When extracting the number for average employees, the value returned is always from the previous year instead of the current year. The iXBRL files seem to be correct, and I have experienced this problem with multiple companies.

If I move average_number_of_employees from GENERAL to PERIODICAL_XPATH_MAPPINGS, the current number gets extracted (which in my specific case is sufficient), but the overall result is incorrect.

Steps to Reproduce

This error can be reproduced for the company below (randomly picked) as follows:

Installed package: https://files.pythonhosted.org/packages/58/11/7849481a5f0d3b7cad22afc75a19b93a0b132f91c71cd4ea1f58a1ddcc15/stream_read_xbrl-0.0.43.tar.gz

import pprint
import httpx
import operator
from stream_read_xbrl import stream_read_xbrl_zip, _xbrl_to_rows, _COLUMNS

if __name__ == '__main__':
    url = "https://download.companieshouse.gov.uk/Accounts_Bulk_Data-2024-06-20.zip"
    with \
            httpx.stream('GET', url) as r, \
            stream_read_xbrl_zip(r.iter_bytes(chunk_size=65536)) as (columns, rows):
            r.raise_for_status()

            for row in rows:
                print(row)
python streamtest.py | grep 10956764

('Prod223_3724', '10956764', datetime.date(2023, 9, 30), 'html', '', datetime.date(2023, 9, 30), '10956764', 'FLY FITNESS LIMITED', False, Decimal('18'), datetime.date(2023, 9, 30), datetime.date(2023, 9, 30), Decimal('579913'), None, None, Decimal('10743'), None, None, D
ecimal('-364809'), Decimal('215104'), Decimal('-733138'), None, None, Decimal('-733138'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)
('Prod223_3724', '10956764', datetime.date(2023, 9, 30), 'html', '', datetime.date(2023, 9, 30), '10956764', 'FLY FITNESS LIMITED', False, Decimal('18'), datetime.date(2022, 9, 30), datetime.date(2022, 9, 30), Decimal('644654'), None, None, Decimal('11080'), None, None, D
ecimal('-69340'), Decimal('575314'), Decimal('-406422'), None, None, Decimal('-406422'), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)

In the output above, the number of average employees is 18 for both years. However, the iXBRL report states that the number of employees for the current year is 9 and for the previous year is 18. The report can be found here:

https://find-and-update.company-information.service.gov.uk/company/10956764/filing-history/MzQyNTg1MzMyNmFkaXF6a2N4/document?format=xhtml&download=1

Thank you for looking into this issue. Please let me know if any additional information is needed.

Waldemar