dgii-ts 0.1.3 → 0.2.1
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/README.en.md +37 -3
- package/README.md +39 -3
- package/dist/bulk.d.cts +1 -1
- package/dist/bulk.d.ts +1 -1
- package/dist/{chunk-KJXLES3I.js → chunk-ABNHQAWP.js} +14 -4
- package/dist/{chunk-AML7LZBU.cjs → chunk-D6DU6PD3.cjs} +114 -11
- package/dist/chunk-H42U4GI5.js +49 -0
- package/dist/{chunk-YTX4QOLE.js → chunk-KMSKQH4U.js} +114 -11
- package/dist/chunk-OSGHCQFA.cjs +49 -0
- package/dist/{chunk-MUAPXS3H.cjs → chunk-QWP5FSCN.cjs} +15 -5
- package/dist/{chunk-TZC6RSWL.js → chunk-RTI3CLHV.js} +1 -48
- package/dist/{chunk-SUSDEKID.cjs → chunk-UW6W2JHW.cjs} +1 -48
- package/dist/client.cjs +4 -3
- package/dist/client.d.cts +13 -3
- package/dist/client.d.ts +13 -3
- package/dist/client.js +3 -2
- package/dist/{index-KNOaUG34.d.cts → index-BPvMDXya.d.cts} +32 -1
- package/dist/{index-KNOaUG34.d.ts → index-BPvMDXya.d.ts} +32 -1
- package/dist/index.cjs +8 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -5
- package/dist/scraping.cjs +3 -2
- package/dist/scraping.d.cts +14 -3
- package/dist/scraping.d.ts +14 -3
- package/dist/scraping.js +2 -1
- package/dist/soap.d.cts +1 -1
- package/dist/soap.d.ts +1 -1
- package/dist/validators.cjs +4 -2
- package/dist/validators.d.cts +1 -1
- package/dist/validators.d.ts +1 -1
- package/dist/validators.js +5 -3
- package/package.json +2 -2
package/README.en.md
CHANGED
|
@@ -135,9 +135,43 @@ const result = await client.getContribuyente('131098193');
|
|
|
135
135
|
|
|
136
136
|
```typescript
|
|
137
137
|
const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
138
|
-
// { rnc: '131098193', ncf: 'B0100000001',
|
|
138
|
+
// { valid: true, rnc: '131098193', ncf: 'B0100000001', nombreComercial: '...' }
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
+
### Validate an e-NCF online
|
|
142
|
+
|
|
143
|
+
For an e-NCF (E-series) DGII requires the buyer's RNC. Without it DGII
|
|
144
|
+
answers with a required-field message: `ScrapingClient.getNCF` throws
|
|
145
|
+
`DgiiServiceError` and `DgiiClient.getNCF` wraps it in
|
|
146
|
+
`AllStrategiesFailedError` after exhausting retries and the fallback
|
|
147
|
+
(the message keeps DGII's text). The security code is optional.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const ecfResult = await client.getNCF('101010632', 'E310125217173', {
|
|
151
|
+
rncComprador: '131262414',
|
|
152
|
+
codigoSeguridad: 'KrOLI0',
|
|
153
|
+
});
|
|
154
|
+
// {
|
|
155
|
+
// valid: true,
|
|
156
|
+
// rnc: '101010632',
|
|
157
|
+
// ncf: 'E310125217173',
|
|
158
|
+
// rncComprador: '131262414',
|
|
159
|
+
// codigoSeguridad: 'KrOLI0',
|
|
160
|
+
// estado: 'Aceptado',
|
|
161
|
+
// montoTotal: 230677.74,
|
|
162
|
+
// totalItbis: 35188.13,
|
|
163
|
+
// fechaEmision: '2026-02-11',
|
|
164
|
+
// fechaFirma: '2026-02-11',
|
|
165
|
+
// }
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`valid: true` means DGII found the document, not that it is accepted:
|
|
169
|
+
check `estado`. The fields `rncComprador`, `codigoSeguridad`, `estado`,
|
|
170
|
+
`montoTotal`, `totalItbis`, `fechaEmision` and `fechaFirma` are only
|
|
171
|
+
filled for the E-series, and `nombreComercial` is not filled for that
|
|
172
|
+
series. Dates are strings exactly as DGII renders them. The options are
|
|
173
|
+
ignored for a B-series NCF.
|
|
174
|
+
|
|
141
175
|
## API reference
|
|
142
176
|
|
|
143
177
|
### Validators
|
|
@@ -155,7 +189,7 @@ const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
|
155
189
|
| --- | --- |
|
|
156
190
|
| `DgiiClient` | Scraping + SOAP fallback, circuit breaker, retry |
|
|
157
191
|
| `client.getContribuyente(rnc)` | Looks up taxpayer data by RNC |
|
|
158
|
-
| `client.getNCF(rnc, ncf)` | Validates a fiscal receipt against DGII |
|
|
192
|
+
| `client.getNCF(rnc, ncf, options?)` | Validates a fiscal receipt against DGII (`options` for e-NCF) |
|
|
159
193
|
|
|
160
194
|
### Scraping
|
|
161
195
|
|
|
@@ -163,7 +197,7 @@ const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
|
163
197
|
| --- | --- |
|
|
164
198
|
| `ScrapingClient` | Queries DGII's ASP.NET pages |
|
|
165
199
|
| `client.getContribuyente(rnc)` | Looks up taxpayer data by RNC |
|
|
166
|
-
| `client.getNCF(rnc, ncf)` | Validates a fiscal receipt |
|
|
200
|
+
| `client.getNCF(rnc, ncf, options?)` | Validates a fiscal receipt (`options` for e-NCF) |
|
|
167
201
|
|
|
168
202
|
### SOAP client (deprecated)
|
|
169
203
|
|
package/README.md
CHANGED
|
@@ -138,9 +138,45 @@ const result = await client.getContribuyente('131098193');
|
|
|
138
138
|
|
|
139
139
|
```typescript
|
|
140
140
|
const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
141
|
-
// { rnc: '131098193', ncf: 'B0100000001',
|
|
141
|
+
// { valid: true, rnc: '131098193', ncf: 'B0100000001', nombreComercial: '...' }
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
+
### Validar e-NCF en línea
|
|
145
|
+
|
|
146
|
+
Para un e-NCF (serie E) la DGII exige el RNC del comprador. Sin él
|
|
147
|
+
responde con un mensaje de campo requerido: `ScrapingClient.getNCF`
|
|
148
|
+
lanza `DgiiServiceError` y `DgiiClient.getNCF` lo envuelve en
|
|
149
|
+
`AllStrategiesFailedError` tras agotar reintentos y fallback (el
|
|
150
|
+
mensaje conserva el texto de la DGII). El código de seguridad es
|
|
151
|
+
opcional.
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
const ecfResult = await client.getNCF('101010632', 'E310125217173', {
|
|
155
|
+
rncComprador: '131262414',
|
|
156
|
+
codigoSeguridad: 'KrOLI0',
|
|
157
|
+
});
|
|
158
|
+
// {
|
|
159
|
+
// valid: true,
|
|
160
|
+
// rnc: '101010632',
|
|
161
|
+
// ncf: 'E310125217173',
|
|
162
|
+
// rncComprador: '131262414',
|
|
163
|
+
// codigoSeguridad: 'KrOLI0',
|
|
164
|
+
// estado: 'Aceptado',
|
|
165
|
+
// montoTotal: 230677.74,
|
|
166
|
+
// totalItbis: 35188.13,
|
|
167
|
+
// fechaEmision: '2026-02-11',
|
|
168
|
+
// fechaFirma: '2026-02-11',
|
|
169
|
+
// }
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`valid: true` significa que la DGII encontró el comprobante, no que
|
|
173
|
+
esté aceptado: revisa `estado`. Los campos `rncComprador`,
|
|
174
|
+
`codigoSeguridad`, `estado`, `montoTotal`, `totalItbis`,
|
|
175
|
+
`fechaEmision` y `fechaFirma` solo se llenan para la serie E, y
|
|
176
|
+
`nombreComercial` no se llena para esa serie. Las fechas son strings
|
|
177
|
+
tal como la DGII las renderiza. Las opciones se ignoran para un NCF de
|
|
178
|
+
serie B.
|
|
179
|
+
|
|
144
180
|
## Referencia del API
|
|
145
181
|
|
|
146
182
|
### Validadores
|
|
@@ -158,7 +194,7 @@ const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
|
158
194
|
| --- | --- |
|
|
159
195
|
| `DgiiClient` | Cliente con scraping + SOAP fallback, circuit breaker y retry |
|
|
160
196
|
| `client.getContribuyente(rnc)` | Consulta datos de un contribuyente por RNC |
|
|
161
|
-
| `client.getNCF(rnc, ncf)` | Valida un comprobante fiscal contra la DGII |
|
|
197
|
+
| `client.getNCF(rnc, ncf, options?)` | Valida un comprobante fiscal contra la DGII (`options` para e-NCF) |
|
|
162
198
|
|
|
163
199
|
### Scraping
|
|
164
200
|
|
|
@@ -166,7 +202,7 @@ const ncfResult = await client.getNCF('131098193', 'B0100000001');
|
|
|
166
202
|
| --- | --- |
|
|
167
203
|
| `ScrapingClient` | Consulta páginas ASP.NET de la DGII |
|
|
168
204
|
| `client.getContribuyente(rnc)` | Consulta contribuyente por RNC |
|
|
169
|
-
| `client.getNCF(rnc, ncf)` | Valida comprobante fiscal |
|
|
205
|
+
| `client.getNCF(rnc, ncf, options?)` | Valida comprobante fiscal (`options` para e-NCF) |
|
|
170
206
|
|
|
171
207
|
### Cliente SOAP (deprecated)
|
|
172
208
|
|
package/dist/bulk.d.cts
CHANGED
package/dist/bulk.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-QTN5ZT4P.js";
|
|
4
4
|
import {
|
|
5
5
|
ScrapingClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KMSKQH4U.js";
|
|
7
7
|
import {
|
|
8
8
|
AllStrategiesFailedError,
|
|
9
9
|
DgiiConnectionError,
|
|
@@ -150,11 +150,21 @@ var DgiiClient = class {
|
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
|
-
* Valida un comprobante fiscal
|
|
153
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
154
|
+
*
|
|
155
|
+
* @param rnc - RNC del emisor
|
|
156
|
+
* @param ncf - NCF o e-NCF a validar
|
|
157
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
158
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
159
|
+
*
|
|
160
|
+
* Para un e-NCF sin `rncComprador` la DGII responde con un mensaje de
|
|
161
|
+
* campo requerido: `ScrapingClient.getNCF` lanza `DgiiServiceError` y
|
|
162
|
+
* este método lo envuelve en `AllStrategiesFailedError` tras agotar
|
|
163
|
+
* reintentos y fallback (el mensaje conserva el texto de la DGII).
|
|
154
164
|
*/
|
|
155
|
-
async getNCF(rnc, ncf) {
|
|
165
|
+
async getNCF(rnc, ncf, options) {
|
|
156
166
|
return this._executeWithFallback(
|
|
157
|
-
(client) => client.getNCF(rnc, ncf)
|
|
167
|
+
(client) => client.getNCF(rnc, ncf, options)
|
|
158
168
|
);
|
|
159
169
|
}
|
|
160
170
|
async _executeWithFallback(operation) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
+
var _chunkOSGHCQFAcjs = require('./chunk-OSGHCQFA.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
var _chunkWMFHPNFPcjs = require('./chunk-WMFHPNFP.cjs');
|
|
4
7
|
|
|
5
8
|
|
|
@@ -21,10 +24,24 @@ var FORM_FIELDS = /* @__PURE__ */ Object.freeze({
|
|
|
21
24
|
rncSubmit: "ctl00$cphMain$btnBuscarPorRNC",
|
|
22
25
|
ncfRncInput: "ctl00$cphMain$txtRNC",
|
|
23
26
|
ncfInput: "ctl00$cphMain$txtNCF",
|
|
24
|
-
ncfSubmit: "ctl00$cphMain$btnConsultar"
|
|
27
|
+
ncfSubmit: "ctl00$cphMain$btnConsultar",
|
|
28
|
+
// Campos adicionales para e-NCF (serie E)
|
|
29
|
+
ncfRncCompradorInput: "ctl00$cphMain$txtRncComprador",
|
|
30
|
+
ncfCodigoSeguridadInput: "ctl00$cphMain$txtCodigoSeg"
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
// src/scraping/html-parser.ts
|
|
34
|
+
var NCF_INVALID_PHRASES = /* @__PURE__ */ Object.freeze([
|
|
35
|
+
"no es v",
|
|
36
|
+
"no se encuentra",
|
|
37
|
+
"no existe",
|
|
38
|
+
// Respuesta de la DGII a un e-NCF con código de seguridad incorrecto
|
|
39
|
+
"no encontrado"
|
|
40
|
+
]);
|
|
41
|
+
function isKnownInvalidMessage(message) {
|
|
42
|
+
const normalized = message.toLowerCase();
|
|
43
|
+
return NCF_INVALID_PHRASES.some((phrase) => normalized.includes(phrase));
|
|
44
|
+
}
|
|
28
45
|
function extractViewStateTokens(html) {
|
|
29
46
|
const viewState = extractInputValue(html, "__VIEWSTATE");
|
|
30
47
|
const viewStateGenerator = extractInputValue(html, "__VIEWSTATEGENERATOR");
|
|
@@ -91,7 +108,7 @@ function parseNcfHtml(html) {
|
|
|
91
108
|
const infoEnd = html.indexOf("</span>", infoStart);
|
|
92
109
|
if (infoEnd !== -1) {
|
|
93
110
|
const infoBlock = html.slice(infoStart, infoEnd);
|
|
94
|
-
if (
|
|
111
|
+
if (isKnownInvalidMessage(infoBlock)) {
|
|
95
112
|
return { valid: false, rnc: "", ncf: "", nombreComercial: void 0 };
|
|
96
113
|
}
|
|
97
114
|
}
|
|
@@ -121,6 +138,58 @@ function parseNcfHtml(html) {
|
|
|
121
138
|
nombreComercial: nombreComercial ? _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, nombreComercial) : void 0
|
|
122
139
|
};
|
|
123
140
|
}
|
|
141
|
+
function parseEcfHtml(html) {
|
|
142
|
+
const info = extractSpanValue(html, "cphMain_lblInformacion");
|
|
143
|
+
if (info && isKnownInvalidMessage(info)) {
|
|
144
|
+
return { valid: false, rnc: "", ncf: "" };
|
|
145
|
+
}
|
|
146
|
+
if (info) {
|
|
147
|
+
throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(`La DGII respondi\xF3: ${info}`);
|
|
148
|
+
}
|
|
149
|
+
if (!html.includes("cphMain_PResultadoFE")) {
|
|
150
|
+
throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
|
|
151
|
+
"Formato de respuesta HTML inesperado: panel de resultado e-NCF no encontrado"
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const rncEmisor = extractSpanValue(html, "cphMain_lblrncemisor");
|
|
155
|
+
const ncf = extractSpanValue(html, "cphMain_lblencf");
|
|
156
|
+
if (!rncEmisor && !ncf) {
|
|
157
|
+
throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
|
|
158
|
+
"Formato de respuesta HTML inesperado: panel e-NCF sin emisor ni e-NCF"
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const rncComprador = extractSpanValue(html, "cphMain_lblrnccomprador");
|
|
162
|
+
const codigoSeguridad = extractSpanValue(html, "cphMain_lblCodSeguridad");
|
|
163
|
+
const estado = extractSpanValue(html, "cphMain_lblEstadoFe");
|
|
164
|
+
const fechaEmision = extractSpanValue(html, "cphMain_lblFechaEmision");
|
|
165
|
+
const fechaFirma = extractSpanValue(html, "cphMain_lblFechaFirma");
|
|
166
|
+
return {
|
|
167
|
+
valid: true,
|
|
168
|
+
rnc: _chunkQH4BK5X3cjs.stripNonDigits.call(void 0, rncEmisor),
|
|
169
|
+
ncf: _chunkQH4BK5X3cjs.collapseSpaces.call(void 0, ncf),
|
|
170
|
+
rncComprador: rncComprador ? _chunkQH4BK5X3cjs.stripNonDigits.call(void 0, rncComprador) : void 0,
|
|
171
|
+
codigoSeguridad: codigoSeguridad || void 0,
|
|
172
|
+
estado: estado || void 0,
|
|
173
|
+
montoTotal: parseAmount(extractSpanValue(html, "cphMain_lblMontoTotal")),
|
|
174
|
+
totalItbis: parseAmount(extractSpanValue(html, "cphMain_lblTotalItbis")),
|
|
175
|
+
fechaEmision: fechaEmision || void 0,
|
|
176
|
+
fechaFirma: fechaFirma || void 0
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function parseAmount(raw) {
|
|
180
|
+
if (!raw) return void 0;
|
|
181
|
+
const value = Number(raw.replace(/,/g, ""));
|
|
182
|
+
return Number.isFinite(value) ? value : void 0;
|
|
183
|
+
}
|
|
184
|
+
function extractSpanValue(html, spanId) {
|
|
185
|
+
const idx = html.indexOf(`id="${spanId}"`);
|
|
186
|
+
if (idx === -1) return "";
|
|
187
|
+
const tagEnd = html.indexOf(">", idx);
|
|
188
|
+
if (tagEnd === -1) return "";
|
|
189
|
+
const closeTag = html.indexOf("</span>", tagEnd);
|
|
190
|
+
if (closeTag === -1) return "";
|
|
191
|
+
return decodeHtmlEntities(stripHtmlTags(html.slice(tagEnd + 1, closeTag)));
|
|
192
|
+
}
|
|
124
193
|
function extractInputValue(html, name) {
|
|
125
194
|
let idx = html.indexOf(`id="${name}"`);
|
|
126
195
|
if (idx === -1) {
|
|
@@ -141,13 +210,13 @@ function extractTableFields(tableHtml) {
|
|
|
141
210
|
const fields = /* @__PURE__ */ new Map();
|
|
142
211
|
for (const match of tableHtml.matchAll(BOLD_STYLE_PATTERN)) {
|
|
143
212
|
const label = normalizeLabel(_nullishCoalesce(match[1], () => ( "")));
|
|
144
|
-
const value = stripHtmlTags(_nullishCoalesce(match[2], () => ( "")));
|
|
213
|
+
const value = decodeHtmlEntities(stripHtmlTags(_nullishCoalesce(match[2], () => ( ""))));
|
|
145
214
|
if (label) fields.set(label, value);
|
|
146
215
|
}
|
|
147
216
|
if (fields.size === 0) {
|
|
148
217
|
for (const match of tableHtml.matchAll(BOLD_TAG_PATTERN)) {
|
|
149
218
|
const label = normalizeLabel(_nullishCoalesce(match[1], () => ( "")));
|
|
150
|
-
const value = stripHtmlTags(_nullishCoalesce(match[2], () => ( "")));
|
|
219
|
+
const value = decodeHtmlEntities(stripHtmlTags(_nullishCoalesce(match[2], () => ( ""))));
|
|
151
220
|
if (label) fields.set(label, value);
|
|
152
221
|
}
|
|
153
222
|
}
|
|
@@ -201,26 +270,60 @@ var ScrapingClient = class {
|
|
|
201
270
|
return parseContribuyenteHtml(html);
|
|
202
271
|
}
|
|
203
272
|
/**
|
|
204
|
-
* Valida un comprobante fiscal
|
|
273
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
274
|
+
*
|
|
275
|
+
* Soporta NCF (serie B) y e-NCF (serie E). Para un e-NCF la DGII
|
|
276
|
+
* exige el RNC del comprador; sin él responde con un mensaje de campo
|
|
277
|
+
* requerido y este método lanza `DgiiServiceError`.
|
|
278
|
+
*
|
|
279
|
+
* @param rnc - RNC del emisor
|
|
280
|
+
* @param ncf - NCF o e-NCF a validar
|
|
281
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
282
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
205
283
|
*/
|
|
206
|
-
async getNCF(rnc, ncf) {
|
|
284
|
+
async getNCF(rnc, ncf, options) {
|
|
207
285
|
if (typeof rnc !== "string" || rnc.trim() === "") {
|
|
208
286
|
throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro rnc es requerido");
|
|
209
287
|
}
|
|
210
288
|
if (typeof ncf !== "string" || ncf.trim() === "") {
|
|
211
289
|
throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)("El par\xE1metro ncf es requerido");
|
|
212
290
|
}
|
|
291
|
+
const rncComprador = _optionalChain([options, 'optionalAccess', _6 => _6.rncComprador]);
|
|
292
|
+
if (rncComprador !== void 0 && (typeof rncComprador !== "string" || rncComprador.trim() === "")) {
|
|
293
|
+
throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
|
|
294
|
+
"La opci\xF3n rncComprador debe ser un string no vac\xEDo"
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
const codigoSeguridad = _optionalChain([options, 'optionalAccess', _7 => _7.codigoSeguridad]);
|
|
298
|
+
if (codigoSeguridad !== void 0 && (typeof codigoSeguridad !== "string" || codigoSeguridad.trim() === "")) {
|
|
299
|
+
throw new (0, _chunkNASWEFHNcjs.DgiiServiceError)(
|
|
300
|
+
"La opci\xF3n codigoSeguridad debe ser un string no vac\xEDo"
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
const isEcf = _chunkOSGHCQFAcjs.validateEcf.call(void 0, ncf).valid;
|
|
213
304
|
const tokens = await this._fetchTokens(this._ncfUrl);
|
|
214
|
-
const
|
|
305
|
+
const fields = [
|
|
215
306
|
[FORM_FIELDS.viewState, tokens.viewState],
|
|
216
307
|
[FORM_FIELDS.viewStateGenerator, tokens.viewStateGenerator],
|
|
217
308
|
[FORM_FIELDS.eventValidation, tokens.eventValidation],
|
|
218
309
|
[FORM_FIELDS.ncfRncInput, rnc.trim()],
|
|
219
|
-
[FORM_FIELDS.ncfInput, ncf.trim()]
|
|
220
|
-
|
|
221
|
-
|
|
310
|
+
[FORM_FIELDS.ncfInput, ncf.trim()]
|
|
311
|
+
];
|
|
312
|
+
if (isEcf) {
|
|
313
|
+
if (rncComprador !== void 0) {
|
|
314
|
+
fields.push([FORM_FIELDS.ncfRncCompradorInput, rncComprador.trim()]);
|
|
315
|
+
}
|
|
316
|
+
if (codigoSeguridad !== void 0) {
|
|
317
|
+
fields.push([
|
|
318
|
+
FORM_FIELDS.ncfCodigoSeguridadInput,
|
|
319
|
+
codigoSeguridad.trim()
|
|
320
|
+
]);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
fields.push([FORM_FIELDS.ncfSubmit, "Buscar"]);
|
|
324
|
+
const body = buildFormBody(fields);
|
|
222
325
|
const html = await this._post(this._ncfUrl, body);
|
|
223
|
-
return parseNcfHtml(html);
|
|
326
|
+
return isEcf ? parseEcfHtml(html) : parseNcfHtml(html);
|
|
224
327
|
}
|
|
225
328
|
async _fetchTokens(url) {
|
|
226
329
|
let response;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/validators/ecf.ts
|
|
2
|
+
var ECF_TYPES = /* @__PURE__ */ Object.freeze({
|
|
3
|
+
"31": "CREDITO_FISCAL_ELECTRONICA",
|
|
4
|
+
"32": "CONSUMO_ELECTRONICA",
|
|
5
|
+
"33": "NOTA_DE_DEBITO_ELECTRONICA",
|
|
6
|
+
"34": "NOTA_DE_CREDITO_ELECTRONICA",
|
|
7
|
+
"41": "COMPRAS_ELECTRONICO",
|
|
8
|
+
"43": "GASTOS_MENORES_ELECTRONICO",
|
|
9
|
+
"44": "REGIMENES_ESPECIALES_ELECTRONICO",
|
|
10
|
+
"45": "GUBERNAMENTAL_ELECTRONICO",
|
|
11
|
+
"46": "EXPORTACIONES_ELECTRONICO",
|
|
12
|
+
"47": "PAGOS_AL_EXTERIOR_ELECTRONICO"
|
|
13
|
+
});
|
|
14
|
+
var ECF_TYPE_NAMES = /* @__PURE__ */ Object.freeze({
|
|
15
|
+
"31": "Factura de cr\xE9dito fiscal electr\xF3nica",
|
|
16
|
+
"32": "Factura de consumo electr\xF3nica",
|
|
17
|
+
"33": "Nota de d\xE9bito electr\xF3nica",
|
|
18
|
+
"34": "Nota de cr\xE9dito electr\xF3nica",
|
|
19
|
+
"41": "Comprobante electr\xF3nico de compras",
|
|
20
|
+
"43": "Comprobante electr\xF3nico para gastos menores",
|
|
21
|
+
"44": "Comprobante electr\xF3nico para reg\xEDmenes especiales",
|
|
22
|
+
"45": "Comprobante electr\xF3nico gubernamental",
|
|
23
|
+
"46": "Comprobante electr\xF3nico para exportaciones",
|
|
24
|
+
"47": "Comprobante electr\xF3nico para pagos al exterior"
|
|
25
|
+
});
|
|
26
|
+
var ECF_PATTERN = /^E(\d{2})(\d{10})$/;
|
|
27
|
+
function validateEcf(value) {
|
|
28
|
+
if (typeof value !== "string") return { valid: false };
|
|
29
|
+
const normalized = value.toUpperCase().trim();
|
|
30
|
+
const match = ECF_PATTERN.exec(normalized);
|
|
31
|
+
if (!match) {
|
|
32
|
+
return { valid: false };
|
|
33
|
+
}
|
|
34
|
+
const typeCode = match[1];
|
|
35
|
+
const type = ECF_TYPES[typeCode];
|
|
36
|
+
if (!type) {
|
|
37
|
+
return { valid: false };
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
valid: true,
|
|
41
|
+
type,
|
|
42
|
+
serie: `E${typeCode}`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
ECF_TYPE_NAMES,
|
|
48
|
+
validateEcf
|
|
49
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
validateEcf
|
|
3
|
+
} from "./chunk-H42U4GI5.js";
|
|
1
4
|
import {
|
|
2
5
|
wrapFetchError
|
|
3
6
|
} from "./chunk-KW4ZV6FJ.js";
|
|
@@ -21,10 +24,24 @@ var FORM_FIELDS = /* @__PURE__ */ Object.freeze({
|
|
|
21
24
|
rncSubmit: "ctl00$cphMain$btnBuscarPorRNC",
|
|
22
25
|
ncfRncInput: "ctl00$cphMain$txtRNC",
|
|
23
26
|
ncfInput: "ctl00$cphMain$txtNCF",
|
|
24
|
-
ncfSubmit: "ctl00$cphMain$btnConsultar"
|
|
27
|
+
ncfSubmit: "ctl00$cphMain$btnConsultar",
|
|
28
|
+
// Campos adicionales para e-NCF (serie E)
|
|
29
|
+
ncfRncCompradorInput: "ctl00$cphMain$txtRncComprador",
|
|
30
|
+
ncfCodigoSeguridadInput: "ctl00$cphMain$txtCodigoSeg"
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
// src/scraping/html-parser.ts
|
|
34
|
+
var NCF_INVALID_PHRASES = /* @__PURE__ */ Object.freeze([
|
|
35
|
+
"no es v",
|
|
36
|
+
"no se encuentra",
|
|
37
|
+
"no existe",
|
|
38
|
+
// Respuesta de la DGII a un e-NCF con código de seguridad incorrecto
|
|
39
|
+
"no encontrado"
|
|
40
|
+
]);
|
|
41
|
+
function isKnownInvalidMessage(message) {
|
|
42
|
+
const normalized = message.toLowerCase();
|
|
43
|
+
return NCF_INVALID_PHRASES.some((phrase) => normalized.includes(phrase));
|
|
44
|
+
}
|
|
28
45
|
function extractViewStateTokens(html) {
|
|
29
46
|
const viewState = extractInputValue(html, "__VIEWSTATE");
|
|
30
47
|
const viewStateGenerator = extractInputValue(html, "__VIEWSTATEGENERATOR");
|
|
@@ -91,7 +108,7 @@ function parseNcfHtml(html) {
|
|
|
91
108
|
const infoEnd = html.indexOf("</span>", infoStart);
|
|
92
109
|
if (infoEnd !== -1) {
|
|
93
110
|
const infoBlock = html.slice(infoStart, infoEnd);
|
|
94
|
-
if (
|
|
111
|
+
if (isKnownInvalidMessage(infoBlock)) {
|
|
95
112
|
return { valid: false, rnc: "", ncf: "", nombreComercial: void 0 };
|
|
96
113
|
}
|
|
97
114
|
}
|
|
@@ -121,6 +138,58 @@ function parseNcfHtml(html) {
|
|
|
121
138
|
nombreComercial: nombreComercial ? collapseSpaces(nombreComercial) : void 0
|
|
122
139
|
};
|
|
123
140
|
}
|
|
141
|
+
function parseEcfHtml(html) {
|
|
142
|
+
const info = extractSpanValue(html, "cphMain_lblInformacion");
|
|
143
|
+
if (info && isKnownInvalidMessage(info)) {
|
|
144
|
+
return { valid: false, rnc: "", ncf: "" };
|
|
145
|
+
}
|
|
146
|
+
if (info) {
|
|
147
|
+
throw new DgiiServiceError(`La DGII respondi\xF3: ${info}`);
|
|
148
|
+
}
|
|
149
|
+
if (!html.includes("cphMain_PResultadoFE")) {
|
|
150
|
+
throw new DgiiServiceError(
|
|
151
|
+
"Formato de respuesta HTML inesperado: panel de resultado e-NCF no encontrado"
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const rncEmisor = extractSpanValue(html, "cphMain_lblrncemisor");
|
|
155
|
+
const ncf = extractSpanValue(html, "cphMain_lblencf");
|
|
156
|
+
if (!rncEmisor && !ncf) {
|
|
157
|
+
throw new DgiiServiceError(
|
|
158
|
+
"Formato de respuesta HTML inesperado: panel e-NCF sin emisor ni e-NCF"
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
const rncComprador = extractSpanValue(html, "cphMain_lblrnccomprador");
|
|
162
|
+
const codigoSeguridad = extractSpanValue(html, "cphMain_lblCodSeguridad");
|
|
163
|
+
const estado = extractSpanValue(html, "cphMain_lblEstadoFe");
|
|
164
|
+
const fechaEmision = extractSpanValue(html, "cphMain_lblFechaEmision");
|
|
165
|
+
const fechaFirma = extractSpanValue(html, "cphMain_lblFechaFirma");
|
|
166
|
+
return {
|
|
167
|
+
valid: true,
|
|
168
|
+
rnc: stripNonDigits(rncEmisor),
|
|
169
|
+
ncf: collapseSpaces(ncf),
|
|
170
|
+
rncComprador: rncComprador ? stripNonDigits(rncComprador) : void 0,
|
|
171
|
+
codigoSeguridad: codigoSeguridad || void 0,
|
|
172
|
+
estado: estado || void 0,
|
|
173
|
+
montoTotal: parseAmount(extractSpanValue(html, "cphMain_lblMontoTotal")),
|
|
174
|
+
totalItbis: parseAmount(extractSpanValue(html, "cphMain_lblTotalItbis")),
|
|
175
|
+
fechaEmision: fechaEmision || void 0,
|
|
176
|
+
fechaFirma: fechaFirma || void 0
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function parseAmount(raw) {
|
|
180
|
+
if (!raw) return void 0;
|
|
181
|
+
const value = Number(raw.replace(/,/g, ""));
|
|
182
|
+
return Number.isFinite(value) ? value : void 0;
|
|
183
|
+
}
|
|
184
|
+
function extractSpanValue(html, spanId) {
|
|
185
|
+
const idx = html.indexOf(`id="${spanId}"`);
|
|
186
|
+
if (idx === -1) return "";
|
|
187
|
+
const tagEnd = html.indexOf(">", idx);
|
|
188
|
+
if (tagEnd === -1) return "";
|
|
189
|
+
const closeTag = html.indexOf("</span>", tagEnd);
|
|
190
|
+
if (closeTag === -1) return "";
|
|
191
|
+
return decodeHtmlEntities(stripHtmlTags(html.slice(tagEnd + 1, closeTag)));
|
|
192
|
+
}
|
|
124
193
|
function extractInputValue(html, name) {
|
|
125
194
|
let idx = html.indexOf(`id="${name}"`);
|
|
126
195
|
if (idx === -1) {
|
|
@@ -141,13 +210,13 @@ function extractTableFields(tableHtml) {
|
|
|
141
210
|
const fields = /* @__PURE__ */ new Map();
|
|
142
211
|
for (const match of tableHtml.matchAll(BOLD_STYLE_PATTERN)) {
|
|
143
212
|
const label = normalizeLabel(match[1] ?? "");
|
|
144
|
-
const value = stripHtmlTags(match[2] ?? "");
|
|
213
|
+
const value = decodeHtmlEntities(stripHtmlTags(match[2] ?? ""));
|
|
145
214
|
if (label) fields.set(label, value);
|
|
146
215
|
}
|
|
147
216
|
if (fields.size === 0) {
|
|
148
217
|
for (const match of tableHtml.matchAll(BOLD_TAG_PATTERN)) {
|
|
149
218
|
const label = normalizeLabel(match[1] ?? "");
|
|
150
|
-
const value = stripHtmlTags(match[2] ?? "");
|
|
219
|
+
const value = decodeHtmlEntities(stripHtmlTags(match[2] ?? ""));
|
|
151
220
|
if (label) fields.set(label, value);
|
|
152
221
|
}
|
|
153
222
|
}
|
|
@@ -201,26 +270,60 @@ var ScrapingClient = class {
|
|
|
201
270
|
return parseContribuyenteHtml(html);
|
|
202
271
|
}
|
|
203
272
|
/**
|
|
204
|
-
* Valida un comprobante fiscal
|
|
273
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
274
|
+
*
|
|
275
|
+
* Soporta NCF (serie B) y e-NCF (serie E). Para un e-NCF la DGII
|
|
276
|
+
* exige el RNC del comprador; sin él responde con un mensaje de campo
|
|
277
|
+
* requerido y este método lanza `DgiiServiceError`.
|
|
278
|
+
*
|
|
279
|
+
* @param rnc - RNC del emisor
|
|
280
|
+
* @param ncf - NCF o e-NCF a validar
|
|
281
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
282
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
205
283
|
*/
|
|
206
|
-
async getNCF(rnc, ncf) {
|
|
284
|
+
async getNCF(rnc, ncf, options) {
|
|
207
285
|
if (typeof rnc !== "string" || rnc.trim() === "") {
|
|
208
286
|
throw new DgiiServiceError("El par\xE1metro rnc es requerido");
|
|
209
287
|
}
|
|
210
288
|
if (typeof ncf !== "string" || ncf.trim() === "") {
|
|
211
289
|
throw new DgiiServiceError("El par\xE1metro ncf es requerido");
|
|
212
290
|
}
|
|
291
|
+
const rncComprador = options?.rncComprador;
|
|
292
|
+
if (rncComprador !== void 0 && (typeof rncComprador !== "string" || rncComprador.trim() === "")) {
|
|
293
|
+
throw new DgiiServiceError(
|
|
294
|
+
"La opci\xF3n rncComprador debe ser un string no vac\xEDo"
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
const codigoSeguridad = options?.codigoSeguridad;
|
|
298
|
+
if (codigoSeguridad !== void 0 && (typeof codigoSeguridad !== "string" || codigoSeguridad.trim() === "")) {
|
|
299
|
+
throw new DgiiServiceError(
|
|
300
|
+
"La opci\xF3n codigoSeguridad debe ser un string no vac\xEDo"
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
const isEcf = validateEcf(ncf).valid;
|
|
213
304
|
const tokens = await this._fetchTokens(this._ncfUrl);
|
|
214
|
-
const
|
|
305
|
+
const fields = [
|
|
215
306
|
[FORM_FIELDS.viewState, tokens.viewState],
|
|
216
307
|
[FORM_FIELDS.viewStateGenerator, tokens.viewStateGenerator],
|
|
217
308
|
[FORM_FIELDS.eventValidation, tokens.eventValidation],
|
|
218
309
|
[FORM_FIELDS.ncfRncInput, rnc.trim()],
|
|
219
|
-
[FORM_FIELDS.ncfInput, ncf.trim()]
|
|
220
|
-
|
|
221
|
-
|
|
310
|
+
[FORM_FIELDS.ncfInput, ncf.trim()]
|
|
311
|
+
];
|
|
312
|
+
if (isEcf) {
|
|
313
|
+
if (rncComprador !== void 0) {
|
|
314
|
+
fields.push([FORM_FIELDS.ncfRncCompradorInput, rncComprador.trim()]);
|
|
315
|
+
}
|
|
316
|
+
if (codigoSeguridad !== void 0) {
|
|
317
|
+
fields.push([
|
|
318
|
+
FORM_FIELDS.ncfCodigoSeguridadInput,
|
|
319
|
+
codigoSeguridad.trim()
|
|
320
|
+
]);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
fields.push([FORM_FIELDS.ncfSubmit, "Buscar"]);
|
|
324
|
+
const body = buildFormBody(fields);
|
|
222
325
|
const html = await this._post(this._ncfUrl, body);
|
|
223
|
-
return parseNcfHtml(html);
|
|
326
|
+
return isEcf ? parseEcfHtml(html) : parseNcfHtml(html);
|
|
224
327
|
}
|
|
225
328
|
async _fetchTokens(url) {
|
|
226
329
|
let response;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/validators/ecf.ts
|
|
2
|
+
var ECF_TYPES = /* @__PURE__ */ Object.freeze({
|
|
3
|
+
"31": "CREDITO_FISCAL_ELECTRONICA",
|
|
4
|
+
"32": "CONSUMO_ELECTRONICA",
|
|
5
|
+
"33": "NOTA_DE_DEBITO_ELECTRONICA",
|
|
6
|
+
"34": "NOTA_DE_CREDITO_ELECTRONICA",
|
|
7
|
+
"41": "COMPRAS_ELECTRONICO",
|
|
8
|
+
"43": "GASTOS_MENORES_ELECTRONICO",
|
|
9
|
+
"44": "REGIMENES_ESPECIALES_ELECTRONICO",
|
|
10
|
+
"45": "GUBERNAMENTAL_ELECTRONICO",
|
|
11
|
+
"46": "EXPORTACIONES_ELECTRONICO",
|
|
12
|
+
"47": "PAGOS_AL_EXTERIOR_ELECTRONICO"
|
|
13
|
+
});
|
|
14
|
+
var ECF_TYPE_NAMES = /* @__PURE__ */ Object.freeze({
|
|
15
|
+
"31": "Factura de cr\xE9dito fiscal electr\xF3nica",
|
|
16
|
+
"32": "Factura de consumo electr\xF3nica",
|
|
17
|
+
"33": "Nota de d\xE9bito electr\xF3nica",
|
|
18
|
+
"34": "Nota de cr\xE9dito electr\xF3nica",
|
|
19
|
+
"41": "Comprobante electr\xF3nico de compras",
|
|
20
|
+
"43": "Comprobante electr\xF3nico para gastos menores",
|
|
21
|
+
"44": "Comprobante electr\xF3nico para reg\xEDmenes especiales",
|
|
22
|
+
"45": "Comprobante electr\xF3nico gubernamental",
|
|
23
|
+
"46": "Comprobante electr\xF3nico para exportaciones",
|
|
24
|
+
"47": "Comprobante electr\xF3nico para pagos al exterior"
|
|
25
|
+
});
|
|
26
|
+
var ECF_PATTERN = /^E(\d{2})(\d{10})$/;
|
|
27
|
+
function validateEcf(value) {
|
|
28
|
+
if (typeof value !== "string") return { valid: false };
|
|
29
|
+
const normalized = value.toUpperCase().trim();
|
|
30
|
+
const match = ECF_PATTERN.exec(normalized);
|
|
31
|
+
if (!match) {
|
|
32
|
+
return { valid: false };
|
|
33
|
+
}
|
|
34
|
+
const typeCode = match[1];
|
|
35
|
+
const type = ECF_TYPES[typeCode];
|
|
36
|
+
if (!type) {
|
|
37
|
+
return { valid: false };
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
valid: true,
|
|
41
|
+
type,
|
|
42
|
+
serie: `E${typeCode}`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
exports.ECF_TYPE_NAMES = ECF_TYPE_NAMES; exports.validateEcf = validateEcf;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkDLB5RJ7Ecjs = require('./chunk-DLB5RJ7E.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkD6DU6PD3cjs = require('./chunk-D6DU6PD3.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -123,7 +123,7 @@ async function withRetry(fn, options = DEFAULT_RETRY_OPTIONS) {
|
|
|
123
123
|
var DgiiClient = class {
|
|
124
124
|
constructor(options) {
|
|
125
125
|
const timeout = _optionalChain([options, 'optionalAccess', _ => _.timeout]);
|
|
126
|
-
this._scraping = new (0,
|
|
126
|
+
this._scraping = new (0, _chunkD6DU6PD3cjs.ScrapingClient)(
|
|
127
127
|
timeout ? { timeout } : void 0
|
|
128
128
|
);
|
|
129
129
|
this._soap = new (0, _chunkDLB5RJ7Ecjs.DgiiSoapClient)(
|
|
@@ -150,11 +150,21 @@ var DgiiClient = class {
|
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
|
-
* Valida un comprobante fiscal
|
|
153
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
154
|
+
*
|
|
155
|
+
* @param rnc - RNC del emisor
|
|
156
|
+
* @param ncf - NCF o e-NCF a validar
|
|
157
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
158
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
159
|
+
*
|
|
160
|
+
* Para un e-NCF sin `rncComprador` la DGII responde con un mensaje de
|
|
161
|
+
* campo requerido: `ScrapingClient.getNCF` lanza `DgiiServiceError` y
|
|
162
|
+
* este método lo envuelve en `AllStrategiesFailedError` tras agotar
|
|
163
|
+
* reintentos y fallback (el mensaje conserva el texto de la DGII).
|
|
154
164
|
*/
|
|
155
|
-
async getNCF(rnc, ncf) {
|
|
165
|
+
async getNCF(rnc, ncf, options) {
|
|
156
166
|
return this._executeWithFallback(
|
|
157
|
-
(client) => client.getNCF(rnc, ncf)
|
|
167
|
+
(client) => client.getNCF(rnc, ncf, options)
|
|
158
168
|
);
|
|
159
169
|
}
|
|
160
170
|
async _executeWithFallback(operation) {
|
|
@@ -729,56 +729,9 @@ function validateNcf(value) {
|
|
|
729
729
|
};
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
// src/validators/ecf.ts
|
|
733
|
-
var ECF_TYPES = /* @__PURE__ */ Object.freeze({
|
|
734
|
-
"31": "CREDITO_FISCAL_ELECTRONICA",
|
|
735
|
-
"32": "CONSUMO_ELECTRONICA",
|
|
736
|
-
"33": "NOTA_DE_DEBITO_ELECTRONICA",
|
|
737
|
-
"34": "NOTA_DE_CREDITO_ELECTRONICA",
|
|
738
|
-
"41": "COMPRAS_ELECTRONICO",
|
|
739
|
-
"43": "GASTOS_MENORES_ELECTRONICO",
|
|
740
|
-
"44": "REGIMENES_ESPECIALES_ELECTRONICO",
|
|
741
|
-
"45": "GUBERNAMENTAL_ELECTRONICO",
|
|
742
|
-
"46": "EXPORTACIONES_ELECTRONICO",
|
|
743
|
-
"47": "PAGOS_AL_EXTERIOR_ELECTRONICO"
|
|
744
|
-
});
|
|
745
|
-
var ECF_TYPE_NAMES = /* @__PURE__ */ Object.freeze({
|
|
746
|
-
"31": "Factura de cr\xE9dito fiscal electr\xF3nica",
|
|
747
|
-
"32": "Factura de consumo electr\xF3nica",
|
|
748
|
-
"33": "Nota de d\xE9bito electr\xF3nica",
|
|
749
|
-
"34": "Nota de cr\xE9dito electr\xF3nica",
|
|
750
|
-
"41": "Comprobante electr\xF3nico de compras",
|
|
751
|
-
"43": "Comprobante electr\xF3nico para gastos menores",
|
|
752
|
-
"44": "Comprobante electr\xF3nico para reg\xEDmenes especiales",
|
|
753
|
-
"45": "Comprobante electr\xF3nico gubernamental",
|
|
754
|
-
"46": "Comprobante electr\xF3nico para exportaciones",
|
|
755
|
-
"47": "Comprobante electr\xF3nico para pagos al exterior"
|
|
756
|
-
});
|
|
757
|
-
var ECF_PATTERN = /^E(\d{2})(\d{10})$/;
|
|
758
|
-
function validateEcf(value) {
|
|
759
|
-
if (typeof value !== "string") return { valid: false };
|
|
760
|
-
const normalized = value.toUpperCase().trim();
|
|
761
|
-
const match = ECF_PATTERN.exec(normalized);
|
|
762
|
-
if (!match) {
|
|
763
|
-
return { valid: false };
|
|
764
|
-
}
|
|
765
|
-
const typeCode = match[1];
|
|
766
|
-
const type = ECF_TYPES[typeCode];
|
|
767
|
-
if (!type) {
|
|
768
|
-
return { valid: false };
|
|
769
|
-
}
|
|
770
|
-
return {
|
|
771
|
-
valid: true,
|
|
772
|
-
type,
|
|
773
|
-
serie: `E${typeCode}`
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
|
|
777
732
|
export {
|
|
778
733
|
validateRnc,
|
|
779
734
|
validateCedula,
|
|
780
735
|
NCF_TYPE_NAMES,
|
|
781
|
-
validateNcf
|
|
782
|
-
ECF_TYPE_NAMES,
|
|
783
|
-
validateEcf
|
|
736
|
+
validateNcf
|
|
784
737
|
};
|
|
@@ -729,56 +729,9 @@ function validateNcf(value) {
|
|
|
729
729
|
};
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
// src/validators/ecf.ts
|
|
733
|
-
var ECF_TYPES = /* @__PURE__ */ Object.freeze({
|
|
734
|
-
"31": "CREDITO_FISCAL_ELECTRONICA",
|
|
735
|
-
"32": "CONSUMO_ELECTRONICA",
|
|
736
|
-
"33": "NOTA_DE_DEBITO_ELECTRONICA",
|
|
737
|
-
"34": "NOTA_DE_CREDITO_ELECTRONICA",
|
|
738
|
-
"41": "COMPRAS_ELECTRONICO",
|
|
739
|
-
"43": "GASTOS_MENORES_ELECTRONICO",
|
|
740
|
-
"44": "REGIMENES_ESPECIALES_ELECTRONICO",
|
|
741
|
-
"45": "GUBERNAMENTAL_ELECTRONICO",
|
|
742
|
-
"46": "EXPORTACIONES_ELECTRONICO",
|
|
743
|
-
"47": "PAGOS_AL_EXTERIOR_ELECTRONICO"
|
|
744
|
-
});
|
|
745
|
-
var ECF_TYPE_NAMES = /* @__PURE__ */ Object.freeze({
|
|
746
|
-
"31": "Factura de cr\xE9dito fiscal electr\xF3nica",
|
|
747
|
-
"32": "Factura de consumo electr\xF3nica",
|
|
748
|
-
"33": "Nota de d\xE9bito electr\xF3nica",
|
|
749
|
-
"34": "Nota de cr\xE9dito electr\xF3nica",
|
|
750
|
-
"41": "Comprobante electr\xF3nico de compras",
|
|
751
|
-
"43": "Comprobante electr\xF3nico para gastos menores",
|
|
752
|
-
"44": "Comprobante electr\xF3nico para reg\xEDmenes especiales",
|
|
753
|
-
"45": "Comprobante electr\xF3nico gubernamental",
|
|
754
|
-
"46": "Comprobante electr\xF3nico para exportaciones",
|
|
755
|
-
"47": "Comprobante electr\xF3nico para pagos al exterior"
|
|
756
|
-
});
|
|
757
|
-
var ECF_PATTERN = /^E(\d{2})(\d{10})$/;
|
|
758
|
-
function validateEcf(value) {
|
|
759
|
-
if (typeof value !== "string") return { valid: false };
|
|
760
|
-
const normalized = value.toUpperCase().trim();
|
|
761
|
-
const match = ECF_PATTERN.exec(normalized);
|
|
762
|
-
if (!match) {
|
|
763
|
-
return { valid: false };
|
|
764
|
-
}
|
|
765
|
-
const typeCode = match[1];
|
|
766
|
-
const type = ECF_TYPES[typeCode];
|
|
767
|
-
if (!type) {
|
|
768
|
-
return { valid: false };
|
|
769
|
-
}
|
|
770
|
-
return {
|
|
771
|
-
valid: true,
|
|
772
|
-
type,
|
|
773
|
-
serie: `E${typeCode}`
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
732
|
|
|
780
733
|
|
|
781
734
|
|
|
782
735
|
|
|
783
736
|
|
|
784
|
-
exports.validateRnc = validateRnc; exports.validateCedula = validateCedula; exports.NCF_TYPE_NAMES = NCF_TYPE_NAMES; exports.validateNcf = validateNcf;
|
|
737
|
+
exports.validateRnc = validateRnc; exports.validateCedula = validateCedula; exports.NCF_TYPE_NAMES = NCF_TYPE_NAMES; exports.validateNcf = validateNcf;
|
package/dist/client.cjs
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkQWP5FSCNcjs = require('./chunk-QWP5FSCN.cjs');
|
|
7
7
|
require('./chunk-DLB5RJ7E.cjs');
|
|
8
|
-
require('./chunk-
|
|
8
|
+
require('./chunk-D6DU6PD3.cjs');
|
|
9
|
+
require('./chunk-OSGHCQFA.cjs');
|
|
9
10
|
require('./chunk-WMFHPNFP.cjs');
|
|
10
11
|
require('./chunk-QH4BK5X3.cjs');
|
|
11
12
|
require('./chunk-NASWEFHN.cjs');
|
|
@@ -14,4 +15,4 @@ require('./chunk-NASWEFHN.cjs');
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
exports.ConsecutiveBreaker =
|
|
18
|
+
exports.ConsecutiveBreaker = _chunkQWP5FSCNcjs.ConsecutiveBreaker; exports.DgiiClient = _chunkQWP5FSCNcjs.DgiiClient; exports.isRetryableError = _chunkQWP5FSCNcjs.isRetryableError; exports.withRetry = _chunkQWP5FSCNcjs.withRetry;
|
package/dist/client.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente, N as NcfQueryResult } from './index-
|
|
1
|
+
import { C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult } from './index-BPvMDXya.cjs';
|
|
2
2
|
|
|
3
3
|
interface RetryOptions {
|
|
4
4
|
/** Número máximo de reintentos (por defecto: 2) */
|
|
@@ -86,9 +86,19 @@ declare class DgiiClient {
|
|
|
86
86
|
*/
|
|
87
87
|
getContribuyente(rnc: string): Promise<Contribuyente>;
|
|
88
88
|
/**
|
|
89
|
-
* Valida un comprobante fiscal
|
|
89
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
90
|
+
*
|
|
91
|
+
* @param rnc - RNC del emisor
|
|
92
|
+
* @param ncf - NCF o e-NCF a validar
|
|
93
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
94
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
95
|
+
*
|
|
96
|
+
* Para un e-NCF sin `rncComprador` la DGII responde con un mensaje de
|
|
97
|
+
* campo requerido: `ScrapingClient.getNCF` lanza `DgiiServiceError` y
|
|
98
|
+
* este método lo envuelve en `AllStrategiesFailedError` tras agotar
|
|
99
|
+
* reintentos y fallback (el mensaje conserva el texto de la DGII).
|
|
90
100
|
*/
|
|
91
|
-
getNCF(rnc: string, ncf: string): Promise<NcfQueryResult>;
|
|
101
|
+
getNCF(rnc: string, ncf: string, options?: NcfQueryOptions): Promise<NcfQueryResult>;
|
|
92
102
|
private _executeWithFallback;
|
|
93
103
|
}
|
|
94
104
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente, N as NcfQueryResult } from './index-
|
|
1
|
+
import { C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult } from './index-BPvMDXya.js';
|
|
2
2
|
|
|
3
3
|
interface RetryOptions {
|
|
4
4
|
/** Número máximo de reintentos (por defecto: 2) */
|
|
@@ -86,9 +86,19 @@ declare class DgiiClient {
|
|
|
86
86
|
*/
|
|
87
87
|
getContribuyente(rnc: string): Promise<Contribuyente>;
|
|
88
88
|
/**
|
|
89
|
-
* Valida un comprobante fiscal
|
|
89
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
90
|
+
*
|
|
91
|
+
* @param rnc - RNC del emisor
|
|
92
|
+
* @param ncf - NCF o e-NCF a validar
|
|
93
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
94
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
95
|
+
*
|
|
96
|
+
* Para un e-NCF sin `rncComprador` la DGII responde con un mensaje de
|
|
97
|
+
* campo requerido: `ScrapingClient.getNCF` lanza `DgiiServiceError` y
|
|
98
|
+
* este método lo envuelve en `AllStrategiesFailedError` tras agotar
|
|
99
|
+
* reintentos y fallback (el mensaje conserva el texto de la DGII).
|
|
90
100
|
*/
|
|
91
|
-
getNCF(rnc: string, ncf: string): Promise<NcfQueryResult>;
|
|
101
|
+
getNCF(rnc: string, ncf: string, options?: NcfQueryOptions): Promise<NcfQueryResult>;
|
|
92
102
|
private _executeWithFallback;
|
|
93
103
|
}
|
|
94
104
|
|
package/dist/client.js
CHANGED
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
DgiiClient,
|
|
4
4
|
isRetryableError,
|
|
5
5
|
withRetry
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ABNHQAWP.js";
|
|
7
7
|
import "./chunk-QTN5ZT4P.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-KMSKQH4U.js";
|
|
9
|
+
import "./chunk-H42U4GI5.js";
|
|
9
10
|
import "./chunk-KW4ZV6FJ.js";
|
|
10
11
|
import "./chunk-D26S6EXD.js";
|
|
11
12
|
import "./chunk-IRQX4WNQ.js";
|
|
@@ -38,14 +38,45 @@ interface Contribuyente {
|
|
|
38
38
|
regimenDePagos?: string;
|
|
39
39
|
administracionLocal?: string;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Datos adicionales para consultar un e-NCF (serie E) en la DGII.
|
|
43
|
+
*
|
|
44
|
+
* La DGII exige el RNC del comprador (o el ID extranjero) para
|
|
45
|
+
* responder el estado de un e-NCF. Se ignoran al consultar un NCF
|
|
46
|
+
* de serie B.
|
|
47
|
+
*/
|
|
48
|
+
interface NcfQueryOptions {
|
|
49
|
+
/** RNC del comprador tal como aparece en la factura. */
|
|
50
|
+
rncComprador?: string;
|
|
51
|
+
/** Código de seguridad de 6 caracteres impreso en la factura. */
|
|
52
|
+
codigoSeguridad?: string;
|
|
53
|
+
}
|
|
41
54
|
/**
|
|
42
55
|
* Resultado de validación de un comprobante fiscal contra la DGII.
|
|
56
|
+
*
|
|
57
|
+
* `valid` significa que la DGII encontró el comprobante, no que esté
|
|
58
|
+
* aceptado: para un e-NCF hay que revisar `estado` (por ejemplo
|
|
59
|
+
* `Aceptado`).
|
|
60
|
+
*
|
|
61
|
+
* Los campos de la sección e-NCF (`rncComprador`, `codigoSeguridad`,
|
|
62
|
+
* `estado`, `montoTotal`, `totalItbis`, `fechaEmision`, `fechaFirma`)
|
|
63
|
+
* solo se llenan cuando el comprobante es un e-NCF (serie E).
|
|
64
|
+
* `nombreComercial` no se llena para la serie E porque la DGII no lo
|
|
65
|
+
* muestra en esa consulta. `fechaEmision` y `fechaFirma` son strings
|
|
66
|
+
* exactamente como la DGII los renderiza.
|
|
43
67
|
*/
|
|
44
68
|
interface NcfQueryResult {
|
|
45
69
|
valid: boolean;
|
|
46
70
|
rnc: string;
|
|
47
71
|
ncf: string;
|
|
48
72
|
nombreComercial?: string;
|
|
73
|
+
rncComprador?: string;
|
|
74
|
+
codigoSeguridad?: string;
|
|
75
|
+
estado?: string;
|
|
76
|
+
montoTotal?: number;
|
|
77
|
+
totalItbis?: number;
|
|
78
|
+
fechaEmision?: string;
|
|
79
|
+
fechaFirma?: string;
|
|
49
80
|
}
|
|
50
81
|
/**
|
|
51
82
|
* Registro del archivo masivo de contribuyentes (DGII_RNC.zip).
|
|
@@ -67,4 +98,4 @@ interface BulkContribuyente {
|
|
|
67
98
|
fechaConstitucion: string;
|
|
68
99
|
}
|
|
69
100
|
|
|
70
|
-
export type { BulkContribuyente as B, Contribuyente as C,
|
|
101
|
+
export type { BulkContribuyente as B, Contribuyente as C, NcfQueryOptions as N, ValidationResult as V, NcfQueryResult as a, NcfValidationResult as b };
|
|
@@ -38,14 +38,45 @@ interface Contribuyente {
|
|
|
38
38
|
regimenDePagos?: string;
|
|
39
39
|
administracionLocal?: string;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Datos adicionales para consultar un e-NCF (serie E) en la DGII.
|
|
43
|
+
*
|
|
44
|
+
* La DGII exige el RNC del comprador (o el ID extranjero) para
|
|
45
|
+
* responder el estado de un e-NCF. Se ignoran al consultar un NCF
|
|
46
|
+
* de serie B.
|
|
47
|
+
*/
|
|
48
|
+
interface NcfQueryOptions {
|
|
49
|
+
/** RNC del comprador tal como aparece en la factura. */
|
|
50
|
+
rncComprador?: string;
|
|
51
|
+
/** Código de seguridad de 6 caracteres impreso en la factura. */
|
|
52
|
+
codigoSeguridad?: string;
|
|
53
|
+
}
|
|
41
54
|
/**
|
|
42
55
|
* Resultado de validación de un comprobante fiscal contra la DGII.
|
|
56
|
+
*
|
|
57
|
+
* `valid` significa que la DGII encontró el comprobante, no que esté
|
|
58
|
+
* aceptado: para un e-NCF hay que revisar `estado` (por ejemplo
|
|
59
|
+
* `Aceptado`).
|
|
60
|
+
*
|
|
61
|
+
* Los campos de la sección e-NCF (`rncComprador`, `codigoSeguridad`,
|
|
62
|
+
* `estado`, `montoTotal`, `totalItbis`, `fechaEmision`, `fechaFirma`)
|
|
63
|
+
* solo se llenan cuando el comprobante es un e-NCF (serie E).
|
|
64
|
+
* `nombreComercial` no se llena para la serie E porque la DGII no lo
|
|
65
|
+
* muestra en esa consulta. `fechaEmision` y `fechaFirma` son strings
|
|
66
|
+
* exactamente como la DGII los renderiza.
|
|
43
67
|
*/
|
|
44
68
|
interface NcfQueryResult {
|
|
45
69
|
valid: boolean;
|
|
46
70
|
rnc: string;
|
|
47
71
|
ncf: string;
|
|
48
72
|
nombreComercial?: string;
|
|
73
|
+
rncComprador?: string;
|
|
74
|
+
codigoSeguridad?: string;
|
|
75
|
+
estado?: string;
|
|
76
|
+
montoTotal?: number;
|
|
77
|
+
totalItbis?: number;
|
|
78
|
+
fechaEmision?: string;
|
|
79
|
+
fechaFirma?: string;
|
|
49
80
|
}
|
|
50
81
|
/**
|
|
51
82
|
* Registro del archivo masivo de contribuyentes (DGII_RNC.zip).
|
|
@@ -67,4 +98,4 @@ interface BulkContribuyente {
|
|
|
67
98
|
fechaConstitucion: string;
|
|
68
99
|
}
|
|
69
100
|
|
|
70
|
-
export type { BulkContribuyente as B, Contribuyente as C,
|
|
101
|
+
export type { BulkContribuyente as B, Contribuyente as C, NcfQueryOptions as N, ValidationResult as V, NcfQueryResult as a, NcfValidationResult as b };
|
package/dist/index.cjs
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _chunkSUSDEKIDcjs = require('./chunk-SUSDEKID.cjs');
|
|
6
|
+
var _chunkUW6W2JHWcjs = require('./chunk-UW6W2JHW.cjs');
|
|
9
7
|
require('./chunk-QOSGH7F5.cjs');
|
|
10
8
|
|
|
11
9
|
|
|
@@ -19,7 +17,7 @@ require('./chunk-2ST6QKHA.cjs');
|
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
|
|
22
|
-
var
|
|
20
|
+
var _chunkQWP5FSCNcjs = require('./chunk-QWP5FSCN.cjs');
|
|
23
21
|
|
|
24
22
|
|
|
25
23
|
|
|
@@ -29,7 +27,11 @@ var _chunkDLB5RJ7Ecjs = require('./chunk-DLB5RJ7E.cjs');
|
|
|
29
27
|
|
|
30
28
|
|
|
31
29
|
|
|
32
|
-
var
|
|
30
|
+
var _chunkD6DU6PD3cjs = require('./chunk-D6DU6PD3.cjs');
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
var _chunkOSGHCQFAcjs = require('./chunk-OSGHCQFA.cjs');
|
|
33
35
|
require('./chunk-WMFHPNFP.cjs');
|
|
34
36
|
require('./chunk-QH4BK5X3.cjs');
|
|
35
37
|
|
|
@@ -67,4 +69,4 @@ var _chunkNASWEFHNcjs = require('./chunk-NASWEFHN.cjs');
|
|
|
67
69
|
|
|
68
70
|
|
|
69
71
|
|
|
70
|
-
exports.AllStrategiesFailedError = _chunkNASWEFHNcjs.AllStrategiesFailedError; exports.BulkFormatError = _chunkNASWEFHNcjs.BulkFormatError; exports.ConsecutiveBreaker =
|
|
72
|
+
exports.AllStrategiesFailedError = _chunkNASWEFHNcjs.AllStrategiesFailedError; exports.BulkFormatError = _chunkNASWEFHNcjs.BulkFormatError; exports.ConsecutiveBreaker = _chunkQWP5FSCNcjs.ConsecutiveBreaker; exports.DGII_BULK_URL = _chunkVIZWYFHPcjs.DGII_BULK_URL; exports.DGII_ESTADOS = _chunkVIZWYFHPcjs.DGII_ESTADOS; exports.DGII_NCF_URL = _chunkD6DU6PD3cjs.DGII_NCF_URL; exports.DGII_RNC_URL = _chunkD6DU6PD3cjs.DGII_RNC_URL; exports.DGII_SOAP_BASE_URL = _chunkDLB5RJ7Ecjs.DGII_SOAP_BASE_URL; exports.DgiiClient = _chunkQWP5FSCNcjs.DgiiClient; exports.DgiiConnectionError = _chunkNASWEFHNcjs.DgiiConnectionError; exports.DgiiError = _chunkNASWEFHNcjs.DgiiError; exports.DgiiNotFoundError = _chunkNASWEFHNcjs.DgiiNotFoundError; exports.DgiiServiceError = _chunkNASWEFHNcjs.DgiiServiceError; exports.DgiiSoapClient = _chunkDLB5RJ7Ecjs.DgiiSoapClient; exports.ECF_TYPE_NAMES = _chunkOSGHCQFAcjs.ECF_TYPE_NAMES; exports.NCF_TYPE_NAMES = _chunkUW6W2JHWcjs.NCF_TYPE_NAMES; exports.SOAP_ACTIONS = _chunkDLB5RJ7Ecjs.SOAP_ACTIONS; exports.ScrapingClient = _chunkD6DU6PD3cjs.ScrapingClient; exports.downloadBulkFile = _chunkVIZWYFHPcjs.downloadBulkFile; exports.isRetryableError = _chunkQWP5FSCNcjs.isRetryableError; exports.parseBulkFile = _chunkVIZWYFHPcjs.parseBulkFile; exports.validateCedula = _chunkUW6W2JHWcjs.validateCedula; exports.validateEcf = _chunkOSGHCQFAcjs.validateEcf; exports.validateNcf = _chunkUW6W2JHWcjs.validateNcf; exports.validateRnc = _chunkUW6W2JHWcjs.validateRnc; exports.withRetry = _chunkQWP5FSCNcjs.withRetry;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,4 +4,4 @@ export { AllStrategiesFailedError, BulkFormatError, DgiiConnectionError, DgiiErr
|
|
|
4
4
|
export { DGII_NCF_URL, DGII_RNC_URL, ScrapingClient, ScrapingClientOptions } from './scraping.cjs';
|
|
5
5
|
export { CircuitBreakerOptions, ClientOptions, ConsecutiveBreaker, DgiiClient, RetryOptions, isRetryableError, withRetry } from './client.cjs';
|
|
6
6
|
export { DGII_BULK_URL, DGII_ESTADOS, DgiiEstado, DownloadOptions, ParseOptions, downloadBulkFile, parseBulkFile } from './bulk.cjs';
|
|
7
|
-
export { B as BulkContribuyente, C as Contribuyente, N as
|
|
7
|
+
export { B as BulkContribuyente, C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult, b as NcfValidationResult, V as ValidationResult } from './index-BPvMDXya.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { AllStrategiesFailedError, BulkFormatError, DgiiConnectionError, DgiiErr
|
|
|
4
4
|
export { DGII_NCF_URL, DGII_RNC_URL, ScrapingClient, ScrapingClientOptions } from './scraping.js';
|
|
5
5
|
export { CircuitBreakerOptions, ClientOptions, ConsecutiveBreaker, DgiiClient, RetryOptions, isRetryableError, withRetry } from './client.js';
|
|
6
6
|
export { DGII_BULK_URL, DGII_ESTADOS, DgiiEstado, DownloadOptions, ParseOptions, downloadBulkFile, parseBulkFile } from './bulk.js';
|
|
7
|
-
export { B as BulkContribuyente, C as Contribuyente, N as
|
|
7
|
+
export { B as BulkContribuyente, C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult, b as NcfValidationResult, V as ValidationResult } from './index-BPvMDXya.js';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ECF_TYPE_NAMES,
|
|
3
2
|
NCF_TYPE_NAMES,
|
|
4
3
|
validateCedula,
|
|
5
|
-
validateEcf,
|
|
6
4
|
validateNcf,
|
|
7
5
|
validateRnc
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RTI3CLHV.js";
|
|
9
7
|
import "./chunk-ERBXSS64.js";
|
|
10
8
|
import {
|
|
11
9
|
DGII_BULK_URL,
|
|
@@ -19,7 +17,7 @@ import {
|
|
|
19
17
|
DgiiClient,
|
|
20
18
|
isRetryableError,
|
|
21
19
|
withRetry
|
|
22
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ABNHQAWP.js";
|
|
23
21
|
import {
|
|
24
22
|
DGII_SOAP_BASE_URL,
|
|
25
23
|
DgiiSoapClient,
|
|
@@ -29,7 +27,11 @@ import {
|
|
|
29
27
|
DGII_NCF_URL,
|
|
30
28
|
DGII_RNC_URL,
|
|
31
29
|
ScrapingClient
|
|
32
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-KMSKQH4U.js";
|
|
31
|
+
import {
|
|
32
|
+
ECF_TYPE_NAMES,
|
|
33
|
+
validateEcf
|
|
34
|
+
} from "./chunk-H42U4GI5.js";
|
|
33
35
|
import "./chunk-KW4ZV6FJ.js";
|
|
34
36
|
import "./chunk-D26S6EXD.js";
|
|
35
37
|
import {
|
package/dist/scraping.cjs
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunkD6DU6PD3cjs = require('./chunk-D6DU6PD3.cjs');
|
|
8
|
+
require('./chunk-OSGHCQFA.cjs');
|
|
8
9
|
require('./chunk-WMFHPNFP.cjs');
|
|
9
10
|
require('./chunk-QH4BK5X3.cjs');
|
|
10
11
|
require('./chunk-NASWEFHN.cjs');
|
|
@@ -13,4 +14,4 @@ require('./chunk-NASWEFHN.cjs');
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
exports.DGII_NCF_URL =
|
|
17
|
+
exports.DGII_NCF_URL = _chunkD6DU6PD3cjs.DGII_NCF_URL; exports.DGII_RNC_URL = _chunkD6DU6PD3cjs.DGII_RNC_URL; exports.FORM_FIELDS = _chunkD6DU6PD3cjs.FORM_FIELDS; exports.ScrapingClient = _chunkD6DU6PD3cjs.ScrapingClient;
|
package/dist/scraping.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente, N as NcfQueryResult } from './index-
|
|
1
|
+
import { C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult } from './index-BPvMDXya.cjs';
|
|
2
2
|
|
|
3
3
|
interface ScrapingClientOptions {
|
|
4
4
|
/** Tiempo de espera en milisegundos (por defecto: 15000) */
|
|
@@ -23,9 +23,18 @@ declare class ScrapingClient {
|
|
|
23
23
|
*/
|
|
24
24
|
getContribuyente(rnc: string): Promise<Contribuyente>;
|
|
25
25
|
/**
|
|
26
|
-
* Valida un comprobante fiscal
|
|
26
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
27
|
+
*
|
|
28
|
+
* Soporta NCF (serie B) y e-NCF (serie E). Para un e-NCF la DGII
|
|
29
|
+
* exige el RNC del comprador; sin él responde con un mensaje de campo
|
|
30
|
+
* requerido y este método lanza `DgiiServiceError`.
|
|
31
|
+
*
|
|
32
|
+
* @param rnc - RNC del emisor
|
|
33
|
+
* @param ncf - NCF o e-NCF a validar
|
|
34
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
35
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
27
36
|
*/
|
|
28
|
-
getNCF(rnc: string, ncf: string): Promise<NcfQueryResult>;
|
|
37
|
+
getNCF(rnc: string, ncf: string, options?: NcfQueryOptions): Promise<NcfQueryResult>;
|
|
29
38
|
private _fetchTokens;
|
|
30
39
|
private _post;
|
|
31
40
|
private _wrapFetchError;
|
|
@@ -42,6 +51,8 @@ declare const FORM_FIELDS: Readonly<{
|
|
|
42
51
|
readonly ncfRncInput: "ctl00$cphMain$txtRNC";
|
|
43
52
|
readonly ncfInput: "ctl00$cphMain$txtNCF";
|
|
44
53
|
readonly ncfSubmit: "ctl00$cphMain$btnConsultar";
|
|
54
|
+
readonly ncfRncCompradorInput: "ctl00$cphMain$txtRncComprador";
|
|
55
|
+
readonly ncfCodigoSeguridadInput: "ctl00$cphMain$txtCodigoSeg";
|
|
45
56
|
}>;
|
|
46
57
|
|
|
47
58
|
export { DGII_NCF_URL, DGII_RNC_URL, FORM_FIELDS, ScrapingClient, type ScrapingClientOptions };
|
package/dist/scraping.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente, N as NcfQueryResult } from './index-
|
|
1
|
+
import { C as Contribuyente, N as NcfQueryOptions, a as NcfQueryResult } from './index-BPvMDXya.js';
|
|
2
2
|
|
|
3
3
|
interface ScrapingClientOptions {
|
|
4
4
|
/** Tiempo de espera en milisegundos (por defecto: 15000) */
|
|
@@ -23,9 +23,18 @@ declare class ScrapingClient {
|
|
|
23
23
|
*/
|
|
24
24
|
getContribuyente(rnc: string): Promise<Contribuyente>;
|
|
25
25
|
/**
|
|
26
|
-
* Valida un comprobante fiscal
|
|
26
|
+
* Valida un comprobante fiscal contra la DGII.
|
|
27
|
+
*
|
|
28
|
+
* Soporta NCF (serie B) y e-NCF (serie E). Para un e-NCF la DGII
|
|
29
|
+
* exige el RNC del comprador; sin él responde con un mensaje de campo
|
|
30
|
+
* requerido y este método lanza `DgiiServiceError`.
|
|
31
|
+
*
|
|
32
|
+
* @param rnc - RNC del emisor
|
|
33
|
+
* @param ncf - NCF o e-NCF a validar
|
|
34
|
+
* @param options - Datos adicionales del e-NCF (`rncComprador`,
|
|
35
|
+
* `codigoSeguridad`). Se ignoran cuando `ncf` no es un e-NCF válido.
|
|
27
36
|
*/
|
|
28
|
-
getNCF(rnc: string, ncf: string): Promise<NcfQueryResult>;
|
|
37
|
+
getNCF(rnc: string, ncf: string, options?: NcfQueryOptions): Promise<NcfQueryResult>;
|
|
29
38
|
private _fetchTokens;
|
|
30
39
|
private _post;
|
|
31
40
|
private _wrapFetchError;
|
|
@@ -42,6 +51,8 @@ declare const FORM_FIELDS: Readonly<{
|
|
|
42
51
|
readonly ncfRncInput: "ctl00$cphMain$txtRNC";
|
|
43
52
|
readonly ncfInput: "ctl00$cphMain$txtNCF";
|
|
44
53
|
readonly ncfSubmit: "ctl00$cphMain$btnConsultar";
|
|
54
|
+
readonly ncfRncCompradorInput: "ctl00$cphMain$txtRncComprador";
|
|
55
|
+
readonly ncfCodigoSeguridadInput: "ctl00$cphMain$txtCodigoSeg";
|
|
45
56
|
}>;
|
|
46
57
|
|
|
47
58
|
export { DGII_NCF_URL, DGII_RNC_URL, FORM_FIELDS, ScrapingClient, type ScrapingClientOptions };
|
package/dist/scraping.js
CHANGED
package/dist/soap.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente,
|
|
1
|
+
import { C as Contribuyente, a as NcfQueryResult } from './index-BPvMDXya.cjs';
|
|
2
2
|
export { DgiiConnectionError, DgiiError, DgiiNotFoundError, DgiiServiceError } from './errors.cjs';
|
|
3
3
|
|
|
4
4
|
interface SoapClientOptions {
|
package/dist/soap.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as Contribuyente,
|
|
1
|
+
import { C as Contribuyente, a as NcfQueryResult } from './index-BPvMDXya.js';
|
|
2
2
|
export { DgiiConnectionError, DgiiError, DgiiNotFoundError, DgiiServiceError } from './errors.js';
|
|
3
3
|
|
|
4
4
|
interface SoapClientOptions {
|
package/dist/validators.cjs
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
var _chunkUW6W2JHWcjs = require('./chunk-UW6W2JHW.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
var _chunkOSGHCQFAcjs = require('./chunk-OSGHCQFA.cjs');
|
|
9
11
|
require('./chunk-QH4BK5X3.cjs');
|
|
10
12
|
|
|
11
13
|
|
|
@@ -14,4 +16,4 @@ require('./chunk-QH4BK5X3.cjs');
|
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
|
|
17
|
-
exports.ECF_TYPE_NAMES =
|
|
19
|
+
exports.ECF_TYPE_NAMES = _chunkOSGHCQFAcjs.ECF_TYPE_NAMES; exports.NCF_TYPE_NAMES = _chunkUW6W2JHWcjs.NCF_TYPE_NAMES; exports.validateCedula = _chunkUW6W2JHWcjs.validateCedula; exports.validateEcf = _chunkOSGHCQFAcjs.validateEcf; exports.validateNcf = _chunkUW6W2JHWcjs.validateNcf; exports.validateRnc = _chunkUW6W2JHWcjs.validateRnc;
|
package/dist/validators.d.cts
CHANGED
package/dist/validators.d.ts
CHANGED
package/dist/validators.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ECF_TYPE_NAMES,
|
|
3
2
|
NCF_TYPE_NAMES,
|
|
4
3
|
validateCedula,
|
|
5
|
-
validateEcf,
|
|
6
4
|
validateNcf,
|
|
7
5
|
validateRnc
|
|
8
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RTI3CLHV.js";
|
|
7
|
+
import {
|
|
8
|
+
ECF_TYPE_NAMES,
|
|
9
|
+
validateEcf
|
|
10
|
+
} from "./chunk-H42U4GI5.js";
|
|
9
11
|
import "./chunk-D26S6EXD.js";
|
|
10
12
|
export {
|
|
11
13
|
ECF_TYPE_NAMES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dgii-ts",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Librería TypeScript para validación e integración con la DGII de República Dominicana — RNC, Cédula, NCF, e-NCF",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
"node": ">=18"
|
|
116
116
|
},
|
|
117
117
|
"overrides": {
|
|
118
|
-
"vite": "^7.3.
|
|
118
|
+
"vite": "^7.3.6"
|
|
119
119
|
},
|
|
120
120
|
"devDependencies": {
|
|
121
121
|
"@types/node": "^18.19.130",
|