facturas 0.20.5 → 0.22.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.
Files changed (43) hide show
  1. package/README.md +4 -2
  2. package/dist/{chunk-C2KX652X.mjs → chunk-5CGIRDZY.mjs} +5 -2
  3. package/dist/chunk-5CGIRDZY.mjs.map +1 -0
  4. package/dist/{chunk-VEKUMXHW.mjs → chunk-67ISWKGE.mjs} +5 -4
  5. package/dist/{chunk-B2M64SIK.mjs → chunk-7MNVZSW6.mjs} +13 -4
  6. package/dist/chunk-7MNVZSW6.mjs.map +1 -0
  7. package/dist/{chunk-UOIZQMA6.mjs → chunk-FSJHE4VS.mjs} +3 -3
  8. package/dist/{chunk-EXJMG54W.mjs → chunk-GQGYO2Z2.mjs} +4 -4
  9. package/dist/{chunk-YPQJRSTA.mjs → chunk-HLSFMWRT.mjs} +2 -2
  10. package/dist/{chunk-NT2A6YMO.mjs → chunk-Q7IURW54.mjs} +12 -1
  11. package/dist/chunk-Q7IURW54.mjs.map +1 -0
  12. package/dist/{chunk-KBEV7QTU.mjs → chunk-R4MOVPYT.mjs} +2848 -297
  13. package/dist/chunk-R4MOVPYT.mjs.map +1 -0
  14. package/dist/cli.d.ts +4 -4
  15. package/dist/cli.mjs +11 -11
  16. package/dist/cli.mjs.map +1 -1
  17. package/dist/{client-BgWH_jKT.d.ts → client-ghHzZdu8.d.ts} +613 -73
  18. package/dist/constants.d.ts +3 -0
  19. package/dist/constants.mjs +1 -1
  20. package/dist/errors.d.ts +2 -2
  21. package/dist/errors.mjs +3 -1
  22. package/dist/{fiscal-evidence-Bg4o9nxt.d.ts → fiscal-evidence-DjG8zB3o.d.ts} +21 -5
  23. package/dist/{index-DAC3edtw.d.ts → index-BSTxy3nN.d.ts} +1 -1
  24. package/dist/index.d.ts +5 -5
  25. package/dist/index.mjs +35 -16
  26. package/dist/index.mjs.map +1 -1
  27. package/dist/padron.d.ts +2 -2
  28. package/dist/padron.mjs +3 -3
  29. package/dist/{types-Su7QwloQ.d.ts → types-CbvsjIhf.d.ts} +14 -5
  30. package/dist/types.d.ts +1 -1
  31. package/dist/wsfe.d.ts +3 -3
  32. package/dist/wsfe.mjs +4 -4
  33. package/dist/wsmtxca.d.ts +3 -3
  34. package/dist/wsmtxca.mjs +4 -4
  35. package/package.json +1 -1
  36. package/dist/chunk-B2M64SIK.mjs.map +0 -1
  37. package/dist/chunk-C2KX652X.mjs.map +0 -1
  38. package/dist/chunk-KBEV7QTU.mjs.map +0 -1
  39. package/dist/chunk-NT2A6YMO.mjs.map +0 -1
  40. /package/dist/{chunk-VEKUMXHW.mjs.map → chunk-67ISWKGE.mjs.map} +0 -0
  41. /package/dist/{chunk-UOIZQMA6.mjs.map → chunk-FSJHE4VS.mjs.map} +0 -0
  42. /package/dist/{chunk-EXJMG54W.mjs.map → chunk-GQGYO2Z2.mjs.map} +0 -0
  43. /package/dist/{chunk-YPQJRSTA.mjs.map → chunk-HLSFMWRT.mjs.map} +0 -0
@@ -1,8 +1,9 @@
1
- import { h as ArcaEnvironment, A as ArcaClientOptions } from './types-Su7QwloQ.js';
1
+ import { a as ArcaClientConfig, h as ArcaEnvironment, A as ArcaClientOptions } from './types-CbvsjIhf.js';
2
2
  import { PadronService } from './padron.js';
3
- import { e as ArcaAuthorizationOutcome, I as IssuanceService, h as ArcaFiscalIssue, o as ArcaSafeErrorMetadata, V as VoucherDateWindow } from './fiscal-evidence-Bg4o9nxt.js';
3
+ import { e as ArcaAuthorizationOutcome, I as IssuanceService, h as ArcaFiscalIssue, q as ArcaSafeErrorMetadata, u as ArcaVoucherLookupResult, V as VoucherDateWindow } from './fiscal-evidence-DjG8zB3o.js';
4
4
  import { WsfeVoucherInput, WsfeVoucherInfo, WsfeDateInput, WsfeService } from './wsfe.js';
5
5
  import { VoucherClass, ReceiverCondition, IssuerCondition, IssuerConditionId } from './constants.js';
6
+ import { W as WsaaAuthModule, S as SoapTransport } from './index-BSTxy3nN.js';
6
7
  import { WsmtxcaService } from './wsmtxca.js';
7
8
 
8
9
  type VoucherCoordinates = {
@@ -179,6 +180,73 @@ declare function wsmtxcaRequest(data: FiscalHeader$1, number?: number): {
179
180
  };
180
181
  };
181
182
 
