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/cfdi-sat

v2.4.0

Published

Libreria para la generación y sellado de XML para facturación electrónica 4.0 en México (SAT)

Downloads

30

Readme

CFDi SAT para NodeJS

Esta libreria ayuda a la generacion del XML para timbrado del SAT conforme a las reglas del XSD.

Funciona correctamente para:

  • Facturas (Ingresos y Egresos) Cfdi 4.0
  • Complementos de Pago 2.0
  • Carta Porte 3.1

Proporcionando los certificados digitales del emisor la libreria tambien puede sellar el XML.

Instalación

npm i @alexotano/cfdi-sat

Ejemplo de uso Factura

'use strict'

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

const cfdi = new CFDI({
  'Fecha': '2018-06-11T08:09:23',
  'NoCertificado': '20001000000300022815',
  'SubTotal': '1000',
  'Moneda': 'MXN',
  'Total': '1160',
  'TipoDeComprobante': 'I',
  'FormaPago': '01',
  'MetodoPago': 'PUE',
  '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',
  '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/cfdisat').CFDI
const Emisor = require('@alexotano/cfdisat').Emisor
const Receptor = require('@alexotano/cfdisat').Receptor
const Concepto = require('@alexotano/cfdisat').Concepto
const CuentaPredial = require('@alexotano/cfdisat').CuentaPredial
const InformacionAduanera = require('@alexotano/cfdisat').InformacionAduanera
const CfdiRelacionado = require('@alexotano/cfdisat').CfdiRelacionado
const Traslado = require('@alexotano/cfdisat').Traslado
const Retencion = require('@alexotano/cfdisat').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()


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'));