MCPcopy Create free account
hub / github.com/BrasilAPI/BrasilAPI / getIntermediatorsFromZip

Function getIntermediatorsFromZip

services/cvm/corretoras.js:14–89  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

12}
13
14function getIntermediatorsFromZip(data) {
15 const zip = new AdmZip(data);
16 const zipEntries = zip.getEntries();
17
18 const intermediatorsEntry = zipEntries.find((entry) =>
19 entry.entryName.match(/cad_intermed.csv/i)
20 );
21 if (!intermediatorsEntry) {
22 throw new Error('File not found');
23 }
24
25 const intermediatorFile = zip.readAsText(intermediatorsEntry, 'latin1');
26 const lines = intermediatorFile.split(LINE_BREAK);
27 lines.shift();
28
29 try {
30 const mappedLines = lines
31 .map((line) => line.split(';')) // Gera um array por coluna
32 .filter(([type, cnpj]) => type === 'CORRETORAS' && cnpj)
33 .map(
34 ([
35 type, // Tipo de participante
36 cnpj, // Cadastro Nacional de Pessoas Jurídicas (CNPJ)
37 socialName, // Denominação Social
38 commercialName, // Denominação Comercial
39 registerDate, // Data de Registro // Data de Cancelamento // Motivo do Cancelamento
40 ,
41 ,
42 status, // Situação
43 statusInit, // Data Inicial do Status
44 cvmCode, // Código da CVM // Setor de Atividade // Controle Acionário
45 ,
46 ,
47 equityValue, // Patrimônio Líquido
48 equityValueDate, // Data de Divulgação do Patrimônio Líquido // Tipo de Endereço
49 ,
50 address, // Logradouro
51 obs, // Complemento
52 neighborhood, // Bairro
53 city, // Cidade
54 state, // Estado
55 country, // País
56 cep, // CEP // DDD Telefone
57 ,
58 tel, // Telefone // DDD Fax // Fax
59 ,
60 ,
61 email, // Email
62 ]) => ({
63 cnpj: cnpj.replace(/\D/gim, ''),
64 type,
65 nome_social: socialName ? socialName.trim() : '',
66 nome_comercial: commercialName ? commercialName.trim() : '',
67 status,
68 email,
69 telefone: tel,
70 cep,
71 pais: country,

Callers 1

getExchangesDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected