glourencoffee / pycvm

Python library for processing data from CVM
MIT License
2 stars 0 forks source link

Missing CVM codes in the ITR from years 2010 to 2019 #21

Closed glourencoffee closed 2 years ago

glourencoffee commented 2 years ago

Description

The exception ValueError is raised if AccountLayoutType.from_cvm_code() is called for ITR documents from years 2011 to 2019.

Steps to reproduce

  1. Download an ITR from 2011 to 2019
  2. Open the document with DFPITRFile
  3. Call AccountLayoutType.from_cvm_code() for documents in that file
  4. See how ValueError is raised for many documents

Expected behavior

CVM codes in ITR files from 2011 to 2019 should be tracked by this library, and thus not raise ValueError.

Actual behavior

For example, running the following program:

import cvm
import sys

missing_cvm_codes = {}

with cvm.DFPITRFile(sys.argv[1]) as file:
    for dfpitr in file:
        # print(dfpitr)

        try:
            cvm.AccountLayoutType.from_cvm_code(dfpitr.cvm_code)
        except ValueError:
            missing_cvm_codes[dfpitr.cvm_code] = dfpitr.company_name

# print('CVM codes missed by this library:')
for cvm_code, company_name in missing_cvm_codes.items():
    print(cvm_code, '-', company_name)

with the ITR of 2011 produces the following output:

15733 - SHOPPING CENTER TACARUNA SA
14680 - PARCOM PARTICIPACOES S.A. - EM LIQUIDAÇÃO
14613 - NEUMARKT TRADE AND FINANCIAL CENTER S/A
15334 - BOMBRIL HOLDING SA
14818 - CIMS S.A.
16772 - BNDES PARTICIPACOES S.A. - BNDESPAR
16209 - ELETRON S.A.
14966 - SERRA AZUL WATER PARK SA
18589 - INVESTCO S.A.
14915 - GTD PARTICIPACOES SA
19577 - CONC RODOVIA PRES. DUTRA S.A.
15261 - SAUIPE SA
15199 - SANTA CATARINA PART INVEST SA
15377 - HOPI HARI SA
19208 - CONC RIO-TERESOPOLIS S.A.
15717 - CAIXA ADM DIV PUB ESTADUAL SA
15784 - ELETROBRÁS PARTICIPAÇÕES S.A. - ELETROPAR
15865 - ITAITINGA PARTICIPACOES S.A.
15709 - FERROVIA SUL-ATLANTICO S.A.
...

Additional context

This bug results from the refactor implemented by callmegiorgio/pycvm#11. callmegiorgio/pycvm#20 was a similar bug with DFP files.