# cfdinative

> Libreria para crear y sellar xml cfdi V3.3

Latest version **3.3.26** (published 2019-06-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install cfdinative
pnpm add cfdinative
yarn add cfdinative
bun add cfdinative
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.26 |
| Published | 2019-06-03 |
| First published | 2019-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 118.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 3 |
| Maintainers | pedromalito |
| Keywords | cfdi, sat, 3.3, factura, mexico, pdf |

## Links

- npm: https://www.npmjs.com/package/cfdinative
- Repository: https://github.com/pedromalito/cfdinative
- Homepage: https://github.com/pedromalito/cfdinative#readme
- Issues: https://github.com/pedromalito/cfdinative/issues
- npm.io page: https://npm.io/package/cfdinative

## Dependencies (7)

- [nan](https://npm.io/package/nan.md) ^2.11.x
- [lodash](https://npm.io/package/lodash.md) ^4.17.x
- [xml-js](https://npm.io/package/xml-js.md) 1.6.x
- [node-gyp](https://npm.io/package/node-gyp.md) ^3.8.0
- [napi-crypto](https://npm.io/package/napi-crypto.md) ^1.2.0
- [node-xsltproc](https://npm.io/package/node-xsltproc.md) ^1.1.1
- [node-addon-api](https://npm.io/package/node-addon-api.md) *

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 3.3.26 (latest) — 2019-06-03

## README

# ![CFDI 3.3](https://idc.brightspotcdn.com/dims4/default/410f35f/2147483647/crop/0x0%2B0%2B0/resize/1500x250%5E/quality/90/?url=https%3A%2F%2Fidc.brightspotcdn.com%2Fd6%2F1f%2F72c8c8f64f92a2f01b43a400d3b8%2Fcfdi.gif)

[![MIT License][license-image]][license-url]
[![Greenkeeper badge][green-image]][green-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
[![dependencies status][dev-image]][dev-url]

[green-image]: https://badges.greenkeeper.io/PolygonTechMX/CFDI.svg
[green-url]: https://greenkeeper.io/
[snyk-image]: https://snyk.io/test/github/polygontechmx/cfdi/badge.svg?targetFile=package.json
[snyk-url]: https://snyk.io/test/github/polygontechmx/cfdi?targetFile=package.json
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE
[npm-url]: https://npmjs.org/package/cfdi
[npm-version-image]: http://img.shields.io/npm/v/cfdi.svg?style=flat
[npm-downloads-image]: http://img.shields.io/npm/dt/cfdi.svg?style=flat
[dev-image]: https://img.shields.io/david/mgcrea/node-openssl-wrapper.svg?style=flat
[dev-url]: https://david-dm.org/mgcrea/node-openssl-wrapper

Libreria para crear y sellar documendos xml cfdi.

Por el momento solo funciona para windows y no requiere instalacion de OpenSSL ni Libxml2 ya que vienen integrados en el paquete.

<!-- toc -->
- [Instalación](#Instalación)
- [Metodos](#Glosario)
  * [`Init`](#init)
  * [`Comprobante`](#comprobante)
    * [`CFDI Relacionados`](#relacionados)
    * [`Emisor`](#emisor)
    * [`Receptor`](#receptor)
    * [`Concepto`](#concepto)
        * [`Traslados`](#concepto.traslado)
        * [`Retenciones`](#concepto.retencion)
        * [`Agregar`](#concepto.agregar)
    * [`Impuestos`](#impuestos)
  * [`Certificar`](#certificar)
  * [`Generar XML`](#xml)
  * [`Generar XML Sellado`](#xmlSellado)
- [Ejemplos]()
  * [`Ejemplo básico`](#basico)
  * [`Ejemplo simplificado`](#simplificado)
<!-- tocstop -->

## Instalación

NPM:

* npm install cfdi --save

YARN:

* yarn add cfdi

## Glosario

### `init`
```javascript
const CFDI = require('cfdi');

const key = './LAN7008173R5.key';
const cer = './LAN7008173R5.cer';
const cfdi = new CFDI()
```

### `comprobante`
```javascript
cfdi.comprobante({
    Serie: 'A',
    Folio: '167ABC',
    Fecha: '2018-01-16T09:33:43',
    SubTotal: '369.83',
    Moneda: 'MXN',
    Total: '429.00',
    TipoDeComprobante: 'I',
    FormaPago: '01',
    MetodoPago: 'PUE',
    CondicionesDePago: 'CONDICIONES',
    Descuento: '0.00',
    TipoCambio: '1',
    LugarExpedicion: '45079'
});
```

### `relacionados`
```javascript
cfdi.CfdiRelacionados({
    TipoRelacion: '',
    CfdiRelacionados: ['UUID_____________1', 'UUID_____________2', 'UUID_____________3']
});
```

### `emisor`
```javascript
cfdi.emisor({
    Rfc: 'SAT',
    Nombre: 'SAT SA DE CV',
    RegimenFiscal: '601'
});
```

### `receptor`
```javascript
cfdi.receptor({
    Rfc: 'MALD930428US2',
    Nombre: 'DAVID ISAAC MARTINEZ LOPEZ',
    UsoCFDI: 'G01'
});
```

### `concepto`
```javascript
const concepto = cfdi.concepto({
    ClaveProdServ: '52121500',
    ClaveUnidad: 'E48',
    NoIdentificacion: '3031130179',
    Cantidad: '1',
    Unidad: 'PZ',
    Descripcion: 'BATITA UNICORNIO',
    ValorUnitario: '369.83',
    Importe: '369.83'
});
```

### `concepto.traslado`
```javascript
concepto.traslado({
    Base: '369.83',
    Impuesto: '002',
    TipoFactor: 'Tasa',
    TasaOCuota: '0.16',
    Importe: '59.17'
});
```

### `concepto.retencion`
```javascript
concepto.retencion({
    Base: '369.83',
    Impuesto: '002',
    TipoFactor: 'Tasa',
    TasaOCuota: '0.16',
    Importe: '59.17'
});
```

### `concepto.agregar`
```javascript
concepto.agregar(cfdi),
```

### `impuestos`
```javascript
cfdi.impuestos({
    TotalImpuestosTrasladados: '59.17',
    Traslados: [
      {
        Impuesto: '002',
        TipoFactor: 'Tasa',
        TasaOCuota: '0.16',
        Importe: '59.17'
      }
    ]
});
```

### `certificar`
```javascript
const cer = path.join(__dirname, 'LAN7008173R5.cer');
cfdi.certificar(cer);
```

### xml
```javascript
cfdi
.xml()
.then(xml => console.log(xml))
.catch(err => console.log(err));
```

### `xmlSellado`
```javascript
const key = path.join(__dirname, 'LAN7008173R5.key');
cfdi.xmlSellado(key, '12345678a')
.then(xml => console.log(xml))
.catch(err => console.log(err));
```

### `basico`
```javascript
const fs = require('fs');
const CFDI = require('../src/CFDI');

const key = './LAN7008173R5.key';
const cer = './LAN7008173R5.cer';

const cfdi = new CFDI({
    Serie: 'A',
    Folio: '167ABC',
    Fecha: '2018-01-16T09:33:43',
    SubTotal: '369.83',
    Moneda: 'MXN',
    Total: '429.00',
    TipoDeComprobante: 'I',
    FormaPago: '01',
    MetodoPago: 'PUE',
    CondicionesDePago: 'CONDICIONES',
    Descuento: '0.00',
    TipoCambio: '1',
    LugarExpedicion: '45079'
});

cfdi.emisor({
    Rfc: 'SAT',
    Nombre: 'SAT SA DE CV',
    RegimenFiscal: '601'
});

cfdi.receptor({
    Rfc: 'MALD930428US2',
    Nombre: 'DAVID ISAAC MARTINEZ LOPEZ',
    UsoCFDI: 'G01'
});

const concepto = cfdi.concepto({
    ClaveProdServ: '52121500',
    ClaveUnidad: 'E48',
    NoIdentificacion: '3031130179',
    Cantidad: '1',
    Unidad: 'PZ',
    Descripcion: 'BATITA UNICORNIO',
    ValorUnitario: '369.83',
    Importe: '369.83'
});

concepto.traslado({
    Base: '369.83',
    Impuesto: '002',
    TipoFactor: 'Tasa',
    TasaOCuota: '0.16',
    Importe: '59.17'
});

concepto.agregar(cfdi);

cfdi.impuestos({
    TotalImpuestosTrasladados: '59.17',
    Traslados: [
      {
        Impuesto: '002',
        TipoFactor: 'Tasa',
        TasaOCuota: '0.16',
        Importe: '59.17'
      }
    ]
});

cfdi.certificar(cer);

cfdi.xmlSellado(key, '12345678a')
.then(xml => console.log(xml))
.catch(err => console.log(err));
```

### `simplificado`
```javascript
const fs = require('fs');
const CFDI = require('../src/CFDI');

const key = './LAN7008173R5.key';
const cer = './LAN7008173R5.cer';

const cfdi = new CFDI({
    Serie: 'A',
    Folio: '167ABC',
    Fecha: '2018-01-16T09:33:43',
    SubTotal: '369.83',
    Moneda: 'MXN',
    Total: '429.00',
    TipoDeComprobante: 'I',
    FormaPago: '01',
    MetodoPago: 'PUE',
    CondicionesDePago: 'CONDICIONES',
    Descuento: '0.00',
    TipoCambio: '1',
    LugarExpedicion: '45079'
}).emisor({
    Rfc: 'SAT',
    Nombre: 'SAT SA DE CV',
    RegimenFiscal: '601'
}).receptor({
    Rfc: 'MALD930428US2',
    Nombre: 'DAVID ISAAC MARTINEZ LOPEZ',
    UsoCFDI: 'G01'
}).impuestos({
    TotalImpuestosTrasladados: '59.17',
    Traslados: [
      {
        Impuesto: '002',
        TipoFactor: 'Tasa',
        TasaOCuota: '0.16',
        Importe: '59.17'
      }
    ]
});

cfdi.concepto({
    ClaveProdServ: '52121500',
    ClaveUnidad: 'E48',
    NoIdentificacion: '3031130179',
    Cantidad: '1',
    Unidad: 'PZ',
    Descripcion: 'BATITA UNICORNIO',
    ValorUnitario: '369.83',
    Importe: '369.83'
}).retencion({
    Base: '369.83',
    Impuesto: '002',
    TipoFactor: 'Tasa',
    TasaOCuota: '0.16',
    Importe: '59.17'
}).agregar(cfdi);


cfdi
.certificar(cer)
.xmlSellado(key, '12345678a')
.then(xml => console.log(xml))
.catch(err => console.log(err));
```

## Utilidades

Windows build tools

* npm install --global windows-build-tools

OpenSSL Windows X64

* https://slproweb.com/download/Win64OpenSSL-1_0_2n.exe

---
_Source: https://npm.io/package/cfdinative · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
