facturacion-open-api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +20 -0
- package/README.md +106 -0
- package/dist/index.d.mts +677 -0
- package/dist/index.d.ts +677 -0
- package/dist/index.js +7188 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7166 -0
- package/dist/index.mjs.map +1 -0
- package/dist/wsdl/AutorizacionComprobantesOffline.wsdl +155 -0
- package/dist/wsdl/RecepcionComprobantesOffline.wsdl +97 -0
- package/package.json +34 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) contributors
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# facturacion-open-api
|
|
2
|
+
|
|
3
|
+
Facturación Open API es un proyecto de facturación electrónica para Ecuador compatible con la ficha técnica para comprobantes electrónicos emitido por el SRI.
|
|
4
|
+
|
|
5
|
+
Está publicada como librería y la puedes utilizar simplemente instalándola como dependencia en tu proyecto de Node o Bun.
|
|
6
|
+
|
|
7
|
+
### Funciones
|
|
8
|
+
|
|
9
|
+
La librería cuenta actualmente con las siguientes funciones:
|
|
10
|
+
|
|
11
|
+
- Tipado de campos para factura electrónica de acuerdo a las especificaciones del SRI.
|
|
12
|
+
- Generación de archivo JSON con formato de factura electrónica.
|
|
13
|
+
- Generación de XML con formato de factura electrónica.
|
|
14
|
+
- Firmado de XML con archivo .p12 (Compatible con Security Data y Banco Central)
|
|
15
|
+
- Envío de documento a endpoint de recepción del SRI
|
|
16
|
+
- Autorización de documento en endpoint del SRI
|
|
17
|
+
- Cargar Firma electrónica desde archivo local o URL
|
|
18
|
+
- Cargar XML desde archivo local o URL
|
|
19
|
+
|
|
20
|
+
### Ejemplo
|
|
21
|
+
|
|
22
|
+
Aquí puedes ver un ejemplo de cómo utilizar las funciones principales:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
import {
|
|
26
|
+
generateInvoice,
|
|
27
|
+
generateInvoiceXml,
|
|
28
|
+
getP12FromUrl,
|
|
29
|
+
signXml,
|
|
30
|
+
} from "facturacion-open-api";
|
|
31
|
+
|
|
32
|
+
const { invoice, accessKey } = generateInvoice({
|
|
33
|
+
infoTributaria: {
|
|
34
|
+
...
|
|
35
|
+
},
|
|
36
|
+
infoFactura: {
|
|
37
|
+
...
|
|
38
|
+
},
|
|
39
|
+
detalles: {
|
|
40
|
+
...
|
|
41
|
+
},
|
|
42
|
+
reembolsos: {
|
|
43
|
+
...
|
|
44
|
+
},
|
|
45
|
+
retenciones: {
|
|
46
|
+
...
|
|
47
|
+
},
|
|
48
|
+
infoSustitutivaGuiaRemision: {
|
|
49
|
+
...
|
|
50
|
+
},
|
|
51
|
+
otrosRubrosTerceros: {
|
|
52
|
+
...
|
|
53
|
+
},
|
|
54
|
+
tipoNegociable: { correo: "correo0" },
|
|
55
|
+
maquinaFiscal: {
|
|
56
|
+
...
|
|
57
|
+
},
|
|
58
|
+
infoAdicional: {
|
|
59
|
+
...
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const invoiceXml = generateInvoiceXml(invoice);
|
|
64
|
+
|
|
65
|
+
const signature: ArrayBuffer = await getP12FromUrl("yoururl");
|
|
66
|
+
const password = "yourpassword";
|
|
67
|
+
|
|
68
|
+
const signedInvoice = await signXml(sign, password, invoiceXml);
|
|
69
|
+
|
|
70
|
+
const receptionResult = await documentReception(
|
|
71
|
+
signedInvoice,
|
|
72
|
+
process.env.SRI_RECEPTION_URL!
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const authorizationResult = await documentAuthorization(
|
|
76
|
+
accessKey,
|
|
77
|
+
process.env.SRI_AUTHORIZATION_URL!
|
|
78
|
+
);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Un ejemplo completo lo puedes encontrar en la carpeta `tests`
|
|
82
|
+
Ejemplos de los archivos generados los encuentras en `src/example`
|
|
83
|
+
|
|
84
|
+
### Endpoints del SRI
|
|
85
|
+
|
|
86
|
+
El SRI ha habilitado dos endpoints para cada ambiente (pruebas, producción).
|
|
87
|
+
|
|
88
|
+
**Producción**
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
SRI_RECEPTION_URL="https://cel.sri.gob.ec/comprobantes-electronicos-ws/RecepcionComprobantesOffline?wsdl"
|
|
92
|
+
SRI_AUTHORIZATION_URL="https://cel.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline?wsdl"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Pruebas**
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
SRI_RECEPTION_URL="https://celcer.sri.gob.ec/comprobantes-electronicos-ws/RecepcionComprobantesOffline?wsdl"
|
|
99
|
+
SRI_AUTHORIZATION_URL="https://celcer.sri.gob.ec/comprobantes-electronicos-ws/AutorizacionComprobantesOffline?wsdl"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Ten en cuenta que para poder utilizar estos endpoints con tu RUC debes activar el ambiente de pruebas/producción en tu cuenta del SRI. [Aquí un tutorial de cómo hacerlo](https://www.factureromovil.com/pasos-para-habilitar-el-ambiente-de-produccion-en-sri)**
|
|
103
|
+
|
|
104
|
+
### Contribuir
|
|
105
|
+
|
|
106
|
+
Si deseas contribuir a este proyecto, crea un Pull Request con los cambios que pienses que pueden aportar para que el proyecto siga creciendo.
|