taxo-sri-xml-2-json 1.7.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/.changeset/README.md +8 -0
- package/.changeset/calm-dragons-agree.md +5 -0
- package/.changeset/config.json +11 -0
- package/.changeset/sixty-dragons-wink.md +5 -0
- package/.github/workflows/main.yml +21 -0
- package/.github/workflows/publish.yml +33 -0
- package/CHANGELOG.md +128 -0
- package/README.md +175 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +724 -0
- package/dist/index.mjs +692 -0
- package/package.json +32 -0
- package/src/documentUtils.ts +12 -0
- package/src/documents/bill.document.ts +158 -0
- package/src/documents/credit-note.document.ts +87 -0
- package/src/documents/debit_note.document.ts +70 -0
- package/src/documents/document.interface.ts +3 -0
- package/src/documents/retention.document.ts +114 -0
- package/src/documents/settlement.document.ts +95 -0
- package/src/enums.ts +7 -0
- package/src/fixtures.ts +2048 -0
- package/src/index.test.ts +193 -0
- package/src/index.ts +87 -0
- package/src/mapping.ts +113 -0
- package/src/run-example.ts +13 -0
- package/src/utils.ts +216 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changesets
|
|
2
|
+
|
|
3
|
+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
+
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
|
|
6
|
+
|
|
7
|
+
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
|
|
3
|
+
"changelog": "@changesets/cli/changelog",
|
|
4
|
+
"commit": false,
|
|
5
|
+
"fixed": [],
|
|
6
|
+
"linked": [],
|
|
7
|
+
"access": "public",
|
|
8
|
+
"baseBranch": "main",
|
|
9
|
+
"updateInternalDependencies": "patch",
|
|
10
|
+
"ignore": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- "hotfix/**"
|
|
6
|
+
- "feature/**"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v3
|
|
13
|
+
- uses: pnpm/action-setup@v2
|
|
14
|
+
with:
|
|
15
|
+
version: latest
|
|
16
|
+
- uses: actions/setup-node@v3
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20.x
|
|
19
|
+
cache: "pnpm"
|
|
20
|
+
- run: pnpm install --frozen-lockfile
|
|
21
|
+
- run: pnpm run ci
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- "main"
|
|
6
|
+
|
|
7
|
+
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
- uses: pnpm/action-setup@v2
|
|
19
|
+
with:
|
|
20
|
+
version: latest
|
|
21
|
+
- uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: 20.x
|
|
24
|
+
cache: "pnpm"
|
|
25
|
+
- run: pnpm install --frozen-lockfile
|
|
26
|
+
- name: Create Release Pull Request or Publish
|
|
27
|
+
id: changesets
|
|
28
|
+
uses: changesets/action@v1
|
|
29
|
+
with:
|
|
30
|
+
publish: pnpm run release
|
|
31
|
+
env:
|
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
33
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @taxo/sri-xml-2-json
|
|
2
|
+
|
|
3
|
+
## 1.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3a6846d: fix debit note
|
|
8
|
+
|
|
9
|
+
## 1.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- change of payment node in debit note
|
|
14
|
+
- 2f9856e: change nodo debit note
|
|
15
|
+
|
|
16
|
+
## 1.6.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- aa12ba3: remove space in number fields
|
|
21
|
+
|
|
22
|
+
## 1.5.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- be25d0e: formater large number as access key
|
|
27
|
+
|
|
28
|
+
## 1.4.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- b2cba8f: support credit note
|
|
33
|
+
|
|
34
|
+
## 1.2.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- bc61498: fix nc document no support read additional info
|
|
39
|
+
|
|
40
|
+
## 1.1.0
|
|
41
|
+
|
|
42
|
+
### Minor Changes
|
|
43
|
+
|
|
44
|
+
- e698509: Update readme documentation
|
|
45
|
+
|
|
46
|
+
## 1.0.0
|
|
47
|
+
|
|
48
|
+
### Major Changes
|
|
49
|
+
|
|
50
|
+
- 2f6279d: support original xml format
|
|
51
|
+
|
|
52
|
+
## 0.0.14
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- df0d859: fix: support bill without payment data
|
|
57
|
+
|
|
58
|
+
## 0.0.13
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- f1517de: fix parser
|
|
63
|
+
|
|
64
|
+
## 0.0.12
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- 2750c54: fix: retention parser
|
|
69
|
+
|
|
70
|
+
## 0.0.11
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- d0f4e0f: fix: retention
|
|
75
|
+
|
|
76
|
+
## 0.0.10
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- 68a2ace: support retention received
|
|
81
|
+
|
|
82
|
+
## 0.0.9
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- 939ce68: feat: mapping authorizationAt and status fields
|
|
87
|
+
|
|
88
|
+
## 0.0.8
|
|
89
|
+
|
|
90
|
+
### Patch Changes
|
|
91
|
+
|
|
92
|
+
- c5e2428: docs: add readme
|
|
93
|
+
|
|
94
|
+
## 0.0.7
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- e67f26b: feat: support credit note
|
|
99
|
+
|
|
100
|
+
## 0.0.6
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- 571699f: fix: no fill additional info when not is present in xml input
|
|
105
|
+
|
|
106
|
+
## 0.0.5
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- d7efd0f: fix: support additional info input as object
|
|
111
|
+
|
|
112
|
+
## 0.0.4
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- 556785d: support one product in bill
|
|
117
|
+
|
|
118
|
+
## 0.0.3
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- 85d32c5: feat: refactor bill parser
|
|
123
|
+
|
|
124
|
+
## 0.0.2
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- d634b93: support bill xml
|
package/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
## Simple XML 2 TO JSON parser to SRI documents
|
|
2
|
+
|
|
3
|
+
### Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
$ npm install taxo-sri-xml-2-json
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### Usage
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Ride } from "taxo-sri-xml-2-json";
|
|
13
|
+
const xmlDocument = "<xml>...</xml>";
|
|
14
|
+
const ride = new Ride(xmlDocument);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
const jsonString = await ride.convertToJson();
|
|
21
|
+
console.log(jsonString);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Example
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"infoTributaria": {
|
|
29
|
+
"ambiente": "PRODUCCIÓN",
|
|
30
|
+
"tipoEmision": "NORMAL",
|
|
31
|
+
"razonSocial": "SAURON S.A.",
|
|
32
|
+
"nombreComercial": "EL ANILLO UNICO",
|
|
33
|
+
"ruc": "1790322831001",
|
|
34
|
+
"claveAcceso": "2342202301179032283100120090210000671826226011210",
|
|
35
|
+
"codDoc": "01",
|
|
36
|
+
"estab": "009",
|
|
37
|
+
"ptoEmi": "021",
|
|
38
|
+
"secuencial": "000067182",
|
|
39
|
+
"dirMatriz": "LA COMARCA"
|
|
40
|
+
},
|
|
41
|
+
"infoDocumento": {
|
|
42
|
+
"tipo": "factura",
|
|
43
|
+
"fechaEmision": "24/12/2023",
|
|
44
|
+
"dirEstablecimiento": "LA COMARCA",
|
|
45
|
+
"contribuyenteEspecial": 5368,
|
|
46
|
+
"obligadoContabilidad": "SI",
|
|
47
|
+
"tipoIdentificacionComprador": "05",
|
|
48
|
+
"razonSocialComprador": "GANDALF EL GRIS",
|
|
49
|
+
"identificacionComprador": 12063133331,
|
|
50
|
+
"totalSinImpuestos": 27.1,
|
|
51
|
+
"totalDescuento": 3.02,
|
|
52
|
+
"propina": 0,
|
|
53
|
+
"importeTotal": 30.35,
|
|
54
|
+
"moneda": "DOLAR",
|
|
55
|
+
"valorRetIva": 0,
|
|
56
|
+
"valorRetRenta": 0,
|
|
57
|
+
"tipoIdentificacionCompradorNombre": "CÉDULA",
|
|
58
|
+
"pago": {
|
|
59
|
+
"formaPago": 19,
|
|
60
|
+
"total": 30.35,
|
|
61
|
+
"plazo": "0",
|
|
62
|
+
"unidadTiempo": "dias",
|
|
63
|
+
"formaPagoNombre": "TARJETA DE CRÉDITO"
|
|
64
|
+
},
|
|
65
|
+
"totalImpuestos": [
|
|
66
|
+
{
|
|
67
|
+
"codigo": 2,
|
|
68
|
+
"codigoPorcentaje": 2,
|
|
69
|
+
"baseImponible": 27.1,
|
|
70
|
+
"valor": 3.25,
|
|
71
|
+
"nombre": "IVA",
|
|
72
|
+
"porcentaje": "12%"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
"productos": [
|
|
77
|
+
{
|
|
78
|
+
"codigoPrincipal": "LAF.142039",
|
|
79
|
+
"codigoAuxiliar": "0000900133785",
|
|
80
|
+
"descripcion": "Producto de prueba",
|
|
81
|
+
"cantidad": 1,
|
|
82
|
+
"precioUnitario": 30.12,
|
|
83
|
+
"descuento": 3.02,
|
|
84
|
+
"precioTotalSinImpuesto": 27.1,
|
|
85
|
+
"impuestos": {
|
|
86
|
+
"codigo": 2,
|
|
87
|
+
"codigoPorcentaje": 2,
|
|
88
|
+
"tarifa": 12,
|
|
89
|
+
"baseImponible": 27.1,
|
|
90
|
+
"valor": 3.26,
|
|
91
|
+
"nombre": "IVA",
|
|
92
|
+
"porcentaje": "12%"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"codigoPrincipal": "FLX.funda1020x600 recicl",
|
|
97
|
+
"codigoAuxiliar": 23521926,
|
|
98
|
+
"descripcion": "producto de prueba 2",
|
|
99
|
+
"cantidad": 1,
|
|
100
|
+
"precioUnitario": 0,
|
|
101
|
+
"descuento": 0,
|
|
102
|
+
"precioTotalSinImpuesto": 0,
|
|
103
|
+
"impuestos": {
|
|
104
|
+
"codigo": 2,
|
|
105
|
+
"codigoPorcentaje": 2,
|
|
106
|
+
"tarifa": 12,
|
|
107
|
+
"baseImponible": 0,
|
|
108
|
+
"valor": 0,
|
|
109
|
+
"nombre": "IVA",
|
|
110
|
+
"porcentaje": "12%"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Publicar en npm
|
|
118
|
+
|
|
119
|
+
### Publicación directa (sin Changesets)
|
|
120
|
+
|
|
121
|
+
Desde la raíz del proyecto, con la sesión de npm iniciada o un token válido en `~/.npmrc`:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pnpm run lint && pnpm run test && pnpm run build
|
|
125
|
+
npm publish
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
O usando el script `release` (incluye lint, test, build y `changeset publish`):
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pnpm run release
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Para que `pnpm run release` publique en npm, hace falta estar autenticado (por ejemplo con `npm login` o con `//registry.npmjs.org/:_authToken=...` en `~/.npmrc`).
|
|
135
|
+
|
|
136
|
+
### Publicación con Changesets (versionado + CHANGELOG)
|
|
137
|
+
|
|
138
|
+
1. Crear un changeset (tipo de versión: patch / minor / major y mensaje):
|
|
139
|
+
```bash
|
|
140
|
+
pnpm changeset
|
|
141
|
+
```
|
|
142
|
+
2. Aplicar changesets (actualiza `package.json` y `CHANGELOG.md`):
|
|
143
|
+
```bash
|
|
144
|
+
pnpm changeset version
|
|
145
|
+
```
|
|
146
|
+
3. Publicar (lint, test, build y subida a npm):
|
|
147
|
+
```bash
|
|
148
|
+
pnpm run release
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### GitHub Actions
|
|
152
|
+
|
|
153
|
+
En cada push a `main`, el workflow `.github/workflows/publish.yml` puede ejecutar la publicación usando el secreto `NPM_TOKEN` del repositorio.
|
|
154
|
+
|
|
155
|
+
# MIT License
|
|
156
|
+
|
|
157
|
+
Copyright (c) 2024 - TAXO
|
|
158
|
+
|
|
159
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
160
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
161
|
+
in the Software without restriction, including without limitation the rights
|
|
162
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
163
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
164
|
+
furnished to do so, subject to the following conditions:
|
|
165
|
+
|
|
166
|
+
The above copyright notice and this permission notice shall be included in all
|
|
167
|
+
copies or substantial portions of the Software.
|
|
168
|
+
|
|
169
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
170
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
171
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
172
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
173
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
174
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
175
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare class Ride {
|
|
2
|
+
private xml;
|
|
3
|
+
constructor(input: string);
|
|
4
|
+
/**
|
|
5
|
+
* Convert the xml to json
|
|
6
|
+
* @returns {Promise<string>} json
|
|
7
|
+
* @memberof Ride
|
|
8
|
+
* @throws {Error} if the document is not supported
|
|
9
|
+
* @example
|
|
10
|
+
* const ride = new Ride(xml);
|
|
11
|
+
* const json = await ride.convertToJson();
|
|
12
|
+
* console.log(json);
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
convertToJson(): Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Ride };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare class Ride {
|
|
2
|
+
private xml;
|
|
3
|
+
constructor(input: string);
|
|
4
|
+
/**
|
|
5
|
+
* Convert the xml to json
|
|
6
|
+
* @returns {Promise<string>} json
|
|
7
|
+
* @memberof Ride
|
|
8
|
+
* @throws {Error} if the document is not supported
|
|
9
|
+
* @example
|
|
10
|
+
* const ride = new Ride(xml);
|
|
11
|
+
* const json = await ride.convertToJson();
|
|
12
|
+
* console.log(json);
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
convertToJson(): Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Ride };
|