183
+ /** Monetary values in the high-level API are integer minor units. */
184
+ type Tribute = {
185
+ id: number;
186
+ description?: string;
187
+ base: number;
188
+ rate: number;
189
+ amount: number;
190
+ };
191
+ /** An already-reviewed fiscal breakdown; no recalculation of historical VAT. */
192
+ type VoucherAmounts = {
193
+ net: number;
194
+ vat: number;
195
+ exempt?: number;
196
+ untaxed?: number;
197
+ vatRates?: readonly {
198
+ id: number;
199
+ base: number;
200
+ amount: number;
201
+ }[];
202
+ };
203
+ type InvoiceFamily = "ordinary" | "retention_legend" | "fce";
204
+ type IssuanceFields = {
205
+ fce?: FceOptions;
206
+ taxes?: readonly Tribute[];
207
+ amounts?: VoucherAmounts;
208
+ concept?: "products" | "services" | "products_and_services";
209
+ dueDate?: WsfeDateInput;
210
+ paidInForeignCurrency?: boolean;
211
+ optionalFields?: WsfeVoucherInput["optionalFields"];
212
+ buyers?: WsfeVoucherInput["buyers"];
213
+ activities?: WsfeVoucherInput["activities"];
214
+ };
215
+ declare const FAMILIES: {
216
+ readonly ordinary: {
217
+ readonly A: readonly [1, 2, 3];
218
+ readonly B: readonly [6, 7, 8];
219
+ readonly C: readonly [11, 12, 13];
220
+ };
221
+ readonly retention_legend: {
222
+ readonly A: readonly [51, 52, 53];
223
+ };
224
+ readonly fce: {
225
+ readonly A: readonly [201, 202, 203];
226
+ readonly B: readonly [206, 207, 208];
227
+ readonly C: readonly [211, 212, 213];
228
+ };
229
+ };
230
+ /**
231
+ * Export vouchers (19, 20, 21) report `family: "export"` and class `"E"`;
232
+ * neither is an `issue()` input, where an export is chosen by `export`.
233
+ */
234
+ type VoucherTypeInfo = {
235
+ family: InvoiceFamily | "export";
236
+ voucherClass: VoucherClass | "E";
237
+ kind: "invoice" | "debit_note" | "credit_note";
238
+ };
239
+ /** What an ARCA voucher type the SDK issues is. Pure; throws for any other. */
240
+ declare function describeVoucherType(voucherType: number): VoucherTypeInfo;
241
+ /** FCE business fields; the SDK encodes each provider's different option layout. */
242
+ type FceOptions = {
243
+ cbu?: string;
244
+ alias?: string;
245
+ transfer?: "ADC" | "SCA";
246
+ annulment?: boolean;
247
+ reference?: string;
248
+ };
249
+
182
250
  /** Where every printed voucher's QR points, per ARCA's QR specification v1. */
183
251
  declare const ARCA_QR_URL = "https://www.arca.gob.ar/fe/qr/";
184
252
  /** What the QR of a printed voucher encodes. Amounts are minor units. */
