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

@alexotano/cfdi33

v2.4.7

Published

Libreria para generación de XML, para facturación electrónica 3.3 en México

Downloads

66

Readme

CFDi33 para NodeJS

Fork de @blacktrue para la generacion de cfdi 3.3, ¡un excelente trabajo!

En mi version se hicieron correcciones de un par de errores de rutas dinamicas y agregado de complemento de pago 2018.

Instalación

npm i @alexotano/cfdi33

Ejemplo de uso Factura

'use strict'

const CFDI = require('@alexotano/cfdi33').CFDI
const Emisor = require('@alexotano/cfdi33').Emisor
const Receptor = require('@alexotano/cfdi33').Receptor
const Concepto = require('@alexotano/cfdi33').Concepto
const CuentaPredial = require('@alexotano/cfdi33').CuentaPredial
const InformacionAduanera = require('@alexotano/cfdi33').InformacionAduanera
const CfdiRelacionado = require('@alexotano/cfdi33').CfdiRelacionado
const Traslado = require('@alexotano/cfdi33').Traslado
const Retencion = require('@alexotano/cfdi33').Retencion

const cfdi = new CFDI({
  //'Serie': 'A',
  //'Folio': '167ABC',
  'Fecha': '2018-06-11T08:09:23',
  'NoCertificado': '20001000000300022815',
  'SubTotal': '1000',
  'Moneda': 'MXN',
  'Total': '1160',
  'TipoDeComprobante': 'I',
  'FormaPago': '01',
  'MetodoPago': 'PUE',
  //'CondicionesDePago': 'CONDICIONES',
  'TipoCambio': '1',
  'LugarExpedicion': '45079',
});

cfdi.cer = './test/resources/XXXXXXXXXXXX.cer.pem'
cfdi.key = './test/resources/XXXXXXXXXXXX.key.pem'
cfdi.withOutCerts = false

/*
cfdi.add(new CfdiRelacionado({
  'UUID': 'A39DA66B-52CA-49E3-879B-5C05185B0EF7'
}, {
  'TipoRelacion': '01'
}))
*/

cfdi.add(new Emisor({
  'Rfc': 'XXXXXXXX',
  'Nombre': 'NOMBRE APELLIDO',
  'RegimenFiscal': '601'
}))

cfdi.add(new Receptor({
  'Rfc': 'ZZZZZZZZZZZ',
  //'Nombre': 'NOMBRE APELLIDO',
  //'ResidenciaFiscal': 'MEX',
  //'NumRegIdTrib': '0000000000000',
  'UsoCFDI': 'G01'
}))

const concepto = new Concepto({
  'ClaveProdServ': '01010101',
  'ClaveUnidad': 'F52',
  'NoIdentificacion': '00001',
  'Cantidad': '1',
  'Unidad': 'TONELADA',
  'Descripcion': 'ACERO',
  'ValorUnitario': '1000',
  'Importe': '1000'
})

concepto.add(new Traslado({
  'Base': '1000',
  'Impuesto': '002',
  'TipoFactor': 'Tasa',
  'TasaOCuota': '0.16',
  'Importe': '160'
}))

cfdi.add(concepto)

cfdi.add(new Traslado({
  'Impuesto': '002',
  'TipoFactor': 'Tasa',
  'TasaOCuota': '0.16',
  'Importe': '160'
}, {}, {
  'TotalImpuestosTrasladados': '160.00'
}))

cfdi.getXml()
.then(xml => console.log(xml))
.catch(e => console.log(e.toString(), '---> error'));

Ejemplo de uso Complemento de Pago

'use strict'

const CFDI = require('@alexotano/cfdi33').CFDI
const Emisor = require('@alexotano/cfdi33').Emisor
const Receptor = require('@alexotano/cfdi33').Receptor
const Concepto = require('@alexotano/cfdi33').Concepto
const CuentaPredial = require('@alexotano/cfdi33').CuentaPredial
const InformacionAduanera = require('@alexotano/cfdi33').InformacionAduanera
const CfdiRelacionado = require('@alexotano/cfdi33').CfdiRelacionado
const Traslado = require('@alexotano/cfdi33').Traslado
const Retencion = require('@alexotano/cfdi33').Retencion

const pago = new CFDIPago({
  'Fecha': '2018-06-11T08:09:23',
  'NoCertificado': '20001000000300022815',
  'SubTotal': '1000',
  'Moneda': 'XXX', // La moneda se declara por comprobante
  'Total': '1160',
  'TipoDeComprobante': 'P',
  'FormaPago': '01',
  'MetodoPago': 'PUE',
  //'CondicionesDePago': 'CONDICIONES',
  'TipoCambio': '1',
  'LugarExpedicion': '45079',
});

pago.cer = './test/resources/LAN7008173R5.cer.pem'
pago.key = './test/resources/LAN7008173R5.key.pem'
pago.withOutCerts = false

pago.add(new Emisor({
  'Rfc': 'LAN7008173R5',
  'Nombre': 'CESAR RENE AGUILERA ARREOLA',
  'RegimenFiscal': '601'
}))

pago.add(new Receptor({
  'Rfc': 'HEPR930322977',
  'UsoCFDI': 'G01'
}))

const concepto = new Concepto({
  'ClaveProdServ': '84111506',
  'ClaveUnidad': 'ACT',
  'Cantidad': 1,
  'Descripcion': 'Pago',
  'ValorUnitario': 0,
  'Importe': 0
})
		
pago.add(concepto)

let complemento = new Complemento()


//SE PUEDE HACER UN CICLO PARA AGREGAR TODOS LOS COMPROBANTES AQUI

let comprobante = {
  IdDocumento: 'A39DA66B-52CA-49E3-879B-OTROCFDI##',
  MonedaDR: 'MXN',
  MetodoDePagoDR: 'PPD',
  NumParcialidad: '1',
  ImpSaldoAnt: 200,
  ImpPagado: 80,
  ImpSaldoInsoluto: 120
}

let pago = {
  MonedaP: 'MXN',
  FormaDePagoP: '01',
  FechaPago: '01-07-2019T22:01:21',
  Monto: 80
}

let version = { Version: "1.0" }

complemento.add(new Pago(comprobante, pago, version))

//------------------


pago.add(complemento)

pago.getXml()
.then(xml => console.log(xml))
.catch(e => console.log(e.toString(), '---> error'));