arca-sdk 1.0.4 → 1.1.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 +13 -0
- package/README.md +27 -1
- package/dist/index.cjs +160 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -5
- package/dist/index.d.ts +143 -5
- package/dist/index.js +160 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -152,8 +152,17 @@ interface WsfeConfig extends ArcaConfig {
|
|
|
152
152
|
*/
|
|
153
153
|
declare enum InvoiceType {
|
|
154
154
|
FACTURA_A = 1,
|
|
155
|
+
NOTA_DEBITO_A = 2,
|
|
156
|
+
NOTA_CREDITO_A = 3,
|
|
157
|
+
RECIBO_A = 4,
|
|
155
158
|
FACTURA_B = 6,
|
|
159
|
+
NOTA_DEBITO_B = 7,
|
|
160
|
+
NOTA_CREDITO_B = 8,
|
|
161
|
+
RECIBO_B = 9,
|
|
156
162
|
FACTURA_C = 11,
|
|
163
|
+
NOTA_DEBITO_C = 12,
|
|
164
|
+
NOTA_CREDITO_C = 13,
|
|
165
|
+
RECIBO_C = 15,
|
|
157
166
|
TICKET_A = 81,
|
|
158
167
|
TICKET_B = 82,
|
|
159
168
|
TICKET_C = 83
|
|
@@ -208,6 +217,21 @@ interface Buyer {
|
|
|
208
217
|
/** Número de documento (sin guiones) */
|
|
209
218
|
docNumber: string;
|
|
210
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Comprobante asociado (Requerido al emitir Notas de Crédito/Débito)
|
|
222
|
+
*/
|
|
223
|
+
interface AssociatedInvoice {
|
|
224
|
+
/** Tipo de comprobante original (ej. FACTURA_C) */
|
|
225
|
+
type: InvoiceType;
|
|
226
|
+
/** Punto de venta original */
|
|
227
|
+
pointOfSale: number;
|
|
228
|
+
/** Número de comprobante original */
|
|
229
|
+
invoiceNumber: number;
|
|
230
|
+
/** CUIT emisor (requerido a veces en MiPyME, opcional para resto) */
|
|
231
|
+
cuit?: string;
|
|
232
|
+
/** Fecha de emisión del comprobante original */
|
|
233
|
+
date?: Date;
|
|
234
|
+
}
|
|
211
235
|
/**
|
|
212
236
|
* Request para emitir comprobante
|
|
213
237
|
*/
|
|
@@ -220,6 +244,8 @@ interface IssueInvoiceRequest {
|
|
|
220
244
|
buyer?: Buyer;
|
|
221
245
|
/** Items de la factura */
|
|
222
246
|
items?: InvoiceItem[];
|
|
247
|
+
/** Comprobantes asociados (Obligatorio para Nota de Crédito/Débito) */
|
|
248
|
+
associatedInvoices?: AssociatedInvoice[];
|
|
223
249
|
/** Monto total (requerido si no hay items) */
|
|
224
250
|
total?: number;
|
|
225
251
|
/** Desglose de IVA (requerido para Factura A/B) */
|
|
@@ -379,12 +405,15 @@ declare class WsfeService {
|
|
|
379
405
|
date?: Date;
|
|
380
406
|
}): Promise<CAEResponse>;
|
|
381
407
|
/**
|
|
382
|
-
* Emite una Factura
|
|
408
|
+
* Emite una Factura A (Responsable Inscripto a Responsable Inscripto, con IVA discriminado).
|
|
409
|
+
* REQUIERE `vatRate` en todos los items.
|
|
383
410
|
*/
|
|
384
|
-
|
|
411
|
+
issueInvoiceA(params: {
|
|
385
412
|
items: InvoiceItem[];
|
|
413
|
+
buyer: Buyer;
|
|
386
414
|
concept?: BillingConcept;
|
|
387
415
|
date?: Date;
|
|
416
|
+
includesVAT?: boolean;
|
|
388
417
|
}): Promise<CAEResponse>;
|
|
389
418
|
/**
|
|
390
419
|
* Emite una Factura B (con IVA discriminado).
|
|
@@ -398,16 +427,113 @@ declare class WsfeService {
|
|
|
398
427
|
includesVAT?: boolean;
|
|
399
428
|
}): Promise<CAEResponse>;
|
|
400
429
|
/**
|
|
401
|
-
* Emite una Factura
|
|
402
|
-
* REQUIERE `vatRate` en todos los items.
|
|
430
|
+
* Emite una Factura C (consumidor final, sin discriminación de IVA).
|
|
403
431
|
*/
|
|
404
|
-
|
|
432
|
+
issueInvoiceC(params: {
|
|
433
|
+
items: InvoiceItem[];
|
|
434
|
+
concept?: BillingConcept;
|
|
435
|
+
date?: Date;
|
|
436
|
+
buyer?: Buyer;
|
|
437
|
+
}): Promise<CAEResponse>;
|
|
438
|
+
/**
|
|
439
|
+
* Emite un Recibo A (con IVA discriminado).
|
|
440
|
+
*/
|
|
441
|
+
issueReceiptA(params: {
|
|
405
442
|
items: InvoiceItem[];
|
|
406
443
|
buyer: Buyer;
|
|
407
444
|
concept?: BillingConcept;
|
|
408
445
|
date?: Date;
|
|
409
446
|
includesVAT?: boolean;
|
|
410
447
|
}): Promise<CAEResponse>;
|
|
448
|
+
/**
|
|
449
|
+
* Emite un Recibo B (con IVA discriminado).
|
|
450
|
+
*/
|
|
451
|
+
issueReceiptB(params: {
|
|
452
|
+
items: InvoiceItem[];
|
|
453
|
+
buyer: Buyer;
|
|
454
|
+
concept?: BillingConcept;
|
|
455
|
+
date?: Date;
|
|
456
|
+
includesVAT?: boolean;
|
|
457
|
+
}): Promise<CAEResponse>;
|
|
458
|
+
/**
|
|
459
|
+
* Emite un Recibo C (sin discriminación de IVA).
|
|
460
|
+
*/
|
|
461
|
+
issueReceiptC(params: {
|
|
462
|
+
items: InvoiceItem[];
|
|
463
|
+
concept?: BillingConcept;
|
|
464
|
+
date?: Date;
|
|
465
|
+
buyer?: Buyer;
|
|
466
|
+
}): Promise<CAEResponse>;
|
|
467
|
+
/**
|
|
468
|
+
* Emite una Nota de Crédito A.
|
|
469
|
+
* REQUIERE especificar la Factura A original en `associatedInvoices`.
|
|
470
|
+
*/
|
|
471
|
+
issueCreditNoteA(params: {
|
|
472
|
+
items: InvoiceItem[];
|
|
473
|
+
buyer: Buyer;
|
|
474
|
+
associatedInvoices: AssociatedInvoice[];
|
|
475
|
+
concept?: BillingConcept;
|
|
476
|
+
date?: Date;
|
|
477
|
+
includesVAT?: boolean;
|
|
478
|
+
}): Promise<CAEResponse>;
|
|
479
|
+
/**
|
|
480
|
+
* Emite una Nota de Crédito B.
|
|
481
|
+
* REQUIERE especificar la Factura B original en `associatedInvoices`.
|
|
482
|
+
*/
|
|
483
|
+
issueCreditNoteB(params: {
|
|
484
|
+
items: InvoiceItem[];
|
|
485
|
+
buyer: Buyer;
|
|
486
|
+
associatedInvoices: AssociatedInvoice[];
|
|
487
|
+
concept?: BillingConcept;
|
|
488
|
+
date?: Date;
|
|
489
|
+
includesVAT?: boolean;
|
|
490
|
+
}): Promise<CAEResponse>;
|
|
491
|
+
/**
|
|
492
|
+
* Emite una Nota de Crédito C.
|
|
493
|
+
* REQUIERE especificar la Factura C original en `associatedInvoices`.
|
|
494
|
+
*/
|
|
495
|
+
issueCreditNoteC(params: {
|
|
496
|
+
items: InvoiceItem[];
|
|
497
|
+
associatedInvoices: AssociatedInvoice[];
|
|
498
|
+
concept?: BillingConcept;
|
|
499
|
+
date?: Date;
|
|
500
|
+
buyer?: Buyer;
|
|
501
|
+
}): Promise<CAEResponse>;
|
|
502
|
+
/**
|
|
503
|
+
* Emite una Nota de Débito A.
|
|
504
|
+
* REQUIERE especificar la Factura A original en `associatedInvoices`.
|
|
505
|
+
*/
|
|
506
|
+
issueDebitNoteA(params: {
|
|
507
|
+
items: InvoiceItem[];
|
|
508
|
+
buyer: Buyer;
|
|
509
|
+
associatedInvoices: AssociatedInvoice[];
|
|
510
|
+
concept?: BillingConcept;
|
|
511
|
+
date?: Date;
|
|
512
|
+
includesVAT?: boolean;
|
|
513
|
+
}): Promise<CAEResponse>;
|
|
514
|
+
/**
|
|
515
|
+
* Emite una Nota de Débito B.
|
|
516
|
+
* REQUIERE especificar la Factura B original en `associatedInvoices`.
|
|
517
|
+
*/
|
|
518
|
+
issueDebitNoteB(params: {
|
|
519
|
+
items: InvoiceItem[];
|
|
520
|
+
buyer: Buyer;
|
|
521
|
+
associatedInvoices: AssociatedInvoice[];
|
|
522
|
+
concept?: BillingConcept;
|
|
523
|
+
date?: Date;
|
|
524
|
+
includesVAT?: boolean;
|
|
525
|
+
}): Promise<CAEResponse>;
|
|
526
|
+
/**
|
|
527
|
+
* Emite una Nota de Débito C.
|
|
528
|
+
* REQUIERE especificar la Factura C original en `associatedInvoices`.
|
|
529
|
+
*/
|
|
530
|
+
issueDebitNoteC(params: {
|
|
531
|
+
items: InvoiceItem[];
|
|
532
|
+
associatedInvoices: AssociatedInvoice[];
|
|
533
|
+
concept?: BillingConcept;
|
|
534
|
+
date?: Date;
|
|
535
|
+
buyer?: Buyer;
|
|
536
|
+
}): Promise<CAEResponse>;
|
|
411
537
|
/**
|
|
412
538
|
* Consulta un comprobante ya emitido (FECompConsultar).
|
|
413
539
|
*
|
|
@@ -419,6 +545,18 @@ declare class WsfeService {
|
|
|
419
545
|
* Lista los puntos de venta habilitados para el CUIT autenticado (FEParamGetPtosVenta).
|
|
420
546
|
*/
|
|
421
547
|
getPointsOfSale(): Promise<PointOfSale[]>;
|
|
548
|
+
/**
|
|
549
|
+
* Helper para emitir comprobantes tipo A/B que requieren IVA
|
|
550
|
+
*/
|
|
551
|
+
private issueInvoiceWithVAT;
|
|
552
|
+
/**
|
|
553
|
+
* Helper para emitir comprobantes tipo C que no discriminan IVA
|
|
554
|
+
*/
|
|
555
|
+
private issueInvoiceWithoutVAT;
|
|
556
|
+
/**
|
|
557
|
+
* Validación obligatoria para NC/ND
|
|
558
|
+
*/
|
|
559
|
+
private validateAssociatedInvoices;
|
|
422
560
|
/**
|
|
423
561
|
* Método genérico interno para emitir cualquier tipo de comprobante.
|
|
424
562
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -152,8 +152,17 @@ interface WsfeConfig extends ArcaConfig {
|
|
|
152
152
|
*/
|
|
153
153
|
declare enum InvoiceType {
|
|
154
154
|
FACTURA_A = 1,
|
|
155
|
+
NOTA_DEBITO_A = 2,
|
|
156
|
+
NOTA_CREDITO_A = 3,
|
|
157
|
+
RECIBO_A = 4,
|
|
155
158
|
FACTURA_B = 6,
|
|
159
|
+
NOTA_DEBITO_B = 7,
|
|
160
|
+
NOTA_CREDITO_B = 8,
|
|
161
|
+
RECIBO_B = 9,
|
|
156
162
|
FACTURA_C = 11,
|
|
163
|
+
NOTA_DEBITO_C = 12,
|
|
164
|
+
NOTA_CREDITO_C = 13,
|
|
165
|
+
RECIBO_C = 15,
|
|
157
166
|
TICKET_A = 81,
|
|
158
167
|
TICKET_B = 82,
|
|
159
168
|
TICKET_C = 83
|
|
@@ -208,6 +217,21 @@ interface Buyer {
|
|
|
208
217
|
/** Número de documento (sin guiones) */
|
|
209
218
|
docNumber: string;
|
|
210
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Comprobante asociado (Requerido al emitir Notas de Crédito/Débito)
|
|
222
|
+
*/
|
|
223
|
+
interface AssociatedInvoice {
|
|
224
|
+
/** Tipo de comprobante original (ej. FACTURA_C) */
|
|
225
|
+
type: InvoiceType;
|
|
226
|
+
/** Punto de venta original */
|
|
227
|
+
pointOfSale: number;
|
|
228
|
+
/** Número de comprobante original */
|
|
229
|
+
invoiceNumber: number;
|
|
230
|
+
/** CUIT emisor (requerido a veces en MiPyME, opcional para resto) */
|
|
231
|
+
cuit?: string;
|
|
232
|
+
/** Fecha de emisión del comprobante original */
|
|
233
|
+
date?: Date;
|
|
234
|
+
}
|
|
211
235
|
/**
|
|
212
236
|
* Request para emitir comprobante
|
|
213
237
|
*/
|
|
@@ -220,6 +244,8 @@ interface IssueInvoiceRequest {
|
|
|
220
244
|
buyer?: Buyer;
|
|
221
245
|
/** Items de la factura */
|
|
222
246
|
items?: InvoiceItem[];
|
|
247
|
+
/** Comprobantes asociados (Obligatorio para Nota de Crédito/Débito) */
|
|
248
|
+
associatedInvoices?: AssociatedInvoice[];
|
|
223
249
|
/** Monto total (requerido si no hay items) */
|
|
224
250
|
total?: number;
|
|
225
251
|
/** Desglose de IVA (requerido para Factura A/B) */
|
|
@@ -379,12 +405,15 @@ declare class WsfeService {
|
|
|
379
405
|
date?: Date;
|
|
380
406
|
}): Promise<CAEResponse>;
|
|
381
407
|
/**
|
|
382
|
-
* Emite una Factura
|
|
408
|
+
* Emite una Factura A (Responsable Inscripto a Responsable Inscripto, con IVA discriminado).
|
|
409
|
+
* REQUIERE `vatRate` en todos los items.
|
|
383
410
|
*/
|
|
384
|
-
|
|
411
|
+
issueInvoiceA(params: {
|
|
385
412
|
items: InvoiceItem[];
|
|
413
|
+
buyer: Buyer;
|
|
386
414
|
concept?: BillingConcept;
|
|
387
415
|
date?: Date;
|
|
416
|
+
includesVAT?: boolean;
|
|
388
417
|
}): Promise<CAEResponse>;
|
|
389
418
|
/**
|
|
390
419
|
* Emite una Factura B (con IVA discriminado).
|
|
@@ -398,16 +427,113 @@ declare class WsfeService {
|
|
|
398
427
|
includesVAT?: boolean;
|
|
399
428
|
}): Promise<CAEResponse>;
|
|
400
429
|
/**
|
|
401
|
-
* Emite una Factura
|
|
402
|
-
* REQUIERE `vatRate` en todos los items.
|
|
430
|
+
* Emite una Factura C (consumidor final, sin discriminación de IVA).
|
|
403
431
|
*/
|
|
404
|
-
|
|
432
|
+
issueInvoiceC(params: {
|
|
433
|
+
items: InvoiceItem[];
|
|
434
|
+
concept?: BillingConcept;
|
|
435
|
+
date?: Date;
|
|
436
|
+
buyer?: Buyer;
|
|
437
|
+
}): Promise<CAEResponse>;
|
|
438
|
+
/**
|
|
439
|
+
* Emite un Recibo A (con IVA discriminado).
|
|
440
|
+
*/
|
|
441
|
+
issueReceiptA(params: {
|
|
405
442
|
items: InvoiceItem[];
|
|
406
443
|
buyer: Buyer;
|
|
407
444
|
concept?: BillingConcept;
|
|
408
445
|
date?: Date;
|
|
409
446
|
includesVAT?: boolean;
|
|
410
447
|
}): Promise<CAEResponse>;
|
|
448
|
+
/**
|
|
449
|
+
* Emite un Recibo B (con IVA discriminado).
|
|
450
|
+
*/
|
|
451
|
+
issueReceiptB(params: {
|
|
452
|
+
items: InvoiceItem[];
|
|
453
|
+
buyer: Buyer;
|
|
454
|
+
concept?: BillingConcept;
|
|
455
|
+
date?: Date;
|
|
456
|
+
includesVAT?: boolean;
|
|
457
|
+
}): Promise<CAEResponse>;
|
|
458
|
+
/**
|
|
459
|
+
* Emite un Recibo C (sin discriminación de IVA).
|
|
460
|
+
*/
|
|
461
|
+
issueReceiptC(params: {
|
|
462
|
+
items: InvoiceItem[];
|
|
463
|
+
concept?: BillingConcept;
|
|
464
|
+
date?: Date;
|
|
465
|
+
buyer?: Buyer;
|
|
466
|
+
}): Promise<CAEResponse>;
|
|
467
|
+
/**
|
|
468
|
+
* Emite una Nota de Crédito A.
|
|
469
|
+
* REQUIERE especificar la Factura A original en `associatedInvoices`.
|
|
470
|
+
*/
|
|
471
|
+
issueCreditNoteA(params: {
|
|
472
|
+
items: InvoiceItem[];
|
|
473
|
+
buyer: Buyer;
|
|
474
|
+
associatedInvoices: AssociatedInvoice[];
|
|
475
|
+
concept?: BillingConcept;
|
|
476
|
+
date?: Date;
|
|
477
|
+
includesVAT?: boolean;
|
|
478
|
+
}): Promise<CAEResponse>;
|
|
479
|
+
/**
|
|
480
|
+
* Emite una Nota de Crédito B.
|
|
481
|
+
* REQUIERE especificar la Factura B original en `associatedInvoices`.
|
|
482
|
+
*/
|
|
483
|
+
issueCreditNoteB(params: {
|
|
484
|
+
items: InvoiceItem[];
|
|
485
|
+
buyer: Buyer;
|
|
486
|
+
associatedInvoices: AssociatedInvoice[];
|
|
487
|
+
concept?: BillingConcept;
|
|
488
|
+
date?: Date;
|
|
489
|
+
includesVAT?: boolean;
|
|
490
|
+
}): Promise<CAEResponse>;
|
|
491
|
+
/**
|
|
492
|
+
* Emite una Nota de Crédito C.
|
|
493
|
+
* REQUIERE especificar la Factura C original en `associatedInvoices`.
|
|
494
|
+
*/
|
|
495
|
+
issueCreditNoteC(params: {
|
|
496
|
+
items: InvoiceItem[];
|
|
497
|
+
associatedInvoices: AssociatedInvoice[];
|
|
498
|
+
concept?: BillingConcept;
|
|
499
|
+
date?: Date;
|
|
500
|
+
buyer?: Buyer;
|
|
501
|
+
}): Promise<CAEResponse>;
|
|
502
|
+
/**
|
|
503
|
+
* Emite una Nota de Débito A.
|
|
504
|
+
* REQUIERE especificar la Factura A original en `associatedInvoices`.
|
|
505
|
+
*/
|
|
506
|
+
issueDebitNoteA(params: {
|
|
507
|
+
items: InvoiceItem[];
|
|
508
|
+
buyer: Buyer;
|
|
509
|
+
associatedInvoices: AssociatedInvoice[];
|
|
510
|
+
concept?: BillingConcept;
|
|
511
|
+
date?: Date;
|
|
512
|
+
includesVAT?: boolean;
|
|
513
|
+
}): Promise<CAEResponse>;
|
|
514
|
+
/**
|
|
515
|
+
* Emite una Nota de Débito B.
|
|
516
|
+
* REQUIERE especificar la Factura B original en `associatedInvoices`.
|
|
517
|
+
*/
|
|
518
|
+
issueDebitNoteB(params: {
|
|
519
|
+
items: InvoiceItem[];
|
|
520
|
+
buyer: Buyer;
|
|
521
|
+
associatedInvoices: AssociatedInvoice[];
|
|
522
|
+
concept?: BillingConcept;
|
|
523
|
+
date?: Date;
|
|
524
|
+
includesVAT?: boolean;
|
|
525
|
+
}): Promise<CAEResponse>;
|
|
526
|
+
/**
|
|
527
|
+
* Emite una Nota de Débito C.
|
|
528
|
+
* REQUIERE especificar la Factura C original en `associatedInvoices`.
|
|
529
|
+
*/
|
|
530
|
+
issueDebitNoteC(params: {
|
|
531
|
+
items: InvoiceItem[];
|
|
532
|
+
associatedInvoices: AssociatedInvoice[];
|
|
533
|
+
concept?: BillingConcept;
|
|
534
|
+
date?: Date;
|
|
535
|
+
buyer?: Buyer;
|
|
536
|
+
}): Promise<CAEResponse>;
|
|
411
537
|
/**
|
|
412
538
|
* Consulta un comprobante ya emitido (FECompConsultar).
|
|
413
539
|
*
|
|
@@ -419,6 +545,18 @@ declare class WsfeService {
|
|
|
419
545
|
* Lista los puntos de venta habilitados para el CUIT autenticado (FEParamGetPtosVenta).
|
|
420
546
|
*/
|
|
421
547
|
getPointsOfSale(): Promise<PointOfSale[]>;
|
|
548
|
+
/**
|
|
549
|
+
* Helper para emitir comprobantes tipo A/B que requieren IVA
|
|
550
|
+
*/
|
|
551
|
+
private issueInvoiceWithVAT;
|
|
552
|
+
/**
|
|
553
|
+
* Helper para emitir comprobantes tipo C que no discriminan IVA
|
|
554
|
+
*/
|
|
555
|
+
private issueInvoiceWithoutVAT;
|
|
556
|
+
/**
|
|
557
|
+
* Validación obligatoria para NC/ND
|
|
558
|
+
*/
|
|
559
|
+
private validateAssociatedInvoices;
|
|
422
560
|
/**
|
|
423
561
|
* Método genérico interno para emitir cualquier tipo de comprobante.
|
|
424
562
|
*/
|
package/dist/index.js
CHANGED
|
@@ -461,8 +461,17 @@ var WsaaService = class {
|
|
|
461
461
|
// src/types/wsfe.ts
|
|
462
462
|
var InvoiceType = /* @__PURE__ */ ((InvoiceType2) => {
|
|
463
463
|
InvoiceType2[InvoiceType2["FACTURA_A"] = 1] = "FACTURA_A";
|
|
464
|
+
InvoiceType2[InvoiceType2["NOTA_DEBITO_A"] = 2] = "NOTA_DEBITO_A";
|
|
465
|
+
InvoiceType2[InvoiceType2["NOTA_CREDITO_A"] = 3] = "NOTA_CREDITO_A";
|
|
466
|
+
InvoiceType2[InvoiceType2["RECIBO_A"] = 4] = "RECIBO_A";
|
|
464
467
|
InvoiceType2[InvoiceType2["FACTURA_B"] = 6] = "FACTURA_B";
|
|
468
|
+
InvoiceType2[InvoiceType2["NOTA_DEBITO_B"] = 7] = "NOTA_DEBITO_B";
|
|
469
|
+
InvoiceType2[InvoiceType2["NOTA_CREDITO_B"] = 8] = "NOTA_CREDITO_B";
|
|
470
|
+
InvoiceType2[InvoiceType2["RECIBO_B"] = 9] = "RECIBO_B";
|
|
465
471
|
InvoiceType2[InvoiceType2["FACTURA_C"] = 11] = "FACTURA_C";
|
|
472
|
+
InvoiceType2[InvoiceType2["NOTA_DEBITO_C"] = 12] = "NOTA_DEBITO_C";
|
|
473
|
+
InvoiceType2[InvoiceType2["NOTA_CREDITO_C"] = 13] = "NOTA_CREDITO_C";
|
|
474
|
+
InvoiceType2[InvoiceType2["RECIBO_C"] = 15] = "RECIBO_C";
|
|
466
475
|
InvoiceType2[InvoiceType2["TICKET_A"] = 81] = "TICKET_A";
|
|
467
476
|
InvoiceType2[InvoiceType2["TICKET_B"] = 82] = "TICKET_B";
|
|
468
477
|
InvoiceType2[InvoiceType2["TICKET_C"] = 83] = "TICKET_C";
|
|
@@ -691,57 +700,93 @@ var WsfeService = class _WsfeService {
|
|
|
691
700
|
return { ...cae, items: params.items };
|
|
692
701
|
}
|
|
693
702
|
/**
|
|
694
|
-
* Emite una Factura
|
|
703
|
+
* Emite una Factura A (Responsable Inscripto a Responsable Inscripto, con IVA discriminado).
|
|
704
|
+
* REQUIERE `vatRate` en todos los items.
|
|
695
705
|
*/
|
|
696
|
-
async
|
|
697
|
-
|
|
698
|
-
return this.issueDocument({
|
|
699
|
-
type: 11 /* FACTURA_C */,
|
|
700
|
-
concept: params.concept || 1 /* PRODUCTS */,
|
|
701
|
-
total,
|
|
702
|
-
date: params.date,
|
|
703
|
-
buyer: {
|
|
704
|
-
docType: 99 /* FINAL_CONSUMER */,
|
|
705
|
-
docNumber: "0"
|
|
706
|
-
},
|
|
707
|
-
items: params.items
|
|
708
|
-
});
|
|
706
|
+
async issueInvoiceA(params) {
|
|
707
|
+
return this.issueInvoiceWithVAT(1 /* FACTURA_A */, params);
|
|
709
708
|
}
|
|
710
709
|
/**
|
|
711
710
|
* Emite una Factura B (con IVA discriminado).
|
|
712
711
|
* REQUIERE `vatRate` en todos los items.
|
|
713
712
|
*/
|
|
714
713
|
async issueInvoiceB(params) {
|
|
715
|
-
this.
|
|
716
|
-
const includesVAT = params.includesVAT || false;
|
|
717
|
-
const vatData = this.calculateVATByRate(params.items, includesVAT);
|
|
718
|
-
return this.issueDocument({
|
|
719
|
-
type: 6 /* FACTURA_B */,
|
|
720
|
-
concept: params.concept || 1 /* PRODUCTS */,
|
|
721
|
-
items: params.items,
|
|
722
|
-
buyer: params.buyer,
|
|
723
|
-
date: params.date,
|
|
724
|
-
vatData,
|
|
725
|
-
includesVAT
|
|
726
|
-
});
|
|
714
|
+
return this.issueInvoiceWithVAT(6 /* FACTURA_B */, params);
|
|
727
715
|
}
|
|
728
716
|
/**
|
|
729
|
-
* Emite una Factura
|
|
730
|
-
* REQUIERE `vatRate` en todos los items.
|
|
717
|
+
* Emite una Factura C (consumidor final, sin discriminación de IVA).
|
|
731
718
|
*/
|
|
732
|
-
async
|
|
733
|
-
this.
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
719
|
+
async issueInvoiceC(params) {
|
|
720
|
+
return this.issueInvoiceWithoutVAT(11 /* FACTURA_C */, params);
|
|
721
|
+
}
|
|
722
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
723
|
+
// Recibos
|
|
724
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
725
|
+
/**
|
|
726
|
+
* Emite un Recibo A (con IVA discriminado).
|
|
727
|
+
*/
|
|
728
|
+
async issueReceiptA(params) {
|
|
729
|
+
return this.issueInvoiceWithVAT(4 /* RECIBO_A */, params);
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Emite un Recibo B (con IVA discriminado).
|
|
733
|
+
*/
|
|
734
|
+
async issueReceiptB(params) {
|
|
735
|
+
return this.issueInvoiceWithVAT(9 /* RECIBO_B */, params);
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Emite un Recibo C (sin discriminación de IVA).
|
|
739
|
+
*/
|
|
740
|
+
async issueReceiptC(params) {
|
|
741
|
+
return this.issueInvoiceWithoutVAT(15 /* RECIBO_C */, params);
|
|
742
|
+
}
|
|
743
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
744
|
+
// Notas de Crédito
|
|
745
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
746
|
+
/**
|
|
747
|
+
* Emite una Nota de Crédito A.
|
|
748
|
+
* REQUIERE especificar la Factura A original en `associatedInvoices`.
|
|
749
|
+
*/
|
|
750
|
+
async issueCreditNoteA(params) {
|
|
751
|
+
return this.issueInvoiceWithVAT(3 /* NOTA_CREDITO_A */, params);
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Emite una Nota de Crédito B.
|
|
755
|
+
* REQUIERE especificar la Factura B original en `associatedInvoices`.
|
|
756
|
+
*/
|
|
757
|
+
async issueCreditNoteB(params) {
|
|
758
|
+
return this.issueInvoiceWithVAT(8 /* NOTA_CREDITO_B */, params);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Emite una Nota de Crédito C.
|
|
762
|
+
* REQUIERE especificar la Factura C original en `associatedInvoices`.
|
|
763
|
+
*/
|
|
764
|
+
async issueCreditNoteC(params) {
|
|
765
|
+
return this.issueInvoiceWithoutVAT(13 /* NOTA_CREDITO_C */, params);
|
|
766
|
+
}
|
|
767
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
768
|
+
// Notas de Débito
|
|
769
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
770
|
+
/**
|
|
771
|
+
* Emite una Nota de Débito A.
|
|
772
|
+
* REQUIERE especificar la Factura A original en `associatedInvoices`.
|
|
773
|
+
*/
|
|
774
|
+
async issueDebitNoteA(params) {
|
|
775
|
+
return this.issueInvoiceWithVAT(2 /* NOTA_DEBITO_A */, params);
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Emite una Nota de Débito B.
|
|
779
|
+
* REQUIERE especificar la Factura B original en `associatedInvoices`.
|
|
780
|
+
*/
|
|
781
|
+
async issueDebitNoteB(params) {
|
|
782
|
+
return this.issueInvoiceWithVAT(7 /* NOTA_DEBITO_B */, params);
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Emite una Nota de Débito C.
|
|
786
|
+
* REQUIERE especificar la Factura C original en `associatedInvoices`.
|
|
787
|
+
*/
|
|
788
|
+
async issueDebitNoteC(params) {
|
|
789
|
+
return this.issueInvoiceWithoutVAT(12 /* NOTA_DEBITO_C */, params);
|
|
745
790
|
}
|
|
746
791
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
747
792
|
// Consultas
|
|
@@ -872,6 +917,63 @@ var WsfeService = class _WsfeService {
|
|
|
872
917
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
873
918
|
// Métodos internos
|
|
874
919
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
920
|
+
/**
|
|
921
|
+
* Helper para emitir comprobantes tipo A/B que requieren IVA
|
|
922
|
+
*/
|
|
923
|
+
async issueInvoiceWithVAT(type, params) {
|
|
924
|
+
this.validateItemsWithVAT(params.items);
|
|
925
|
+
this.validateAssociatedInvoices(type, params.associatedInvoices);
|
|
926
|
+
const includesVAT = params.includesVAT || false;
|
|
927
|
+
const vatData = this.calculateVATByRate(params.items, includesVAT);
|
|
928
|
+
return this.issueDocument({
|
|
929
|
+
type,
|
|
930
|
+
concept: params.concept || 1 /* PRODUCTS */,
|
|
931
|
+
items: params.items,
|
|
932
|
+
buyer: params.buyer,
|
|
933
|
+
associatedInvoices: params.associatedInvoices,
|
|
934
|
+
date: params.date,
|
|
935
|
+
vatData,
|
|
936
|
+
includesVAT
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Helper para emitir comprobantes tipo C que no discriminan IVA
|
|
941
|
+
*/
|
|
942
|
+
async issueInvoiceWithoutVAT(type, params) {
|
|
943
|
+
this.validateAssociatedInvoices(type, params.associatedInvoices);
|
|
944
|
+
const total = round(calculateTotal(params.items));
|
|
945
|
+
return this.issueDocument({
|
|
946
|
+
type,
|
|
947
|
+
concept: params.concept || 1 /* PRODUCTS */,
|
|
948
|
+
total,
|
|
949
|
+
date: params.date,
|
|
950
|
+
buyer: params.buyer || {
|
|
951
|
+
docType: 99 /* FINAL_CONSUMER */,
|
|
952
|
+
docNumber: "0"
|
|
953
|
+
},
|
|
954
|
+
items: params.items,
|
|
955
|
+
associatedInvoices: params.associatedInvoices
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Validación obligatoria para NC/ND
|
|
960
|
+
*/
|
|
961
|
+
validateAssociatedInvoices(type, associatedInvoices) {
|
|
962
|
+
const needsAssociation = [
|
|
963
|
+
3 /* NOTA_CREDITO_A */,
|
|
964
|
+
2 /* NOTA_DEBITO_A */,
|
|
965
|
+
8 /* NOTA_CREDITO_B */,
|
|
966
|
+
7 /* NOTA_DEBITO_B */,
|
|
967
|
+
13 /* NOTA_CREDITO_C */,
|
|
968
|
+
12 /* NOTA_DEBITO_C */
|
|
969
|
+
].includes(type);
|
|
970
|
+
if (needsAssociation && (!associatedInvoices || associatedInvoices.length === 0)) {
|
|
971
|
+
throw new ArcaValidationError(
|
|
972
|
+
"Las Notas de Cr\xE9dito y D\xE9bito requieren al menos un comprobante asociado.",
|
|
973
|
+
{ hint: "Debes enviar el arreglo `associatedInvoices` con la factura original a la cual haces referencia" }
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
875
977
|
/**
|
|
876
978
|
* Método genérico interno para emitir cualquier tipo de comprobante.
|
|
877
979
|
*/
|
|
@@ -896,6 +998,7 @@ var WsfeService = class _WsfeService {
|
|
|
896
998
|
concept: request.concept,
|
|
897
999
|
date: request.date || /* @__PURE__ */ new Date(),
|
|
898
1000
|
buyer: request.buyer,
|
|
1001
|
+
associatedInvoices: request.associatedInvoices,
|
|
899
1002
|
net,
|
|
900
1003
|
vat,
|
|
901
1004
|
total,
|
|
@@ -1041,6 +1144,21 @@ var WsfeService = class _WsfeService {
|
|
|
1041
1144
|
});
|
|
1042
1145
|
vatXml += "\n </ar:Iva>";
|
|
1043
1146
|
}
|
|
1147
|
+
let asocXml = "";
|
|
1148
|
+
if (params.associatedInvoices && params.associatedInvoices.length > 0) {
|
|
1149
|
+
asocXml = "<ar:CbtesAsoc>";
|
|
1150
|
+
params.associatedInvoices.forEach((asoc) => {
|
|
1151
|
+
asocXml += `
|
|
1152
|
+
<ar:CbteAsoc>
|
|
1153
|
+
<ar:Tipo>${asoc.type}</ar:Tipo>
|
|
1154
|
+
<ar:PtoVta>${asoc.pointOfSale}</ar:PtoVta>
|
|
1155
|
+
<ar:Nro>${asoc.invoiceNumber}</ar:Nro>
|
|
1156
|
+
${asoc.cuit ? `<ar:Cuit>${asoc.cuit}</ar:Cuit>` : ""}
|
|
1157
|
+
${asoc.date ? `<ar:CbteFch>${asoc.date.toISOString().split("T")[0].replace(/-/g, "")}</ar:CbteFch>` : ""}
|
|
1158
|
+
</ar:CbteAsoc>`;
|
|
1159
|
+
});
|
|
1160
|
+
asocXml += "\n </ar:CbtesAsoc>";
|
|
1161
|
+
}
|
|
1044
1162
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
1045
1163
|
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
|
|
1046
1164
|
xmlns:ar="http://ar.gov.afip.dif.FEV1/">
|
|
@@ -1074,6 +1192,7 @@ var WsfeService = class _WsfeService {
|
|
|
1074
1192
|
<ar:ImpTrib>0.00</ar:ImpTrib>
|
|
1075
1193
|
<ar:MonId>PES</ar:MonId>
|
|
1076
1194
|
<ar:MonCotiz>1</ar:MonCotiz>
|
|
1195
|
+
${asocXml}
|
|
1077
1196
|
${vatXml}
|
|
1078
1197
|
</ar:FECAEDetRequest>
|
|
1079
1198
|
</ar:FeDetReq>
|