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

sigep-js-danfe

v0.16.12

Published

Modulo para trabalhar com o SIGEP dos correios com danfe simplificada

Downloads

302

Readme

SIGEP-JS - DESENVOLVIMENTO

Objetivo

Uma camada para facilitar as chamadas para o sigep em NODE e geração pdf das etiquetas.

Instalação

npm install sigep-js
yarn add sigep-js

Metodos

iniciando os serviços adicione as informações do contrato no init para ter acessos aos serviços

const SIGEP = require("sigep-js").init({
    usuario,
    senha,
    codAdministrativo,
    idContrato,
    idCartaoPostagem,
    identificador, //cnpj
    cepOrigem
})

await SIGEP.verificaDisponibilidadeServico({ 
    cepDestino, 
    numeroServico, 
    cepOrigem // opcional 
});

await SIGEP.consultaCEP( cep );

await SIGEP.solicitaEtiquetas({
    qtdEtiquetas
    idServico
});


SIGEP.geraDigitoVerificadorEtiquetas([ 'SZ80600533 BR', 'SZ80600534 BR' ]);

//modelos JSON para ajudar na montagem do PLP - recomendado ler a documentaçao dos Correios
let plp = SIGEP.PLPModel.plp
let objPostal = SIGEP.PLPModel.objetoPostal

/**
 * A lista de etiquetas precisa estar na ordem do adicionado no JSON PLP
 * ex: modelo exemplo em __tests__/etiquetas.jest.js
 */
await SIGEP.solicitaJsonPlp({
    jsonPLP,
    idPlpCliente,
    listaEtiquetas //array, [ 'SZ80600533BR', 'SZ80600534BR' ] 
})

await SIGEP.calcPrecoPrazo({
    nCdEmpresa, //não obrigatório
    sDsSenha, //não obrigatório
    nCdServico,
    sCepOrigem,
    sCepDestino,
    nVlPeso, //Decimal ex: 1 = 1kg
    nCdFormato, //1 – Formato caixa/pacote, 2 – Formato rolo/prisma, 3 – Envelope
    nVlComprimento, //Decimal ex: 1 = 1cm
    nVlAltura, //Decimal ex: 1 = 1cm
    nVlLargura //Decimal ex: 1 = 1cm
    nVlDiametro, //Decimal ex: 1 = 1cm
    sCdMaoPropria, //"S" = sim, "N" = não
    nVlValorDeclarado //Decimal ex: 1 = R$1,00
    sCdAvisoRecebimento //"S" = sim, "N" = não
});

await SIGEP.buscaCliente();

await SIGEP.verificarStatusCartaoPostagem( idCartaoPostagem //oprcional );

await SIGEP.bloquearObjeto( 
    etiqueta, 
    idPLP
);

//BREVE
SIGEP.rastrearObjeto();

//BREVE
SIGEP.cancelarObjeto();

IMPRESSÃO

Por enquanto os pdf das etiquetas são feitas com puppeteer e html, nesse momento tem apenas a etiqueta pequena outro modelos em breve.

//exemplo __tests__/etiquetas.jest.js
const jsonPLP = {} //o objeto JSON do plp enviado para o SIGEP

const path = require('path')
const dir = path.dirname(__dirname)
const SIGEPPDF = require('sigep-js').pdfPLP( '44022831', jsonPLP, dir + '/__tests__/tmp/', 'teste_sigep'  )


await SIGEPPDF.tagsToPDF( dir + '/__tests__/tmp/arquivo.pdf' )
await SIGEPPDF.voucherToPDF( dir + '/__tests__/tmp/arquivo_voucher.pdf', '20/01/2020' )