@@ -199,7 +267,10 @@ type ArcaQrInput = {
199
267
  /** The CAE, or the CAEA when `authorization` is `"CAEA"`. */
200
268
  cae: string;
201
269
  authorization?: "CAE" | "CAEA";
202
- /** The receiver's document. Omitted, or type 99, means an unidentified consumidor final. */
270
+ /**
271
+ * The receiver's document as sent to ARCA, type 99 and number 0 included
272
+ * for an unidentified consumidor final. Omitted, the QR names no receiver.
273
+ */
203
274
  document?: {
204
275
  type: number;
205
276
  number: number | string;
@@ -357,7 +428,7 @@ type WithRequest<O extends IssueOptions> = O extends {
357
428
  } : true extends NonNullable<O["include"]>["request"] ? {
358
429
  request?: IssueRequest<ServiceFor<O>>;
359
430
  } : unknown;
360
- type Evidence<K extends ArcaAuthorizationOutcome["kind"], O extends IssueOptions> = WithRawResponse<Omit<Extract<ArcaAuthorizationOutcome<ServiceFor<O>>, {
431
+ type Evidence$1<K extends ArcaAuthorizationOutcome["kind"], O extends IssueOptions> = WithRawResponse<Omit<Extract<ArcaAuthorizationOutcome<ServiceFor<O>>, {
361
432
  kind: K;
362
433
  }>, "raw">, O>;
363
434
  /** Fiscal outcomes are returned. Keyed replays authorize only after not_found. */
@@ -367,22 +438,22 @@ type IssueOutcome<O extends IssueOptions = {
367
438
  kind: "authorized";
368
439
  recoveredByMatch: false;
369
440
  voucher: IssuedVoucher;
370
- authorization: Evidence<"authorized", O>;
441
+ authorization: Evidence$1<"authorized", O>;
371
442
  } | {
372
443
  kind: "authorized";
373
444
  recoveredByMatch: true;
374
445
  voucher: IssuedVoucher;
375
- attempt: Evidence<"indeterminate", O>;
446
+ attempt: Evidence$1<"indeterminate", O>;
376
447
  lookup: WithRawResponse<VoucherSummary, O>;
377
448
  } | {
378
449
  kind: "rejected";
379
450
  attempted: VoucherCoordinates;
380
451
  issues: ArcaFiscalIssue[];
381
- authorization: Evidence<"rejected", O>;
452
+ authorization: Evidence$1<"rejected", O>;
382
453
  } | {
383
454
  kind: "indeterminate";
384
455
  attempted: VoucherCoordinates;
385
- attempt: Evidence<"indeterminate", O>;
456
+ attempt: Evidence$1<"indeterminate", O>;
386
457
  lookup: WithRawResponse<{
387
458
  kind: "not_found";
388
459
  }, O> | WithRawResponse<{
@@ -417,58 +488,442 @@ type IssueOutcome<O extends IssueOptions = {
417
488
  } | {
418
489
  kind: "conflict";
419
490
  attempted: VoucherCoordinates;
420
- attempt: Evidence<"indeterminate", O>;
491
+ attempt: Evidence$1<"indeterminate", O>;
421
492
  found: WithRawResponse<VoucherSummary, O>;
422
493
  reason: string;
423
494
  }) & WithRequest<O>;
424
495
 
425
- /** Monetary values in the high-level API are integer minor units. */
426
- type Tribute = {
496
+ /** Factura E (19), Nota de Débito E (20) and Nota de Crédito E (21). */
497
+ type WsfexVoucherType = 19 | 20 | 21;
498
+ /** `Tipo_expo`: goods (1), services (2) or other (4). */
499
+ type WsfexExportType = 1 | 2 | 4;
500
+ /** `Idioma_cbte`: Spanish (1), English (2) or Portuguese (3). */
501
+ type WsfexLanguage = 1 | 2 | 3;
502
+ /**
503
+ * One `Item`. Money is in major units like `WsfeVoucherInput`: `amount` has
504
+ * at most two decimals, `discount` at most six. `unitPrice` is a decimal
505
+ * string with up to six decimals, the SDK's one monetary exception.
506
+ */
507
+ type WsfexItem = {
508
+ code?: string;
509
+ description: string;
510
+ /** A number, or an exact decimal string; a lookup answers the string. */
511
+ quantity?: number | string;
512
+ unit: number;
513
+ unitPrice?: string;
514
+ /** A number, or an exact decimal string; a lookup answers the string. */
515
+ discount?: number | string;
516
+ amount: number;
517
+ };
518
+ type WsfexPermit = {
519
+ id: string;
520
+ destination: number;
521
+ };
522
+ type WsfexAssociatedVoucher = {
523
+ voucherType: number;
524
+ salesPoint: number;
525
+ number: number;
526
+ issuerTaxId?: string;
527
+ };
528
+ /**
529
+ * The fiscal content of one `FEXAuthorize` `Cmp`, without its request `Id`
530
+ * and number. Dates are `YYYYMMDD`. Field order here is not the wire order:
531
+ * the service serializes in WSDL order.
532
+ */
533
+ type WsfexVoucherInput = {
534
+ voucherType: WsfexVoucherType;
535
+ salesPoint: number;
536
+ voucherDate?: string;
537
+ exportType: WsfexExportType;
538
+ /** `Permiso_existente`: absent sends it empty, as notes and services require. */
539
+ permitExists?: "S" | "N";
540
+ permits?: readonly WsfexPermit[];
541
+ /** `Dst_cmp`, an ARCA country code from `getCountries()`. */
542
+ destination: number;
543
+ receiverName: string;
544
+ /** `Cuit_pais_cliente`, one of `getCountryTaxIds()`. */
545
+ receiverCountryTaxId?: string;
546
+ receiverAddress: string;
547
+ /** `Id_impositivo`, the receiver's tax ID abroad. */
548
+ receiverTaxId?: string;
549
+ currencyId: string;
550
+ /** `Moneda_ctz` as an exact decimal string; ARCA may fill it when `sameCurrencyForeignCancellation` is `S`. */
551
+ exchangeRate?: string;
552
+ /** `CanMisMonExt`. Invoices in a foreign currency only. */
553
+ sameCurrencyForeignCancellation?: "S" | "N";
554
+ commercialObservations?: string;
555
+ totalAmount: number;
556
+ observations?: string;
557
+ associatedVouchers?: readonly WsfexAssociatedVoucher[];
558
+ /** `Forma_pago`, required on invoices (rule 1620). */
559
+ paymentTerms?: string;
560
+ incoterms?: string;
561
+ incotermsDetail?: string;
562
+ language: WsfexLanguage;
563
+ items: readonly WsfexItem[];
564
+ /** `Fecha_pago`, required on service and other invoices (rule 1672). */
565
+ paymentDate?: string;
566
+ activities?: readonly {
567
+ id: string;
568
+ }[];
569
+ };
570
+ type WsfexIssueInput = WsfexVoucherInput & {
571
+ /** `Cmp.Id`. Resending the same id returns ARCA's stored answer. */
427
572
  id: number;
428
- description?: string;
429
- base: number;
430
- rate: number;
573
+ number: number;
574
+ representedTaxId?: number | string;
575
+ forceRefresh?: boolean;
576
+ abortSignal?: AbortSignal;
577
+ };
578
+ /**
579
+ * Structured evidence of one `FEXAuthorize`. `echo` is what ARCA says it
580
+ * authorized: callers must compare it with what they sent, since a reused
581
+ * `Id` returns another request's stored answer with `reprocessed: true`.
582
+ */
583
+ type WsfexAuthorizationOutcome = ArcaAuthorizationOutcome<"wsfex"> & {
584
+ reprocessed?: boolean;
585
+ echo?: {
586
+ id?: number;
587
+ salesPoint?: number;
588
+ voucherType?: number;
589
+ number?: number;
590
+ date?: string;
591
+ };
592
+ };
593
+ /** One authorized voucher as `FEXGetCMP` reports it, in ARCA's units. */
594
+ type WsfexVoucherInfo = Omit<WsfexVoucherInput, "voucherType" | "language" | "exportType"> & {
595
+ id?: number;
596
+ voucherType: number;
597
+ number: number;
598
+ exportType?: number;
599
+ language?: number;
600
+ result?: string;
601
+ cae?: string;
602
+ /** `Fch_venc_Cae`, `YYYYMMDD`. */
603
+ caeExpiry?: string;
604
+ /** `Fecha_cbte_cae`, `YYYYMMDD`. */
605
+ authorizedAt?: string;
606
+ observations?: string;
607
+ };
608
+ type WsfexVoucherLookupResult = ArcaVoucherLookupResult<WsfexVoucherInfo, "wsfex">;
609
+ type WsfexCatalogEntry = {
610
+ id: string;
611
+ description: string;
612
+ };
613
+ type WsfexCountryTaxId = {
614
+ taxId: string;
615
+ description: string;
616
+ };
617
+ type WsfexSalesPoint = {
618
+ number: number;
619
+ blocked: boolean;
620
+ /** `YYYY-MM-DD`, absent when active. */
621
+ deactivatedAt?: string;
622
+ };
623
+ type WsfexExchangeRate = {
624
+ currencyId: string;
625
+ /** Exact decimal string. */
626
+ rate: string;
627
+ /** `YYYY-MM-DD`. */
628
+ date: string;
629
+ };
630
+ type Auth = {
631
+ representedTaxId?: number | string;
632
+ forceRefresh?: boolean;
633
+ };
634
+ type WsfexService = {
635
+ /**
636
+ * One `FEXAuthorize` with the caller's `Id` and number. Never throws a
637
+ * provider answer: `authorized`, `rejected` or `indeterminate`. Transport
638
+ * retries are safe because ARCA answers a repeated `Id` from its records.
639
+ */
640
+ issue(input: WsfexIssueInput): Promise<WsfexAuthorizationOutcome>;
641
+ /** `FEXGetLast_ID`: the highest request `Id` ARCA received for the CUIT. */
642
+ getLastRequestId(input?: Auth & {
643
+ abortSignal?: AbortSignal;
644
+ }): Promise<number>;
645
+ /** `FEXGetLast_CMP`: the last authorized number; `0` when none. */
646
+ getLastVoucherNumber(input: Auth & {
647
+ salesPoint: number;
648
+ voucherType: number;
649
+ abortSignal?: AbortSignal;
650
+ }): Promise<number>;
651
+ /** `FEXGetCMP`; error 1020 becomes `not_found`. */
652
+ lookupVoucher(input: Auth & {
653
+ salesPoint: number;
654
+ voucherType: number;
655
+ number: number;
656
+ abortSignal?: AbortSignal;
657
+ }): Promise<WsfexVoucherLookupResult>;
658
+ getSalesPoints(input?: Auth): Promise<WsfexSalesPoint[]>;
659
+ getCountries(input?: Auth): Promise<WsfexCatalogEntry[]>;
660
+ getCountryTaxIds(input?: Auth): Promise<WsfexCountryTaxId[]>;
661
+ getCurrencies(input?: Auth): Promise<WsfexCatalogEntry[]>;
662
+ getIncoterms(input?: Auth): Promise<WsfexCatalogEntry[]>;
663
+ getUnits(input?: Auth): Promise<WsfexCatalogEntry[]>;
664
+ getLanguages(input?: Auth): Promise<WsfexCatalogEntry[]>;
665
+ getVoucherTypes(input?: Auth): Promise<WsfexCatalogEntry[]>;
666
+ getExportTypes(input?: Auth): Promise<WsfexCatalogEntry[]>;
667
+ getActivities(input?: Auth): Promise<WsfexCatalogEntry[]>;
668
+ /**
669
+ * `FEXGetPARAM_Ctz`. ARCA's rate for `date` (`YYYY-MM-DD`), or its latest
670
+ * when omitted. Homologation answers a test rate, not the real one.
671
+ */
672
+ getExchangeRate(input: Auth & {
673
+ currencyId: string;
674
+ date?: string;
675
+ }): Promise<WsfexExchangeRate>;
676
+ /** `FEXCheck_Permiso`: whether a shipping permit exists for a destination. */
677
+ checkPermit(input: Auth & {
678
+ id: string;
679
+ destination: number;
680
+ }): Promise<boolean>;
681
+ };
682
+ type CreateWsfexServiceOptions = {
683
+ config: ArcaClientConfig;
684
+ auth: WsaaAuthModule;
685
+ soap: SoapTransport;
686
+ };
687
+ /** Creates a WSFEX service instance wired with authentication and SOAP transport. */
688
+ declare function createWsfexService(options: CreateWsfexServiceOptions): WsfexService;
689
+
690
+ /** Factura E (19), Nota de Débito E (20) and Nota de Crédito E (21). */
691
+ type ExportVoucherType = 19 | 20 | 21;
692
+ /** A receiver abroad. ARCA needs `taxId`, `countryTaxId` or both (rule 1580). */
693
+ type ExportReceiver = {
694
+ /** ARCA destination country, from `wsfex.getCountries()`: 203 is Brasil. */
695
+ country: number;
696
+ name: string;
697
+ address: string;
698
+ /** The receiver's tax ID in its own country. */
699
+ taxId?: string;
700
+ /** ARCA's CUIT for the receiver's country, from `wsfex.getCountryTaxIds()`. */
701
+ countryTaxId?: string;
702
+ };
703
+ /**
704
+ * One exported line. `unit` is an ARCA unit of measure from
705
+ * `wsfex.getUnits()`. Except for units 0, 97 and 99, `quantity` and
706
+ * `unitPrice` are required and `amount` must equal their product less
707
+ * `discount`. `amount` and `discount` are minor units; `amount` is negative
708
+ * only for unit 99, a discount line, or 97, an advance.
709
+ */
710
+ type ExportItem = Pick<ItemLine, "quantity" | "unitPrice" | "discount" | "code"> & {
711
+ description: string;
712
+ unit: number;
431
713
  amount: number;
432
714
  };
433
- /** An already-reviewed fiscal breakdown; no recalculation of historical VAT. */
434
- type VoucherAmounts = {
435
- net: number;
436
- vat: number;
437
- exempt?: number;
438
- untaxed?: number;
439
- vatRates?: readonly {
440
- id: number;
441
- base: number;
442
- amount: number;
715
+ type ExportOfGoods = {
716
+ kind: "goods";
717
+ /** An Incoterm from `wsfex.getIncoterms()`, such as `FOB`. */
718
+ incoterms: string;
719
+ incotermsDetail?: string;
720
+ /**
721
+ * The shipping permits already issued, each with its destination. Omit it
722
+ * while the goods have none yet: ARCA records that the permit is pending.
723
+ */
724
+ permits?: readonly {
725
+ id: string;
726
+ destination: number;
443
727
  }[];
444
728
  };
445
- type InvoiceFamily = "ordinary" | "retention_legend" | "fce";
446
- type IssuanceFields = {
447
- fce?: FceOptions;
448
- taxes?: readonly Tribute[];
449
- amounts?: VoucherAmounts;
450
- concept?: "products" | "services" | "products_and_services";
451
- dueDate?: WsfeDateInput;
729
+ type ExportOfServices = {
730
+ /** Services, or `other` for exports that are neither goods nor services. */
731
+ kind: "services" | "other";
732
+ /** When the receiver pays, on or after the voucher date. */
733
+ paymentDate: WsfeDateInput;
734
+ };
735
+ /**
736
+ * A Factura E. ARCA authorizes it through WSFEX, never WSFE: `issue()` takes
737
+ * this shape whenever `export` is present. The issuer's tax condition does
738
+ * not change the class, so there is no `issuer`.
739
+ */
740
+ type ExportIssueInput = {
741
+ salesPoint: number;
742
+ to: ExportReceiver;
743
+ export: ExportOfGoods | ExportOfServices;
744
+ items: readonly ExportItem[];
745
+ /** The reviewed total in minor units; must equal the sum of `items`. */
746
+ total?: number;
747
+ date?: WsfeDateInput;
748
+ /** `ARS`, `USD`, or any ARCA currency id such as `{ id: "060" }` for euros. */
749
+ currency?: "ARS" | "USD" | {
750
+ id: string;
751
+ };
752
+ /**
753
+ * Pesos per unit, required for every currency but ARS. ARCA checks it
754
+ * against its own rate: take it from `wsfex.getExchangeRate()`.
755
+ */
756
+ exchangeRate?: string;
757
+ /** The receiver pays in the invoice's foreign currency (`CanMisMonExt`). */
452
758
  paidInForeignCurrency?: boolean;
453
- optionalFields?: WsfeVoucherInput["optionalFields"];
454
- buyers?: WsfeVoucherInput["buyers"];
455
- activities?: WsfeVoucherInput["activities"];
759
+ /** How the receiver pays, such as "Transferencia bancaria" (`Forma_pago`). */
760
+ paymentTerms: string;
761
+ /** The language of the printed voucher; Spanish when omitted. */
762
+ language?: "es" | "en" | "pt";
763
+ observations?: string;
764
+ commercialObservations?: string;
456
765
  };
457
- type VoucherTypeInfo = {
458
- family: InvoiceFamily;
459
- voucherClass: VoucherClass;
460
- kind: "invoice" | "debit_note" | "credit_note";
766
+ type ExportNoteCommon = {
767
+ /** The authorized export voucher the note adjusts. */
768
+ for: VoucherCoordinates & {
769
+ voucherType: ExportVoucherType;
770
+ };
771
+ salesPoint?: number;
772
+ date?: WsfeDateInput;
773
+ /**
774
+ * Overrides the original's rate. Services notes must keep the original's
775
+ * rate (rule 2053), so it is refused for them.
776
+ */
777
+ exchangeRate?: string;
778
+ observations?: string;
779
+ commercialObservations?: string;
461
780
  };
462
- /** What an ARCA voucher type the SDK issues is. Pure; throws for any other. */
463
- declare function describeVoucherType(voucherType: number): VoucherTypeInfo;
464
- /** FCE business fields; the SDK encodes each provider's different option layout. */
465
- type FceOptions = {
466
- cbu?: string;
467
- alias?: string;
468
- transfer?: "ADC" | "SCA";
469
- annulment?: boolean;
470
- reference?: string;
781
+ /** A Nota de Crédito E for chosen lines, or for every line with `all`. */
782
+ type ExportCreditNoteInput = ExportNoteCommon & ({
783
+ items: readonly ExportItem[];
784
+ all?: never;
785
+ } | {
786
+ all: true;
787
+ items?: never;
788
+ });
789
+ /** A Nota de Débito E always lists what it adds. */
790
+ type ExportDebitNoteInput = ExportNoteCommon & {
791
+ items: readonly ExportItem[];
792
+ all?: never;
471
793
  };
794
+ /** The normalized fiscal fields of an export voucher. Dates are `YYYY-MM-DD`. */
795
+ type ExportHeader = {
796
+ exportType: WsfexExportType;
797
+ destination: number;
798
+ receiverName: string;
799
+ receiverAddress: string;
800
+ receiverTaxId?: string;
801
+ receiverCountryTaxId?: string;
802
+ currencyId: string;
803
+ exchangeRate?: string;
804
+ paidInForeignCurrency?: boolean;
805
+ language: WsfexLanguage;
806
+ incoterms?: string;
807
+ incotermsDetail?: string;
808
+ /** Whether the voucher declared an issued shipping permit; absent on notes and services. */
809
+ permitExists?: boolean;
810
+ paymentTerms?: string;
811
+ paymentDate?: string;
812
+ };
813
+ type ExportIssuedVoucher = VoucherCoordinates & {
814
+ voucherClass: "E";
815
+ /** The request id (`Cmp.Id`) ARCA stored this voucher under. */
816
+ requestId: number;
817
+ date: string;
818
+ header: ExportHeader;
819
+ cae: string;
820
+ caeExpiry: string;
821
+ amounts: IssueAmounts;
822
+ qr?: string;
823
+ qrPayload?: ArcaQrPayload;
824
+ };
825
+ /** Raw-free consultation of one export voucher, money in minor units. */
826
+ type ExportVoucherSummary = {
827
+ /** Tells an export summary apart from a WSFE or WSMTXCA one. */
828
+ voucherClass: "E";
829
+ number: number;
830
+ salesPoint?: number;
831
+ voucherType?: number;
832
+ requestId?: number;
833
+ date?: string;
834
+ exportType?: number;
835
+ destination?: number;
836
+ receiverName?: string;
837
+ receiverAddress?: string;
838
+ receiverTaxId?: string;
839
+ receiverCountryTaxId?: string;
840
+ currencyId?: string;
841
+ exchangeRate?: string;
842
+ totalAmount?: number;
843
+ result?: string;
844
+ cae?: string;
845
+ caeExpiry?: string;
846
+ };
847
+ type ExportPreview = {
848
+ voucherClass: "E";
849
+ voucherType: ExportVoucherType;
850
+ date: string;
851
+ header: ExportHeader;
852
+ amounts: IssueAmounts;
853
+ request: WsfexVoucherInput;
854
+ service: "wsfex";
855
+ /** The original a note adjusts. */
856
+ originals?: readonly ExportVoucherSummary[];
857
+ };
858
+ /** The outcome without `raw`, kept per kind so `reason` and `cae` survive. */
859
+ type Evidence = (WsfexAuthorizationOutcome extends infer T ? T extends unknown ? Omit<T, "raw"> : never : never) & {
860
+ rawResponse?: Record<string, unknown>;
861
+ };
862
+ /** What `issue()` sent: the voucher with the request id and number it took. */
863
+ type ExportIssueRequest = WsfexVoucherInput & {
864
+ id: number;
865
+ number: number;
866
+ };
867
+ /** `request` is always present when `include.request` is `true`. */
868
+ /** What happened to one export attempt, before the service tag. */
869
+ type ExportResult = {
870
+ kind: "authorized";
871
+ recoveredByMatch: false;
872
+ voucher: ExportIssuedVoucher;
873
+ authorization: Evidence;
874
+ } | {
875
+ kind: "authorized";
876
+ recoveredByMatch: true;
877
+ voucher: ExportIssuedVoucher;
878
+ attempt: Evidence;
879
+ lookup: ExportVoucherSummary;
880
+ } | {
881
+ kind: "rejected";
882
+ attempted: VoucherCoordinates;
883
+ issues: ArcaFiscalIssue[];
884
+ authorization: Evidence;
885
+ } | {
886
+ kind: "indeterminate";
887
+ attempted: VoucherCoordinates;
888
+ attempt: Evidence;
889
+ lookup: {
890
+ kind: "not_found";
891
+ }
892
+ /** ARCA has this voucher but reports no approval, CAE or expiry. */
893
+ | {
894
+ kind: "incomplete";
895
+ reason: string;
896
+ } | {
897
+ kind: "failed";
898
+ error: ArcaSafeErrorMetadata;
899
+ } | {
900
+ kind: "aborted";
901
+ };
902
+ } | {
903
+ kind: "conflict";
904
+ attempted: VoucherCoordinates;
905
+ attempt: Evidence;
906
+ found: ExportVoucherSummary;
907
+ reason: string;
908
+ };
909
+ /**
910
+ * `service: "wsfex"` tells an export outcome apart at the top level: where a
911
+ * result may be domestic or export, `"service" in outcome` narrows it. With
912
+ * `include.request: true`, `request` is always present.
913
+ */
914
+ type ExportIssueOutcome<O extends IssueOptions = {
915
+ include?: never;
916
+ }> = ExportResult & {
917
+ service: "wsfex";
918
+ } & (O extends {
919
+ include: {
920
+ request: true;
921
+ };
922
+ } ? {
923
+ request: ExportIssueRequest;
924
+ } : {
925
+ request?: ExportIssueRequest;
926
+ });
472
927
 
473
928
  type Receiver = {
474
929
  condition: number;
@@ -518,9 +973,15 @@ type IssueInput = IssueCommon & ({
518
973
  });
519
974
  type VoucherDateWindowInput = {
520
975
  voucherType: number;
521
- /** What the voucher bills; `"products"` when omitted, as in `issue()`. */
976
+ /**
977
+ * What the voucher bills; `"products"` when omitted, as in `issue()`. For
978
+ * an export voucher (19, 20, 21), `"services"` is an export of services.
979
+ */
522
980
  concept?: NonNullable<IssuanceFields["concept"]>;
523
- /** The service that will authorize it; `"wsfe"` when omitted. */
981
+ /**
982
+ * The service that will authorize it; `"wsfe"` when omitted. Omit it for
983
+ * an export voucher, which WSFEX always authorizes.
984
+ */
524
985
  service?: "wsfe" | "wsmtxca";
525
986
  /** When it will be sent; its day in Argentina anchors the window. */
526
987
  now?: Date;
@@ -589,6 +1050,21 @@ type NotePreview<S extends IssuanceService = "wsfe"> = IssuePreview<S> & {
589
1050
  /** The originals consulted, in input order; absent for a period note. */
590
1051
  originals?: readonly VoucherSummary[];
591
1052
  };
1053
+ /** Every voucher type the WSFE and WSMTXCA facade issues, as literals. */
1054
+ type DomesticVoucherType = {
1055
+ [F in keyof typeof FAMILIES]: (typeof FAMILIES)[F][keyof (typeof FAMILIES)[F]];
1056
+ }[keyof typeof FAMILIES][number];
1057
+ type DomesticCoordinates = VoucherCoordinates & {
1058
+ voucherType: DomesticVoucherType;
1059
+ };
1060
+ /**
1061
+ * A note whose original is a literal domestic type, or a list of originals,
1062
+ * which are always domestic. Only a `voucherType` typed as plain `number` may
1063
+ * hold 19 to 21 at run time, so only that input gets the result union.
1064
+ */
1065
+ type DomesticNote<T> = T & {
1066
+ for?: DomesticCoordinates | readonly VoucherCoordinates[];
1067
+ };
592
1068
  type RecoveryOptions = Pick<IssueOptions, "representedTaxId" | "forceRefresh" | "include" | "abortSignal">;
593
1069
  type VouchersService = {
594
1070
  /**
@@ -596,7 +1072,17 @@ type VouchersService = {
596
1072
  * credit note's `for` takes. Returns `null` when ARCA has no such voucher and
597
1073
  * throws on any other provider error. Reads only: no store and no reserve.
598
1074
  */
599
- lookup(voucher: VoucherCoordinates, options?: PreviewOptions): Promise<VoucherSummary | null>;
1075
+ lookup: {
1076
+ (voucher: VoucherCoordinates & {
1077
+ voucherType: ExportVoucherType;
1078
+ }, options?: PreviewOptions): Promise<ExportVoucherSummary | null>;
1079
+ (voucher: DomesticCoordinates, options?: PreviewOptions): Promise<VoucherSummary | null>;
1080
+ /**
1081
+ * A `voucherType` typed as plain `number` may hold 19 to 21 at run time,
1082
+ * so its answer may be an export summary: narrow on `voucherClass`.
1083
+ */
1084
+ (voucher: VoucherCoordinates, options?: PreviewOptions): Promise<VoucherSummary | ExportVoucherSummary | null>;
1085
+ };
600
1086
  /**
601
1087
  * The number of the last voucher ARCA authorized for a sales point and
602
1088
  * voucher type, on WSFE or WSMTXCA; `0` when none was ever authorized.
@@ -606,29 +1092,61 @@ type VouchersService = {
606
1092
  recover<O extends RecoveryOptions = {
607
1093
  include?: never;
608
1094
  }>(idempotencyKey: string, options?: O): Promise<IssueOutcome<O & {
609
- service?: IssuanceService;
610
- }>>;
1095
+ service?: "wsfe" | "wsmtxca";
1096
+ }> | ExportIssueOutcome<O>>;
611
1097
  /**
612
1098
  * Issues a debit note against the same originals `issueCreditNote()` accepts,
613
1099
  * or against a period with `associatedPeriod`. It has no `all: true` mode:
614
1100
  * a debit note adds to the account, so its lines are always explicit.
615
1101
  */
616
- issueDebitNote<O extends IssueOptions = {
617
- include?: never;
618
- }>(input: DebitNoteInput, options?: O): Promise<IssueOutcome<O>>;
1102
+ issueDebitNote: {
1103
+ <O extends IssueOptions = {
1104
+ include?: never;
1105
+ }>(input: ExportDebitNoteInput, options?: O): Promise<ExportIssueOutcome<O>>;
1106
+ <O extends IssueOptions = {
1107
+ include?: never;
1108
+ }>(input: DomesticNote<DebitNoteInput>, options?: O): Promise<IssueOutcome<O>>;
1109
+ /**
1110
+ * A `for.voucherType` typed as plain `number` may hold 19 to 21 at run
1111
+ * time, so the result may be an export one: narrow with `"service" in outcome`.
1112
+ */
1113
+ <O extends IssueOptions = {
1114
+ include?: never;
1115
+ }>(input: DebitNoteInput, options?: O): Promise<IssueOutcome<O> | ExportIssueOutcome<O>>;
1116
+ };
619
1117
  /**
620
1118
  * Derives what issueCreditNote() would send. Unlike the zero-I/O preview(),
621
1119
  * it consults each original once: reads only, no write and no number
622
1120
  * reserved. A linked note returns those raw-free originals in `originals`. A
623
1121
  * period note carries its own business input and needs no lookup at all.
624
1122
  */
625
- previewCreditNote<O extends PreviewOptions = {
626
- service?: never;
627
- }>(input: CreditNoteInput | PeriodNoteInput, options?: O): Promise<NotePreview<ServiceFor<O>>>;
1123
+ previewCreditNote: {
1124
+ (input: ExportCreditNoteInput, options?: PreviewOptions): Promise<ExportPreview>;
1125
+ <O extends PreviewOptions = {
1126
+ service?: never;
1127
+ }>(input: DomesticNote<CreditNoteInput | PeriodNoteInput>, options?: O): Promise<NotePreview<ServiceFor<O>>>;
1128
+ /**
1129
+ * A `for.voucherType` typed as plain `number` may hold 19 to 21 at run
1130
+ * time, so the preview may be an export one: narrow on `voucherClass`.
1131
+ */
1132
+ <O extends PreviewOptions = {
1133
+ service?: never;
1134
+ }>(input: CreditNoteInput | PeriodNoteInput, options?: O): Promise<NotePreview<ServiceFor<O>> | ExportPreview>;
1135
+ };
628
1136
  /** Same contract as previewCreditNote(), for issueDebitNote() input. */
629
- previewDebitNote<O extends PreviewOptions = {
630
- service?: never;
631
- }>(input: DebitNoteInput, options?: O): Promise<NotePreview<ServiceFor<O>>>;
1137
+ previewDebitNote: {
1138
+ (input: ExportDebitNoteInput, options?: PreviewOptions): Promise<ExportPreview>;
1139
+ <O extends PreviewOptions = {
1140
+ service?: never;
1141
+ }>(input: DomesticNote<DebitNoteInput>, options?: O): Promise<NotePreview<ServiceFor<O>>>;
1142
+ /**
1143
+ * A `for.voucherType` typed as plain `number` may hold 19 to 21 at run
1144
+ * time, so the preview may be an export one: narrow on `voucherClass`.
1145
+ */
1146
+ <O extends PreviewOptions = {
1147
+ service?: never;
1148
+ }>(input: DebitNoteInput, options?: O): Promise<NotePreview<ServiceFor<O>> | ExportPreview>;
1149
+ };
632
1150
  /**
633
1151
  * Issues a credit note against an authorized invoice or debit note of the
634
1152
  * ordinary, retention-legend or FCE families, or against a period with
@@ -641,9 +1159,21 @@ type VouchersService = {
641
1159
  * and every one is associated to the note. ARCA has no cancellation; every
642
1160
  * mode writes a real fiscal document.
643
1161
  */
644
- issueCreditNote<O extends IssueOptions = {
645
- include?: never;
646
- }>(input: CreditNoteInput | PeriodNoteInput, options?: O): Promise<IssueOutcome<O>>;
1162
+ issueCreditNote: {
1163
+ <O extends IssueOptions = {
1164
+ include?: never;
1165
+ }>(input: ExportCreditNoteInput, options?: O): Promise<ExportIssueOutcome<O>>;
1166
+ <O extends IssueOptions = {
1167
+ include?: never;
1168
+ }>(input: DomesticNote<CreditNoteInput | PeriodNoteInput>, options?: O): Promise<IssueOutcome<O>>;
1169
+ /**
1170
+ * A `for.voucherType` typed as plain `number` may hold 19 to 21 at run
1171
+ * time, so the result may be an export one: narrow with `"service" in outcome`.
1172
+ */
1173
+ <O extends IssueOptions = {
1174
+ include?: never;
1175
+ }>(input: CreditNoteInput | PeriodNoteInput, options?: O): Promise<IssueOutcome<O> | ExportIssueOutcome<O>>;
1176
+ };
647
1177
  /**
648
1178
  * Configure a store and pass idempotencyKey to recover retries after a crash.
649
1179
  *
@@ -651,9 +1181,14 @@ type VouchersService = {
651
1181
  * Keyed replay consults the reserved number; only not_found permits a write.
652
1182
  * Local validation and next-number read failures throw before authorization.
653
1183
  */
654
- issue<O extends IssueOptions = {
655
- include?: never;
656
- }>(input: IssueInput, options?: O): Promise<IssueOutcome<O>>;
1184
+ issue: {
1185
+ <O extends IssueOptions = {
1186
+ include?: never;
1187
+ }>(input: ExportIssueInput, options?: O): Promise<ExportIssueOutcome<O>>;
1188
+ <O extends IssueOptions = {
1189
+ include?: never;
1190
+ }>(input: IssueInput, options?: O): Promise<IssueOutcome<O>>;
1191
+ };
657
1192
  /**
658
1193
  * Derives what issue() would send for the same input, with no I/O at all:
659
1194
  * no store, no WSAA, no SOAP and no next-number read.
@@ -661,9 +1196,12 @@ type VouchersService = {
661
1196
  * It throws every input error issue() throws before its first call, so a
662
1197
  * caller that previews and then issues sees no new local error.
663
1198
  */
664
- preview<O extends Pick<PreviewOptions, "representedTaxId" | "service"> = {
665
- service?: never;
666
- }>(input: IssueInput, options?: O): IssuePreview<ServiceFor<O>>;
1199
+ preview: {
1200
+ (input: ExportIssueInput, options?: Pick<PreviewOptions, "representedTaxId">): ExportPreview;
1201
+ <O extends Pick<PreviewOptions, "representedTaxId" | "service"> = {
1202
+ service?: never;
1203
+ }>(input: IssueInput, options?: O): IssuePreview<ServiceFor<O>>;
1204
+ };
667
1205
  };
668
1206
  type PreviewOptions = {
669
1207
  representedTaxId?: number | string;
@@ -702,6 +1240,8 @@ type ArcaClient = {
702
1240
  /** The last number ARCA authorized for a sales point and type; `0` when none. */
703
1241
  lastAuthorized: VouchersService["lastAuthorized"];
704
1242
  wsfe: WsfeService;
1243
+ /** WSFEX, ARCA's export service: its reference tables and exchange rates. */
1244
+ wsfex: WsfexService;
705
1245
  wsmtxca: WsmtxcaService;
706
1246
  padron: PadronService;
707
1247
  };
@@ -710,11 +1250,11 @@ type ArcaClient = {
710
1250
  * Validates the config, wires WSAA authentication and SOAP transport,
711
1251
  * and returns an object with `issue()`, `preview()`, `issueCreditNote()`,
712
1252
  * `issueDebitNote()`, `previewCreditNote()`, `previewDebitNote()`, `recover()`,
713
- * `lookup()`, `lastAuthorized()` and the `.wsfe`, `.wsmtxca`, and `.padron`
714
- * service modules.
1253
+ * `lookup()`, `lastAuthorized()` and the `.wsfe`, `.wsfex`, `.wsmtxca`, and
1254
+ * `.padron` service modules.
715
1255
  *
716
1256
  * @throws {ArcaConfigurationError} When the config is missing or invalid.
717
1257
  */
718
1258
  declare function createArcaClient(config?: ArcaClientOptions): ArcaClient;
719
1259
 
720
- export { type ArcaClient as A, type WsmtxcaLine as B, type CreditNoteInput as C, type DebitNoteInput as D, arcaQrPayload as E, type FceOptions as F, arcaQrUrl as G, createArcaClient as H, type InvoiceFamily as I, describeVoucherType as J, matchWsfeVoucherIdentity as K, voucherDateWindow as L, type NotePreview as N, type PeriodNoteInput as P, type Receiver as R, type Tribute as T, type VatItem as V, type WsfeIdentityMatch as W, ARCA_QR_URL as a, type AmountItem as b, type ArcaClientConfigView as c, type ArcaQrInput as d, type ArcaQrPayload as e, type FiscalHeader as f, type IssuanceFields as g, type IssueAmounts as h, type IssueCommon as i, type IssueInput as j, type IssueOptions as k, type IssueOutcome as l, type IssuePreview as m, type IssueRequest as n, type IssuedVoucher as o, type ItemLine as p, type PreviewOptions as q, type RecoveryOptions as r, type VatRate as s, type VoucherAmounts as t, type VoucherCoordinates as u, type VoucherDateWindowInput as v, type VoucherSummary as w, type VoucherTypeInfo as x, type VouchersService as y, type WsmtxcaIssueRequest as z };
1260
+ export { type WsfexCatalogEntry as $, type ArcaClient as A, type IssuePreview as B, type CreateWsfexServiceOptions as C, type DebitNoteInput as D, type ExportCreditNoteInput as E, type FceOptions as F, type IssueRequest as G, type IssuedVoucher as H, type InvoiceFamily as I, type ItemLine as J, type PreviewOptions as K, type RecoveryOptions as L, type VatRate as M, type NotePreview as N, type VoucherAmounts as O, type PeriodNoteInput as P, type VoucherCoordinates as Q, type Receiver as R, type VoucherDateWindowInput as S, type Tribute as T, type VoucherSummary as U, type VatItem as V, type VoucherTypeInfo as W, type VouchersService as X, type WsfeIdentityMatch as Y, type WsfexAssociatedVoucher as Z, type WsfexAuthorizationOutcome as _, ARCA_QR_URL as a, type WsfexCountryTaxId as a0, type WsfexExchangeRate as a1, type WsfexExportType as a2, type WsfexIssueInput as a3, type WsfexItem as a4, type WsfexLanguage as a5, type WsfexPermit as a6, type WsfexSalesPoint as a7, type WsfexService as a8, type WsfexVoucherInfo as a9, type WsfexVoucherInput as aa, type WsfexVoucherLookupResult as ab, type WsfexVoucherType as ac, type WsmtxcaIssueRequest as ad, type WsmtxcaLine as ae, arcaQrPayload as af, arcaQrUrl as ag, createArcaClient as ah, createWsfexService as ai, describeVoucherType as aj, matchWsfeVoucherIdentity as ak, voucherDateWindow as al, type AmountItem as b, type ArcaClientConfigView as c, type ArcaQrInput as d, type ArcaQrPayload as e, type CreditNoteInput as f, type ExportDebitNoteInput as g, type ExportHeader as h, type ExportIssueInput as i, type ExportIssueOutcome as j, type ExportIssueRequest as k, type ExportIssuedVoucher as l, type ExportItem as m, type ExportOfGoods as n, type ExportOfServices as o, type ExportPreview as p, type ExportReceiver as q, type ExportVoucherSummary as r, type ExportVoucherType as s, type FiscalHeader as t, type IssuanceFields as u, type IssueAmounts as v, type IssueCommon as w, type IssueInput as x, type IssueOptions as y, type IssueOutcome as z };