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

@alexssmusica/emissao-nota-fiscal

v1.0.4

Published

Modulo que auxilia na geração de NFe e NFCe

Downloads

204

Readme

npm install @alexssmusica/emissao-nota-fiscal
yarn add @alexssmusica/emissao-nota-fiscal

Exemplo

import {
  carregaCertificadoPath,
  carregaCertificadoBase64,
  statusServico,
  emitir,
  cancelar,
  inutilizar,
  cartaCorrecao,
  gerarPDF,
} from "@alexssmusica/emissao-nota-fiscal";

const keypem = carregaCertificadoPath({
  path: env.CERTIFICATE_PATH,
  password: env.CERTIFICATE_PASSWORD,
});
const cert = {
  pfx: fs.readFileSync(env.CERTIFICATE_PATH),
  pem: keypem.pem,
  key: keypem.key,
  password: env.CERTIFICATE_PASSWORD,
};

const emit: TNFeInfNFeEmit = {
  CNPJ: "00000000000000",
  xNome: "NOME DA EMPRESA",
  xFant: "NOME FANSASIA DA EMPRESA",
  enderEmit: {
    xLgr: "Rua Teste",
    nro: "123",
    xCpl: undefined,
    xBairro: "Bairro Teste",
    cMun: "3504602",
    xMun: "BADY BASSITT",
    UF: "SP",
    CEP: "15115000",
    cPais: "1058",
    xPais: "BRASIL",
    fone: undefined,
  },
  IE: "195000888999",
  IM: "000888999",
  CRT: "1",
  iEST: undefined,
  CNAE: undefined,
};

const empresa: Empresa = {
  certificado: cert,
  idCSC: env.DADOS_ID_CSC,
  CSC: env.DADOS_CSC,
};

const configuracoes = {
  empresa: {
    pem: cert.pem,
    key: cert.key,
    password: "SUA SENHA",
    idCSC: "SEU_ID_CSC",
    CSC: "SEU CSC",
  },
  geral: {
    versao: "4.00",
    ambiente: "2",
    modelo: "55",
  },
};

const dest: TNFeInfNFeDest = {
  idEstrangeiro: undefined,
  CNPJ: undefined,
  CPF: "00000000000",
  xNome: "DESTINATARIO TESTE",
  enderDest: {
    xLgr: "RUA DOS PALMARES",
    nro: "1231",
    xCpl: "casa 5",
    xBairro: "NOME DO BAIRRO",
    cMun: "4303103",
    xMun: "CACHOEIRINHA",
    UF: "RS",
    CEP: "15025120",
  },
  indIEDest: "9",
  email: "[email protected]",
};

const transp: TNFeInfNFeTransp = {
  modFrete: "9",
};

const infAdic: TNFeInfNFeInfAdic = {
  infCpl: "INFORMACAO COMPLEMENTAR FEITA PARA APARECER NA NFE/NFCE",
  infAdFisco: undefined,
  obsCont: [],
  obsFisco: [],
  procRef: [],
};

const det_list: TNFeInfNFeDet[] = [];
const valorProduto = 31.8;
let valorTotalProdutos = 0;
for (let i = 1; i <= 1; i++) {
  valorTotalProdutos += valorProduto;
  det_list.push({
    $: { nItem: String(i) },
    prod: {
      cProd: "84233",
      cEAN: "7898221456293",
      xProd: "PRODUTO TESTE",
      NCM: "85164000",
      CEST: undefined,
      cNPJFab: undefined,
      cBenef: undefined,
      eXTIPI: undefined,
      CFOP: "5102",
      uCom: "SAC",
      qCom: "1.0000",
      vUnCom: valorProduto.toFixed(2),
      vProd: valorProduto.toFixed(2),
      cEANTrib: "7898221456293",
      uTrib: "SAC",
      qTrib: "1.0000",
      vUnTrib: valorProduto.toFixed(2),
      vFrete: "",
      vSeg: "",
      vDesc: "",
      vOutro: "",
      indTot: "1",
      xPed: "",
      nItemPed: "",
    },
    imposto: {
      vTotTrib: 0,
      ICMS: {
        ICMSSN102: {
          orig: "0",
          CSOSN: "102",
        },
      },
      PIS: {
        PISOutr: {
          CST: "99",
          vBC: 0,
          pPIS: 0,
          vPIS: 0,
        },
      },
      COFINS: {
        COFINSOutr: {
          CST: "99",
          vBC: 0,
          pCOFINS: 0,
          vCOFINS: 0,
        },
      },
    },
  });
}

