npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xml-nfe.io

v0.0.8

Published

Biblioteca para consultar notas destinadas e enviar evento de manifestação do destinatário

Downloads

53

Readme

Instalação

$ npm i xml-nfe.io

Construtor

new DistribuicaoDFe(config)
  • config <Object>
    • pfx <Buffer> - [OPCIONAL] - Arquivo .pfx. Se o pfx não for informado, as propriedades cert e key passam a ser obrigatórias.
    • passphrase <String> - [OPCIONAL] - Senha do arquivo .pfx.
    • cert <Buffer | String> - [OPCIONAL] - Conteúdo do cert.pem. Essa propriedade fica obrigatória se o pfx não for informado.
    • key <Buffer | String> - [OPCIONAL] - Conteúdo do key.pem. Essa propriedade fica obrigatória se o pfx não for informado.
    • cUFAutor <String> - [OBRIGATÓRIO] - Código da UF do autor. Consulte a tabela códigos UF.
    • cnpj <String> - [OPCIONAL] - CNPJ do interessado no DF-e. Se não informado um CNPJ, será obrigatório informar um CPF.
    • cpf <String> - [OPCIONAL] - CPF do interessado no DF-e. Se não informado um CPF, será obrigatório informar um CNPJ.
    • tpAmb <String> - [OBRIGATÓRIO] - Identificação de Ambiente. Informar '1' para Produção ou '2' para Homologação.
    • options <Object> - [OPCIONAL]
      • requestOptions <AxiosRequestConfig> - [OPCIONAL]
      • httpsOptions <AgentOptions> - [OPCIONAL]

Consulta por ultNSU

| Campo | Tipo | Tamanho | Descrição | | :------- | :------: | :-----: | :----------------------------- | | ultNSU | string | 1-15 | Último NSU recebido pelo ator. |

Exemplo

const { DistribuicaoDFe } = require('xml-nfe.io')
const fs = require('fs')

const distribuicao = new DistribuicaoDFe({
  pfx: fs.readFileSync('./certificado.pfx'),
  passphrase: 'senha',
  cnpj: '12345678901234',
  cUFAutor: '41',
  tpAmb: '2',
})

const consulta = await distribuicao.consultaUltNSU('000000000000000')

if (consulta.error) {
  throw new Error(consulta.error)
}

console.log(consulta)

Consulta por chNFe

| Campo | Tipo | Tamanho | Descrição | | :------ | :------: | :-----: | :-------------------------- | | chNFe | string | 44 | Chave de acesso específica. |

Exemplo

const { DistribuicaoDFe } = require('xml-nfe.io')
const fs = require('fs')

const distribuicao = new DistribuicaoDFe({
  pfx: fs.readFileSync('./certificado.pfx'),
  passphrase: 'senha',
  cnpj: '12345678901234',
  cUFAutor: '41',
  tpAmb: '2',
})

const consulta = await distribuicao.consultaChNFe('Chave NFE')

if (consulta.error) {
  throw new Error(consulta.error)
}

console.log(consulta)

Consulta por NSU

| Campo | Tipo | Tamanho | Descrição | | :---- | :------: | :-----: | :---------------------------------- | | NSU | string | 1-15 | Número Sequencial Único específico. |

Exemplo

const { DistribuicaoDFe } = require('xml-nfe.io')
const fs = require('fs')

const distribuicao = new DistribuicaoDFe({
  pfx: fs.readFileSync('./certificado.pfx'),
  passphrase: 'senha',
  cnpj: '12345678901234',
  cUFAutor: '41',
  tpAmb: '2',
})

const consulta = await distribuicao.consultaNSU('000000000000049')

if (consulta.error) {
  throw new Error(consulta.error)
}

console.log(consulta)

Manifestação do Destinatário

Construtor

new RecepcaoEvento(config)
  • config <Object>
    • pfx <Buffer> - [OPCIONAL] - Arquivo .pfx. Se o pfx não for informado, as propriedades cert e key passam a ser obrigatórias.
    • passphrase <String> - [OPCIONAL] - Senha do arquivo .pfx.
    • cert <Buffer | String> - [OPCIONAL] - Conteúdo do cert.pem. Essa propriedade fica obrigatória se o pfx não for informado.
    • key <Buffer | String> - [OPCIONAL] - Conteúdo do key.pem. Essa propriedade fica obrigatória se o pfx não for informado.
    • cnpj <String> - [OPCIONAL] - CNPJ do interessado no DF-e. Se não informado um CNPJ, será obrigatório informar um CPF.
    • cpf <String> - [OPCIONAL] - CPF do interessado no DF-e. Se não informado um CPF, será obrigatório informar um CNPJ.
    • tpAmb <String> - [OBRIGATÓRIO] - Identificação de Ambiente. Informar '1' para Produção ou '2' para Homologação.
    • timezone <String> - [OPCIONAL] - Fuso horário do autor. É utilizado 'America/Sao_Paulo' como valor padrão. Consulte a tabela lista de timezones válidos para o Brasil.
    • options <Object> - [OPCIONAL]
      • requestOptions <AxiosRequestConfig> - [OPCIONAL]
      • httpsOptions <AgentOptions> - [OPCIONAL]

