arca-sdk 0.5.0 → 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/CHANGELOG.md +142 -0
- package/README.md +125 -48
- package/dist/index.cjs +489 -352
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +271 -179
- package/dist/index.d.ts +271 -179
- package/dist/index.js +484 -348
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -37,6 +37,12 @@ declare class ArcaAuthError extends ArcaError {
|
|
|
37
37
|
declare class ArcaValidationError extends ArcaError {
|
|
38
38
|
constructor(message: string, details?: unknown);
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Error de comunicación/red
|
|
42
|
+
*/
|
|
43
|
+
declare class ArcaNetworkError extends ArcaError {
|
|
44
|
+
constructor(message: string, details?: unknown);
|
|
45
|
+
}
|
|
40
46
|
|
|
41
47
|
/**
|
|
42
48
|
* Interface for token persistence.
|
|
@@ -56,7 +62,7 @@ interface TokenStorage {
|
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
/**
|
|
59
|
-
* Configuración para
|
|
65
|
+
* Configuración para WsaaService
|
|
60
66
|
*/
|
|
61
67
|
interface WsaaConfig extends ArcaConfig {
|
|
62
68
|
/** Certificado X.509 en formato PEM */
|
|
@@ -76,9 +82,9 @@ interface LoginTicket {
|
|
|
76
82
|
token: string;
|
|
77
83
|
/** Firma del token */
|
|
78
84
|
sign: string;
|
|
79
|
-
/** Fecha de generación
|
|
85
|
+
/** Fecha de generación */
|
|
80
86
|
generationTime: Date;
|
|
81
|
-
/** Fecha de expiración
|
|
87
|
+
/** Fecha de expiración */
|
|
82
88
|
expirationTime: Date;
|
|
83
89
|
}
|
|
84
90
|
|
|
@@ -133,18 +139,18 @@ declare class WsaaService {
|
|
|
133
139
|
}
|
|
134
140
|
|
|
135
141
|
/**
|
|
136
|
-
* Configuración para
|
|
142
|
+
* Configuración para WsfeService
|
|
137
143
|
*/
|
|
138
144
|
interface WsfeConfig extends ArcaConfig {
|
|
139
145
|
/** Ticket de autenticación WSAA */
|
|
140
146
|
ticket: LoginTicket;
|
|
141
|
-
/** Punto de venta (
|
|
142
|
-
|
|
147
|
+
/** Punto de venta (1-9999) */
|
|
148
|
+
pointOfSale: number;
|
|
143
149
|
}
|
|
144
150
|
/**
|
|
145
|
-
* Tipo de comprobante
|
|
151
|
+
* Tipo de comprobante ARCA
|
|
146
152
|
*/
|
|
147
|
-
declare enum
|
|
153
|
+
declare enum InvoiceType {
|
|
148
154
|
FACTURA_A = 1,
|
|
149
155
|
FACTURA_B = 6,
|
|
150
156
|
FACTURA_C = 11,
|
|
@@ -155,119 +161,167 @@ declare enum TipoComprobante {
|
|
|
155
161
|
/**
|
|
156
162
|
* Concepto de facturación
|
|
157
163
|
*/
|
|
158
|
-
declare enum
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
declare enum BillingConcept {
|
|
165
|
+
PRODUCTS = 1,
|
|
166
|
+
SERVICES = 2,
|
|
167
|
+
PRODUCTS_AND_SERVICES = 3
|
|
162
168
|
}
|
|
163
169
|
/**
|
|
164
|
-
* Tipo de documento del
|
|
170
|
+
* Tipo de documento del receptor
|
|
165
171
|
*/
|
|
166
|
-
declare enum
|
|
172
|
+
declare enum TaxIdType {
|
|
167
173
|
CUIT = 80,
|
|
168
174
|
CUIL = 86,
|
|
169
175
|
CDI = 87,
|
|
170
176
|
LE = 89,
|
|
171
177
|
LC = 90,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
178
|
+
FOREIGN_ID = 91,
|
|
179
|
+
PASSPORT = 94,
|
|
180
|
+
BUENOS_AIRES_ID = 95,
|
|
181
|
+
/**
|
|
182
|
+
* @note AFIP usa el código 96 para ambos. En la práctica, DNI es el más utilizado.
|
|
183
|
+
* Fuente: Tabla 13 del catálogo ARCA — ambos valores son 96 en el catálogo oficial.
|
|
184
|
+
*/
|
|
185
|
+
NATIONAL_POLICE_ID = 96,
|
|
176
186
|
DNI = 96,
|
|
177
|
-
|
|
187
|
+
FINAL_CONSUMER = 99
|
|
178
188
|
}
|
|
179
189
|
/**
|
|
180
|
-
*
|
|
190
|
+
* Ítem de factura
|
|
181
191
|
*/
|
|
182
|
-
interface
|
|
192
|
+
interface InvoiceItem {
|
|
183
193
|
/** Descripción del producto/servicio */
|
|
184
|
-
|
|
194
|
+
description: string;
|
|
185
195
|
/** Cantidad */
|
|
186
|
-
|
|
196
|
+
quantity: number;
|
|
187
197
|
/** Precio unitario */
|
|
188
|
-
|
|
189
|
-
/** IVA % (0, 10.5, 21, 27) */
|
|
190
|
-
|
|
198
|
+
unitPrice: number;
|
|
199
|
+
/** Alícuota IVA % (0, 10.5, 21, 27) */
|
|
200
|
+
vatRate?: number;
|
|
191
201
|
}
|
|
192
202
|
/**
|
|
193
203
|
* Datos del comprador
|
|
194
204
|
*/
|
|
195
|
-
interface
|
|
205
|
+
interface Buyer {
|
|
196
206
|
/** Tipo de documento */
|
|
197
|
-
|
|
207
|
+
docType: TaxIdType;
|
|
198
208
|
/** Número de documento (sin guiones) */
|
|
199
|
-
|
|
209
|
+
docNumber: string;
|
|
200
210
|
}
|
|
201
211
|
/**
|
|
202
|
-
* Request para emitir
|
|
212
|
+
* Request para emitir comprobante
|
|
203
213
|
*/
|
|
204
|
-
interface
|
|
214
|
+
interface IssueInvoiceRequest {
|
|
205
215
|
/** Tipo de comprobante */
|
|
206
|
-
|
|
216
|
+
type: InvoiceType;
|
|
207
217
|
/** Concepto */
|
|
208
|
-
|
|
218
|
+
concept: BillingConcept;
|
|
209
219
|
/** Comprador (opcional para Factura C consumidor final) */
|
|
210
|
-
|
|
211
|
-
/** Items de la factura
|
|
212
|
-
items?:
|
|
220
|
+
buyer?: Buyer;
|
|
221
|
+
/** Items de la factura */
|
|
222
|
+
items?: InvoiceItem[];
|
|
213
223
|
/** Monto total (requerido si no hay items) */
|
|
214
224
|
total?: number;
|
|
215
|
-
/** Desglose de IVA (requerido para Factura B
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
225
|
+
/** Desglose de IVA (requerido para Factura A/B) */
|
|
226
|
+
vatData?: {
|
|
227
|
+
rate: number;
|
|
228
|
+
taxBase: number;
|
|
229
|
+
amount: number;
|
|
220
230
|
}[];
|
|
221
|
-
/** Indica si los
|
|
222
|
-
|
|
231
|
+
/** Indica si los precios unitarios YA incluyen el IVA. Defecto: false */
|
|
232
|
+
includesVAT?: boolean;
|
|
223
233
|
/** Fecha del comprobante (default: hoy) */
|
|
224
|
-
|
|
234
|
+
date?: Date;
|
|
225
235
|
}
|
|
226
236
|
/**
|
|
227
237
|
* Respuesta CAE (Código de Autorización Electrónico)
|
|
228
238
|
*/
|
|
229
239
|
interface CAEResponse {
|
|
230
240
|
/** Tipo de comprobante */
|
|
231
|
-
|
|
241
|
+
invoiceType: number;
|
|
232
242
|
/** Punto de venta */
|
|
233
|
-
|
|
243
|
+
pointOfSale: number;
|
|
234
244
|
/** Número de comprobante */
|
|
235
|
-
|
|
236
|
-
/** Fecha de emisión */
|
|
237
|
-
|
|
245
|
+
invoiceNumber: number;
|
|
246
|
+
/** Fecha de emisión (YYYYMMDD) */
|
|
247
|
+
date: string;
|
|
238
248
|
/** CAE asignado */
|
|
239
249
|
cae: string;
|
|
240
|
-
/** Fecha de vencimiento del CAE */
|
|
241
|
-
|
|
250
|
+
/** Fecha de vencimiento del CAE (YYYYMMDD) */
|
|
251
|
+
caeExpiry: string;
|
|
242
252
|
/** Resultado (A = Aprobado, R = Rechazado) */
|
|
243
|
-
|
|
244
|
-
/** Observaciones de ARCA
|
|
245
|
-
|
|
253
|
+
result: 'A' | 'R';
|
|
254
|
+
/** Observaciones de ARCA */
|
|
255
|
+
observations?: string[];
|
|
246
256
|
/** Items (se retornan si fueron proveídos en el request) */
|
|
247
|
-
items?:
|
|
248
|
-
/** Desglose IVA (solo para Factura B
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
257
|
+
items?: InvoiceItem[];
|
|
258
|
+
/** Desglose IVA (solo para Factura A/B) */
|
|
259
|
+
vat?: {
|
|
260
|
+
rate: number;
|
|
261
|
+
taxBase: number;
|
|
262
|
+
amount: number;
|
|
253
263
|
}[];
|
|
254
264
|
/** URL del código QR oficial de ARCA */
|
|
255
|
-
|
|
265
|
+
qrUrl?: string;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Detalle de un comprobante consultado (FECompConsultar)
|
|
269
|
+
*/
|
|
270
|
+
interface InvoiceDetails {
|
|
271
|
+
/** Tipo de comprobante */
|
|
272
|
+
invoiceType: number;
|
|
273
|
+
/** Punto de venta */
|
|
274
|
+
pointOfSale: number;
|
|
275
|
+
/** Número de comprobante */
|
|
276
|
+
invoiceNumber: number;
|
|
277
|
+
/** Fecha de emisión (YYYYMMDD) */
|
|
278
|
+
date: string;
|
|
279
|
+
/** Concepto */
|
|
280
|
+
concept: number;
|
|
281
|
+
/** Tipo de documento del receptor */
|
|
282
|
+
docType: number;
|
|
283
|
+
/** Número de documento del receptor */
|
|
284
|
+
docNumber: number;
|
|
285
|
+
/** Importe total */
|
|
286
|
+
total: number;
|
|
287
|
+
/** Importe neto gravado */
|
|
288
|
+
net: number;
|
|
289
|
+
/** Importe IVA */
|
|
290
|
+
vat: number;
|
|
291
|
+
/** CAE */
|
|
292
|
+
cae: string;
|
|
293
|
+
/** Vencimiento CAE (YYYYMMDD) */
|
|
294
|
+
caeExpiry: string;
|
|
295
|
+
/** Resultado */
|
|
296
|
+
result: 'A' | 'R';
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Punto de venta habilitado en ARCA
|
|
300
|
+
*/
|
|
301
|
+
interface PointOfSale {
|
|
302
|
+
/** Número de punto de venta */
|
|
303
|
+
number: number;
|
|
304
|
+
/** Tipo (CAI, CAE, CAEA, etc.) */
|
|
305
|
+
type: string;
|
|
306
|
+
/** Indica si está bloqueado */
|
|
307
|
+
isBlocked: boolean;
|
|
308
|
+
/** Fecha de bloqueo (si aplica) */
|
|
309
|
+
blockedSince?: string;
|
|
256
310
|
}
|
|
257
311
|
/**
|
|
258
312
|
* Estado de los servidores de ARCA
|
|
259
313
|
*/
|
|
260
314
|
interface ServiceStatus {
|
|
261
315
|
/** Estado del servidor de aplicaciones */
|
|
262
|
-
|
|
316
|
+
appServer: string;
|
|
263
317
|
/** Estado del servidor de base de datos */
|
|
264
|
-
|
|
318
|
+
dbServer: string;
|
|
265
319
|
/** Estado del servidor de autenticación */
|
|
266
|
-
|
|
320
|
+
authServer: string;
|
|
267
321
|
}
|
|
268
322
|
|
|
269
323
|
/**
|
|
270
|
-
* Servicio de Facturación Electrónica
|
|
324
|
+
* Servicio de Facturación Electrónica WSFE v1
|
|
271
325
|
*
|
|
272
326
|
* @example
|
|
273
327
|
* ```typescript
|
|
@@ -275,16 +329,19 @@ interface ServiceStatus {
|
|
|
275
329
|
* environment: 'homologacion',
|
|
276
330
|
* cuit: '20123456789',
|
|
277
331
|
* ticket: await wsaa.login(),
|
|
278
|
-
*
|
|
279
|
-
* });
|
|
280
|
-
*
|
|
281
|
-
* const cae = await wsfe.emitirFacturaC({
|
|
282
|
-
* items: [
|
|
283
|
-
* { descripcion: 'Producto 1', cantidad: 2, precioUnitario: 100 }
|
|
284
|
-
* ]
|
|
332
|
+
* pointOfSale: 4,
|
|
285
333
|
* });
|
|
286
334
|
*
|
|
335
|
+
* // Ticket C rápido
|
|
336
|
+
* const cae = await wsfe.issueSimpleReceipt({ total: 1500 });
|
|
287
337
|
* console.log('CAE:', cae.cae);
|
|
338
|
+
* console.log('QR:', cae.qrUrl);
|
|
339
|
+
*
|
|
340
|
+
* // Factura A/B con IVA discriminado
|
|
341
|
+
* const cae = await wsfe.issueInvoiceB({
|
|
342
|
+
* items: [{ description: 'Servicio', quantity: 1, unitPrice: 1000, vatRate: 21 }],
|
|
343
|
+
* buyer: { docType: TaxIdType.CUIT, docNumber: '20987654321' },
|
|
344
|
+
* });
|
|
288
345
|
* ```
|
|
289
346
|
*/
|
|
290
347
|
declare class WsfeService {
|
|
@@ -292,94 +349,105 @@ declare class WsfeService {
|
|
|
292
349
|
constructor(config: WsfeConfig);
|
|
293
350
|
private validateConfig;
|
|
294
351
|
/**
|
|
295
|
-
*
|
|
296
|
-
*
|
|
352
|
+
* Verifica el estado de los servidores de ARCA (FEDummy).
|
|
353
|
+
* No requiere autenticación. Útil para health checks.
|
|
354
|
+
*
|
|
355
|
+
* @param environment Ambiente a consultar (default: 'homologacion')
|
|
297
356
|
*/
|
|
298
|
-
|
|
357
|
+
static checkStatus(environment?: 'homologacion' | 'produccion'): Promise<ServiceStatus>;
|
|
358
|
+
/**
|
|
359
|
+
* Verifica el estado de los servidores de ARCA.
|
|
360
|
+
* Versión de instancia — usa el ambiente configurado.
|
|
361
|
+
*/
|
|
362
|
+
checkStatus(): Promise<ServiceStatus>;
|
|
363
|
+
/**
|
|
364
|
+
* Emite un Ticket C simple (solo monto total, sin detalle de items).
|
|
365
|
+
* Ideal para registros mínimos, como una app móvil de punto de venta.
|
|
366
|
+
*/
|
|
367
|
+
issueSimpleReceipt(params: {
|
|
299
368
|
total: number;
|
|
300
|
-
|
|
301
|
-
|
|
369
|
+
concept?: BillingConcept;
|
|
370
|
+
date?: Date;
|
|
302
371
|
}): Promise<CAEResponse>;
|
|
303
372
|
/**
|
|
304
|
-
*
|
|
305
|
-
*
|
|
373
|
+
* Emite un Ticket C con detalle de items.
|
|
374
|
+
* Los items se guardan en la respuesta pero no se envían a ARCA.
|
|
306
375
|
*/
|
|
307
|
-
|
|
376
|
+
issueReceipt(params: {
|
|
377
|
+
items: InvoiceItem[];
|
|
378
|
+
concept?: BillingConcept;
|
|
379
|
+
date?: Date;
|
|
380
|
+
}): Promise<CAEResponse>;
|
|
308
381
|
/**
|
|
309
|
-
*
|
|
310
|
-
* No requiere autenticación.
|
|
382
|
+
* Emite una Factura C (consumidor final, sin discriminación de IVA).
|
|
311
383
|
*/
|
|
312
|
-
|
|
384
|
+
issueInvoiceC(params: {
|
|
385
|
+
items: InvoiceItem[];
|
|
386
|
+
concept?: BillingConcept;
|
|
387
|
+
date?: Date;
|
|
388
|
+
}): Promise<CAEResponse>;
|
|
313
389
|
/**
|
|
314
|
-
* Emite
|
|
315
|
-
*
|
|
390
|
+
* Emite una Factura B (con IVA discriminado).
|
|
391
|
+
* REQUIERE `vatRate` en todos los items.
|
|
316
392
|
*/
|
|
317
|
-
|
|
318
|
-
items:
|
|
319
|
-
|
|
320
|
-
|
|
393
|
+
issueInvoiceB(params: {
|
|
394
|
+
items: InvoiceItem[];
|
|
395
|
+
buyer: Buyer;
|
|
396
|
+
concept?: BillingConcept;
|
|
397
|
+
date?: Date;
|
|
398
|
+
includesVAT?: boolean;
|
|
321
399
|
}): Promise<CAEResponse>;
|
|
322
400
|
/**
|
|
323
|
-
* Emite una Factura
|
|
324
|
-
* REQUIERE
|
|
401
|
+
* Emite una Factura A (Responsable Inscripto a Responsable Inscripto, con IVA discriminado).
|
|
402
|
+
* REQUIERE `vatRate` en todos los items.
|
|
325
403
|
*/
|
|
326
|
-
|
|
327
|
-
items:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
404
|
+
issueInvoiceA(params: {
|
|
405
|
+
items: InvoiceItem[];
|
|
406
|
+
buyer: Buyer;
|
|
407
|
+
concept?: BillingConcept;
|
|
408
|
+
date?: Date;
|
|
409
|
+
includesVAT?: boolean;
|
|
332
410
|
}): Promise<CAEResponse>;
|
|
333
411
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
412
|
+
* Consulta un comprobante ya emitido (FECompConsultar).
|
|
413
|
+
*
|
|
414
|
+
* @param type Tipo de comprobante
|
|
415
|
+
* @param invoiceNumber Número de comprobante
|
|
336
416
|
*/
|
|
337
|
-
|
|
338
|
-
items: FacturaItem[];
|
|
339
|
-
comprador: Comprador;
|
|
340
|
-
concepto?: Concepto;
|
|
341
|
-
fecha?: Date;
|
|
342
|
-
incluyeIva?: boolean;
|
|
343
|
-
}): Promise<CAEResponse>;
|
|
417
|
+
getInvoice(type: InvoiceType, invoiceNumber: number): Promise<InvoiceDetails>;
|
|
344
418
|
/**
|
|
345
|
-
*
|
|
419
|
+
* Lista los puntos de venta habilitados para el CUIT autenticado (FEParamGetPtosVenta).
|
|
346
420
|
*/
|
|
347
|
-
|
|
421
|
+
getPointsOfSale(): Promise<PointOfSale[]>;
|
|
348
422
|
/**
|
|
349
|
-
*
|
|
350
|
-
* ARCA requiere esto para Factura B/A
|
|
423
|
+
* Método genérico interno para emitir cualquier tipo de comprobante.
|
|
351
424
|
*/
|
|
352
|
-
private
|
|
425
|
+
private issueDocument;
|
|
353
426
|
/**
|
|
354
|
-
*
|
|
355
|
-
* Forma simplificada sin especificar comprador
|
|
427
|
+
* Obtiene el próximo número de comprobante disponible (FECompUltimoAutorizado + 1)
|
|
356
428
|
*/
|
|
357
|
-
|
|
358
|
-
items: FacturaItem[];
|
|
359
|
-
concepto?: Concepto;
|
|
360
|
-
fecha?: Date;
|
|
361
|
-
}): Promise<CAEResponse>;
|
|
429
|
+
private getNextInvoiceNumber;
|
|
362
430
|
/**
|
|
363
|
-
*
|
|
431
|
+
* Valida que todos los items tengan alícuota IVA definida
|
|
364
432
|
*/
|
|
365
|
-
|
|
433
|
+
private validateItemsWithVAT;
|
|
366
434
|
/**
|
|
367
|
-
*
|
|
435
|
+
* Calcula el IVA agrupado por alícuota (requerido por ARCA para Factura A/B)
|
|
368
436
|
*/
|
|
369
|
-
private
|
|
370
|
-
private buildCAESolicitarRequest;
|
|
437
|
+
private calculateVATByRate;
|
|
371
438
|
/**
|
|
372
|
-
* Mapea alícuota %
|
|
439
|
+
* Mapea alícuota % al código interno de ARCA
|
|
373
440
|
*/
|
|
374
|
-
private
|
|
375
|
-
private
|
|
441
|
+
private getVATCode;
|
|
442
|
+
private buildCAERequest;
|
|
443
|
+
private buildLastInvoiceRequest;
|
|
376
444
|
private parseCAEResponse;
|
|
377
445
|
}
|
|
378
446
|
|
|
379
447
|
/**
|
|
380
448
|
* Configuración para PadronService
|
|
381
449
|
*/
|
|
382
|
-
interface
|
|
450
|
+
interface TaxpayerServiceConfig extends ArcaConfig {
|
|
383
451
|
/** CUIT del emisor (quien consulta) */
|
|
384
452
|
cuit: string;
|
|
385
453
|
/** Certificado X.509 en formato PEM */
|
|
@@ -392,95 +460,119 @@ interface PadronConfig extends ArcaConfig {
|
|
|
392
460
|
/**
|
|
393
461
|
* Actividad económica según AFIP
|
|
394
462
|
*/
|
|
395
|
-
interface
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
463
|
+
interface Activity {
|
|
464
|
+
id: number;
|
|
465
|
+
description: string;
|
|
466
|
+
order: number;
|
|
467
|
+
period: number;
|
|
400
468
|
}
|
|
401
469
|
/**
|
|
402
470
|
* Impuesto registrado en AFIP
|
|
403
471
|
*/
|
|
404
|
-
interface
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
472
|
+
interface TaxRecord {
|
|
473
|
+
id: number;
|
|
474
|
+
description: string;
|
|
475
|
+
period: number;
|
|
408
476
|
}
|
|
409
477
|
/**
|
|
410
|
-
*
|
|
478
|
+
* Domicilio registrado en AFIP
|
|
411
479
|
*/
|
|
412
|
-
interface
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
actividad?: Actividad[];
|
|
421
|
-
impuesto?: Impuesto[];
|
|
422
|
-
descripcionActividadPrincipal?: string;
|
|
423
|
-
esInscriptoIVA: boolean;
|
|
424
|
-
esMonotributista: boolean;
|
|
425
|
-
esExento: boolean;
|
|
480
|
+
interface Address {
|
|
481
|
+
street: string;
|
|
482
|
+
city?: string;
|
|
483
|
+
postalCode?: string;
|
|
484
|
+
provinceId: number;
|
|
485
|
+
province: string;
|
|
486
|
+
/** Tipo: FISCAL, LEGAL, etc. */
|
|
487
|
+
type: string;
|
|
426
488
|
}
|
|
427
489
|
/**
|
|
428
|
-
*
|
|
490
|
+
* Persona (física o jurídica) obtenida del Padrón A13
|
|
429
491
|
*/
|
|
430
|
-
interface
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
492
|
+
interface Taxpayer {
|
|
493
|
+
taxId: number;
|
|
494
|
+
personType: 'FISICA' | 'JURIDICA';
|
|
495
|
+
/** Nombre (persona física) */
|
|
496
|
+
firstName?: string;
|
|
497
|
+
/** Apellido (persona física) */
|
|
498
|
+
lastName?: string;
|
|
499
|
+
/** Razón social (persona jurídica) */
|
|
500
|
+
companyName?: string;
|
|
501
|
+
/** Estado de la clave fiscal */
|
|
502
|
+
status: string;
|
|
503
|
+
addresses: Address[];
|
|
504
|
+
activities?: Activity[];
|
|
505
|
+
taxes?: TaxRecord[];
|
|
506
|
+
mainActivity?: string;
|
|
507
|
+
/** ¿Está inscripto en IVA? */
|
|
508
|
+
isVATRegistered: boolean;
|
|
509
|
+
/** ¿Es monotributista? */
|
|
510
|
+
isMonotax: boolean;
|
|
511
|
+
/** ¿Es exento de IVA? */
|
|
512
|
+
isVATExempt: boolean;
|
|
437
513
|
}
|
|
438
514
|
/**
|
|
439
515
|
* Respuesta del servicio de Padrón
|
|
440
516
|
*/
|
|
441
|
-
interface
|
|
442
|
-
|
|
517
|
+
interface TaxpayerResponse {
|
|
518
|
+
taxpayer?: Taxpayer;
|
|
443
519
|
error?: string;
|
|
444
520
|
}
|
|
445
521
|
|
|
446
522
|
/**
|
|
447
523
|
* Servicio para consultar el Padrón de AFIP (ws_sr_padron_a13)
|
|
524
|
+
*
|
|
525
|
+
* @example
|
|
526
|
+
* ```typescript
|
|
527
|
+
* const padron = new PadronService({
|
|
528
|
+
* environment: 'homologacion',
|
|
529
|
+
* cuit: '20123456789',
|
|
530
|
+
* cert: fs.readFileSync('cert.pem', 'utf-8'),
|
|
531
|
+
* key: fs.readFileSync('key.pem', 'utf-8'),
|
|
532
|
+
* });
|
|
533
|
+
*
|
|
534
|
+
* const { taxpayer, error } = await padron.getTaxpayer('30111111118');
|
|
535
|
+
* if (taxpayer) {
|
|
536
|
+
* console.log(taxpayer.companyName || `${taxpayer.firstName} ${taxpayer.lastName}`);
|
|
537
|
+
* console.log('¿Inscripto IVA?:', taxpayer.isVATRegistered);
|
|
538
|
+
* }
|
|
539
|
+
* ```
|
|
448
540
|
*/
|
|
449
541
|
declare class PadronService {
|
|
450
542
|
private wsaa;
|
|
451
543
|
private config;
|
|
452
|
-
constructor(config:
|
|
544
|
+
constructor(config: TaxpayerServiceConfig);
|
|
453
545
|
/**
|
|
454
|
-
* Consulta los datos de
|
|
546
|
+
* Consulta los datos de un contribuyente por CUIT
|
|
455
547
|
*
|
|
456
|
-
* @param
|
|
457
|
-
* @returns Datos
|
|
548
|
+
* @param taxId CUIT a consultar (11 dígitos sin guiones)
|
|
549
|
+
* @returns Datos del contribuyente o mensaje de error
|
|
458
550
|
*/
|
|
459
|
-
|
|
551
|
+
getTaxpayer(taxId: string): Promise<TaxpayerResponse>;
|
|
460
552
|
/**
|
|
461
|
-
*
|
|
553
|
+
* Parsea la respuesta XML de getPersona
|
|
462
554
|
*/
|
|
463
555
|
private parseResponse;
|
|
464
|
-
private
|
|
465
|
-
private
|
|
466
|
-
private
|
|
467
|
-
private
|
|
556
|
+
private mapAddresses;
|
|
557
|
+
private mapActivities;
|
|
558
|
+
private mapTaxRecords;
|
|
559
|
+
private hasTaxId;
|
|
468
560
|
/**
|
|
469
|
-
*
|
|
561
|
+
* Normaliza un valor que puede ser un objeto único o un array (comportamiento de fast-xml-parser)
|
|
470
562
|
*/
|
|
471
|
-
private
|
|
563
|
+
private toArray;
|
|
472
564
|
}
|
|
473
565
|
|
|
474
566
|
/**
|
|
475
567
|
* Genera la URL completa con el código QR para un comprobante emitido.
|
|
476
|
-
*
|
|
568
|
+
* Implementa la versión oficial con orden estricto de campos según spec de ARCA.
|
|
477
569
|
*
|
|
478
570
|
* @param caeResponse Respuesta obtenida al emitir la factura (CAEResponse)
|
|
479
|
-
* @param
|
|
571
|
+
* @param issuerCUIT CUIT del emisor (con o sin guiones)
|
|
480
572
|
* @param total Importe total del comprobante
|
|
481
|
-
* @param
|
|
482
|
-
* @returns
|
|
573
|
+
* @param buyer Datos del comprador (opcional)
|
|
574
|
+
* @returns URL lista para embeber en un generador de QR
|
|
483
575
|
*/
|
|
484
|
-
declare function
|
|
576
|
+
declare function generateQRUrl(caeResponse: CAEResponse, issuerCUIT: string, total: number, buyer?: Buyer): string;
|
|
485
577
|
|
|
486
|
-
export { ArcaAuthError, type ArcaConfig, ArcaError, ArcaValidationError, type
|
|
578
|
+
export { type Activity, type Address, ArcaAuthError, type ArcaConfig, ArcaError, ArcaNetworkError, ArcaValidationError, BillingConcept, type Buyer, type CAEResponse, type Environment, type InvoiceDetails, type InvoiceItem, InvoiceType, type IssueInvoiceRequest, type LoginTicket, PadronService, type PointOfSale, type ServiceStatus, TaxIdType, type TaxRecord, type Taxpayer, type TaxpayerResponse, type TaxpayerServiceConfig, type TokenStorage, type WsaaConfig, WsaaService, type WsfeConfig, WsfeService, generateQRUrl };
|