const detPag: TNFeInfNFePagDetPag[] = [];
const pagItem: TNFeInfNFePagDetPag = {
  indPag: "0",
  tPag: "01",
  vPag: valorTotalProdutos.toFixed(2),
  xPag: undefined,
  card: undefined,
};
detPag.push(pagItem);

const pag: TNFeInfNFePag = {
  detPag,
  vTroco: "0",
};

const ICMSTot: TNFeInfNFeTotalICMSTot = {
  vBC: "0.00",
  vICMS: "0.00",
  vICMSDeson: "0.00",
  vFCP: "0.00",
  vBCST: "0.00",
  vST: "0.00",
  vFCPST: "0.00",
  vFCPSTRet: "0.00",
  vProd: valorTotalProdutos.toFixed(2),
  vFrete: "0.00",
  vSeg: "0.00",
  vDesc: "0.00",
  vII: "0.00",
  vIPI: "0.00",
  vIPIDevol: "0.00",
  vPIS: "0.00",
  vCOFINS: "0.00",
  vOutro: "0.00",
  vNF: valorTotalProdutos.toFixed(2),
};

const ide: IdeInput = {
  cUF: "35",
  natOp: "VENDA",
  mod: "55",
  serie: "1",
  nNF: "16",
  dhEmi: "",
  tpNF: "1",
  idDest: "1",
  cMunFG: "3504602",
  tpImp: "1",
  tpEmis: "1",
  tpAmb: "2",
  finNFe: "1",
  indFinal: "1",
  indPres: "1",
  procEmi: "0",
  verProc: "NODE-NFE TEST 1.0",
};

const pag: TNFeInfNFePag = {
  detPag,
  vTroco: "0",
};

const ICMSTot: TNFeInfNFeTotalICMSTot = {
  vBC: "0.00",
  vICMS: "0.00",
  vICMSDeson: "0.00",
  vFCP: "0.00",
  vBCST: "0.00",
  vST: "0.00",
  vFCPST: "0.00",
  vFCPSTRet: "0.00",
  vProd: valorTotalProdutos.toFixed(2),
  vFrete: "0.00",
  vSeg: "0.00",
  vDesc: "0.00",
  vII: "0.00",
  vIPI: "0.00",
  vIPIDevol: "0.00",
  vPIS: "0.00",
  vCOFINS: "0.00",
  vOutro: "0.00",
  vNF: valorTotalProdutos.toFixed(2),
};

const nfe: NFeBase = {
  ide,
  emit,
  dest,
  det_list,
  total: { ICMSTot },
  transp,
  pag,
  infAdic,
};

const result = await emitir({ documento: nfe, configuracoes });
const response = inspect(result, false, null);
console.log("Resultado: \n\n" + response);

const result = await cancelar({
  chNFe: "35230400000000000000550010000000071458222950",
  nProt: "135230009995798",
  xJust: "TESTE DE CANCELAMENTO",
  configuracoes,
});
const response = inspect(result, false, null);
console.log("Resultado: \n\n" + response);

const result = await cartaCorrecao({
  chNFe: "35230400000000000000550010000000071458222950",
  nProt: "135230009999798",
  xCorrecao: "TESTE DE CARTA DE CORRECAO EM HOMOLOCAO",
  configuracoes,
});
const response = inspect(result, false, null);
console.log("Resultado Carta Correção NFC-e: \n\n" + response);

const dados: Inutilizar = {
  ano: 2023,
  modelo: "55",
  numeroInicial: 5,
  numeroFinal: 5,
  serie: 1,
  xJustificativa: "HOMOLOGACAO TESTE",
  cUf: "35",
  cnpj: "00000000000000",
};
const result = await inutilizar({ configuracao, dados });
console.log(result);

const result = await statusServico(configuracoes, "35");
const response = inspect(result, false, null);
console.log("Status: \n\n" + response);