Enviar Lote de Eventos

| Campo | Tipo | Tamanho | Descrição | | :------------------- | :------: | :-----: | :------------------------------------------------------------------------------------------------------------------------------------------------------- | | idLote | string | 1-15 | Identificador de controle do Lote de envio do Evento. | | lote | array | 1-20 | Lista de eventos para manifestação. | | lote.chNFe | string | 44 | Chave de Acesso da NF-e vinculada ao Evento. | | lote.tpEvento | number | 6 | Código do evento: 210200 - Confirmacao da Operacao; 210210 - Ciencia da Operacao; 210220 - Desconhecimento da Operacao; 210240 - Operacao nao Realizada. | | lote.justificativa | string | 15-255 | Informar a justificativa do porque a operação não foi realizada, este campo deve ser informado somente no evento de Operação não Realizada. |

Exemplo

const { RecepcaoEvento } = require('xml-nfe.io')
const fs = require('fs')

const recepcao = new RecepcaoEvento({
  pfx: fs.readFileSync('./certificado.pfx'),
  passphrase: 'senha',
  cnpj: '12345678901234',
  tpAmb: '2',
})

const lote = [
  {
    chNFe: '41000000000000000000000000000000000000000040',
    tipoEvento: 210210,
  },
  {
    chNFe: '41000000000000000000000000000000000000000041',
    tipoEvento: 210240,
    justificativa: 'Não foi realizado a entrega correta dos itens da nota.',
  },
]

const manifestacao = await recepcao.enviarEvento({
  idLote: '1337',
  lote: lote,
})

if (manifestacao.error) {
  throw new Error(manifestacao.error)
}

console.log(manifestacao)

Tabelas

Códigos UF

| UF | cUF | Estado | | :--: | :--: | :---------------------- | | RO | 11 | Rondônia | | AC | 12 | Acre | | AM | 13 | Amazonas | | RR | 14 | Roraima | | PA | 15 | Pará | | AP | 16 | Amapá | | TO | 17 | Tocantins | | MA | 21 | Maranhão | | PI | 22 | Piauí | | CE | 23 | Ceará | | RN | 24 | Rio Grande do Norte | | PB | 25 | Paraíba | | PE | 26 | Pernambuco | | AL | 27 | Alagoas | | SE | 28 | Sergipe | | BA | 29 | Bahia | | MG | 31 | Minas Gerais | | ES | 32 | Espírito Santo | | RJ | 33 | Rio de Janeiro | | SP | 35 | São Paulo | | PR | 41 | Paraná | | SC | 42 | Santa Catarina | | RS | 43 | Rio Grande do Sul | | MS | 50 | Mato Grosso do Sul | | MT | 51 | Mato Grosso | | GO | 52 | Goiás | | DF | 53 | Distrito Federal |

Lista de Timezones

| timezone | Estado | UTC | | :--------------------: | :------------------------------------- | :------: | | America/Noronha | Fernando de Noronha | −02:00 | | America/Araguaina | TO | −03:00 | | America/Bahia | BA | −03:00 | | America/Belem | AP, PA (leste) | −03:00 | | America/Fortaleza | CE, MA, PB, PI, RN | −03:00 | | America/Maceio | AL, SE | −03:00 | | America/Recife | PE | −03:00 | | America/Santarem | PA (oeste) | −03:00 | | America/Sao_Paulo | DF, ES, GO, MG, PR, RJ, RS, SC, SP | −03:00 | | America/Boa_Vista | RR | −04:00 | | America/Campo_Grande | MS | −04:00 | | America/Cuiaba | MT | −04:00 | | America/Manaus | AM (leste) | −04:00 | | America/Porto_Velho | RO | −04:00 | | America/Eirunepe | AM (oeste) | −05:00 | | America/Rio_Branco | AC | −05:00 |