import { h as ArcaEnvironment, A as ArcaClientOptions } from './types-Su7QwloQ.js'; import { PadronService } from './padron.js'; import { WsfeVoucherInput, WsfeVoucherInfo, WsfeDateInput, WsfeService } from './wsfe.js'; import { VoucherClass, ReceiverCondition, IssuerCondition } from './constants.js'; import { e as ArcaAuthorizationOutcome, h as ArcaFiscalIssue, p as ArcaSafeErrorMetadata } from './fiscal-evidence-DaCyGd5o.js'; import { WsmtxcaService } from './wsmtxca.js'; type VoucherCoordinates = { salesPoint: number; voucherType: number; number: number; }; /** * Raw-free consultation evidence in the facade's units: money in minor units, * dates in `YYYY-MM-DD`. A field ARCA omits or reports unparseably is absent. */ type VoucherSummary = { number: number; salesPoint?: number; voucherType?: number; date?: string; concept?: number; documentType?: number; documentNumber?: string; receiverVatConditionId?: number; currencyId?: string; exchangeRate?: number; totalAmount?: number; netAmount?: number; vatAmount?: number; exemptAmount?: number; nonTaxableAmount?: number; taxAmount?: number; vatRates?: { id: number; baseAmount: number; amount: number; }[]; serviceStartDate?: string; serviceEndDate?: string; paymentDueDate?: string; result?: string; cae?: string; caeExpiry?: string; }; type WsfeIdentityMatch = { matches: true; } | { matches: false; evidence: "conflict" | "incomplete"; reason: string; }; /** * Compares the invoice subset supported by issue(): header identity, amounts, * VAT, tributes, associations, optional fields, buyers, activities and the * foreign-currency payment flag. This proves consistency, not authorship. * Configure a store and pass idempotencyKey for retries. Provider fields * outside that subset stay incomplete; a missing field is never proof. */ declare function matchWsfeVoucherIdentity(sent: WsfeVoucherInput, number: number, found: WsfeVoucherInfo): WsfeIdentityMatch; /** * One WSMTXCA provider line, derived from an `items` entry on the way out and * read back from ARCA on the way in. Amounts are cents; `unitPrice` is a * decimal major-unit string, the SDK's one monetary exception. */ type WsmtxcaLine = { description: string; quantity: number; unit: number; unitPrice: string; discount: number; vatCondition: number; vatAmount?: number; amount: number; code?: string; matrixCode?: string; matrixUnits?: number; }; /** @internal Shape written by facturas 0.10 through 0.12. */ type LegacyWsmtxcaLine = Omit & { discount?: number; }; type WsmtxcaIssueRequest = ReturnType; type FiscalHeader$1 = WsfeVoucherInput & { /** Derived provider lines. WSFE never reads them; WSMTXCA sends them. */ lines?: readonly WsmtxcaLine[]; /** @internal Lines mirrored from an authorized WSMTXCA consultation. */ authorizedLines?: readonly WsmtxcaLine[]; /** @internal Durable v2 reservation evidence written before `lines`. */ details?: readonly LegacyWsmtxcaLine[]; }; declare function wsmtxcaRequest(data: FiscalHeader$1, number?: number): { comprobanteCAERequest: { arrayItems: { item: { importeItem: number; importeIVA?: number | undefined; unidadesMtx: number | undefined; codigoMtx: string | undefined; codigo: string | undefined; descripcion: string; cantidad: number; codigoUnidadMedida: number; precioUnitario: string; importeBonificacion: number; codigoCondicionIVA: number; }[]; }; arraySubtotalesIVA: { subtotalIVA: { codigo: number; importe: number; }[]; } | undefined; arrayDatosAdicionales: { datoAdicional: ({ t: number; c1: string; } | { t: number; c1: string | undefined; c2: string | undefined; })[]; } | undefined; arrayActividades: { actividad: { codigo: number; }[]; } | undefined; arrayOtrosTributos?: { otroTributo: { codigo: number; descripcion: string | undefined; baseImponible: number; importe: number; }[]; } | undefined; arrayComprobantesAsociados: { comprobanteAsociado: { codigoTipoComprobante: number; numeroPuntoVenta: number; numeroComprobante: number; cuit: string | undefined; fechaEmision: string | undefined; }[]; } | undefined; periodoComprobantesAsociados: { fechaDesde: string | undefined; fechaHasta: string | undefined; } | undefined; arrayCompradores: { comprador: { codigoTipoDocumento: number; numeroDocumento: number; porcentaje: number; }[]; } | undefined; cancelaEnMismaMonedaExtranjera?: "S" | "N" | undefined; importeTotal: number; codigoMoneda: string; cotizacionMoneda: string | number | undefined; codigoConcepto: number; fechaServicioDesde: string | undefined; fechaServicioHasta: string | undefined; fechaVencimientoPago: string | undefined; importeOtrosTributos?: number | undefined; fechaEmision: string | undefined; codigoTipoDocumento: number; numeroDocumento: number; condicionIVAReceptor: number; importeGravado: number; importeNoGravado: number; importeExento: number; importeSubtotal: number; numeroComprobante?: number | undefined; codigoTipoComprobante: number; numeroPuntoVenta: number; }; }; declare const SUPPORTED_VAT_RATES: readonly [0, 2.5, 5, 10.5, 21, 27]; type SupportedVatRate = (typeof SUPPORTED_VAT_RATES)[number]; /** * The line an item describes. WSFE ignores every field here and derives its * header from the money alone; WSMTXCA requires `description`, `quantity`, * `unit` and `unitPrice` and sends the line as it is. The line never carries * its own VAT amount: that follows from the item's `vat` and its money. */ type ItemLine = { description?: string; quantity?: number; unit?: number; /** A major-unit decimal string with up to six decimals, unlike every other amount. */ unitPrice?: string; discount?: number; code?: string; matrixCode?: string; matrixUnits?: number; }; type VatRate = SupportedVatRate | "exempt" | "untaxed"; type VatItem = ItemLine & ({ net: number; gross?: never; amount?: never; vat: VatRate; } | { gross: number; net?: never; amount?: never; vat: VatRate; }); type AmountItem = ItemLine & { amount: number; vat?: never; net?: never; gross?: never; }; type IssueAmounts = { computedTotal: number; sentTotal: number; vatAdjustment: number; }; /** * The normalized fiscal fields shared by previews and authorized vouchers. * Dates are `YYYY-MM-DD`; `exchangeRate` is an exact decimal string. Service * dates are absent for product-only documents. `paymentDueDate` is absent when * the fiscal document has no due date. */ type FiscalHeader = { /** ARCA concept: products (1), services (2), or both (3). */ concept: 1 | 2 | 3; documentType: number; documentNumber: string; receiverVatConditionId: number; currencyId: string; exchangeRate?: string; serviceStartDate?: string; serviceEndDate?: string; paymentDueDate?: string; }; type IssueOptions = { service?: "wsfe" | "wsmtxca"; /** An externally reserved number. Never reads the next number when supplied. */ number?: number; idempotencyKey?: string; representedTaxId?: number | string; forceRefresh?: boolean; include?: { request?: boolean; rawResponse?: boolean; }; /** * The caller's deadline. It aborts the WSAA login, the submission and every * consultation of this call. An abort after the write was sent answers * `indeterminate` with `lookup.kind === "aborted"`: the reservation stays and * `recover()` settles it. */ abortSignal?: AbortSignal; }; /** Dates are `YYYY-MM-DD` and money is in minor units, like the input. */ type IssuedVoucher = VoucherCoordinates & { voucherClass: VoucherClass; date: string; header: FiscalHeader; cae: string; caeExpiry: string; amounts: IssueAmounts; /** * The URL the printed voucher's QR must encode, per ARCA's specification. * Absent only if ARCA answered a CAE the specification cannot encode: an * authorization is never lost over its QR. */ qr?: string; }; /** The provider a call targets. It is chosen explicitly, never switched. */ type IssuanceService = "wsfe" | "wsmtxca"; type ServiceFor = "service" extends keyof O ? "wsmtxca" extends O["service"] ? O extends { service: "wsmtxca"; } ? "wsmtxca" : IssuanceService : "wsfe" : "wsfe"; type IssueRequest = S extends "wsmtxca" ? WsmtxcaIssueRequest : WsfeVoucherInput; /** * What issue() would send, derived with zero I/O. The voucher number is absent * because it is only known when the number is reserved at issuance. */ type IssuePreview = { voucherClass: VoucherClass; voucherType: number; header: FiscalHeader; amounts: IssueAmounts; request: IssueRequest; service?: S; }; type WithRawResponse = T & (true extends NonNullable["rawResponse"] ? { rawResponse?: Record; } : unknown); type WithRequest = O extends { include: { request: true; }; } ? { request: IssueRequest>; } : true extends NonNullable["request"] ? { request?: IssueRequest>; } : unknown; type Evidence = WithRawResponse>, { kind: K; }>, "raw">, O>; /** Fiscal outcomes are returned. Keyed replays authorize only after not_found. */ type IssueOutcome = ({ kind: "authorized"; recoveredByMatch: false; voucher: IssuedVoucher; authorization: Evidence<"authorized", O>; } | { kind: "authorized"; recoveredByMatch: true; voucher: IssuedVoucher; attempt: Evidence<"indeterminate", O>; lookup: WithRawResponse; } | { kind: "rejected"; attempted: VoucherCoordinates; issues: ArcaFiscalIssue[]; authorization: Evidence<"rejected", O>; } | { kind: "indeterminate"; attempted: VoucherCoordinates; attempt: Evidence<"indeterminate", O>; lookup: WithRawResponse<{ kind: "not_found"; }, O> | WithRawResponse<{ kind: "incomplete"; reason: string; }, O> | { kind: "failed"; error: ArcaSafeErrorMetadata; } /** The caller's deadline fired; the reservation stays for recover(). */ | { kind: "aborted"; } /** An unresolved claim holds this sequence; resolve `by` and retry. */ | { kind: "blocked"; by: string; } /** The sequence moved past this key: it can never write. Use a new one. */ | { kind: "superseded"; by: string; }; } | { kind: "conflict"; attempted: VoucherCoordinates; attempt: Evidence<"indeterminate", O>; found: WithRawResponse; reason: string; }) & WithRequest; /** Monetary values in the high-level API are integer minor units. */ type Tribute = { id: number; description?: string; base: number; rate: number; amount: number; }; /** An already-reviewed fiscal breakdown; no recalculation of historical VAT. */ type VoucherAmounts = { net: number; vat: number; exempt?: number; untaxed?: number; vatRates?: readonly { id: number; base: number; amount: number; }[]; }; type InvoiceFamily = "ordinary" | "retention_legend" | "fce"; type IssuanceFields = { fce?: FceOptions; taxes?: readonly Tribute[]; amounts?: VoucherAmounts; concept?: "products" | "services" | "products_and_services"; dueDate?: WsfeDateInput; paidInForeignCurrency?: boolean; optionalFields?: WsfeVoucherInput["optionalFields"]; buyers?: WsfeVoucherInput["buyers"]; activities?: WsfeVoucherInput["activities"]; }; /** FCE business fields; the SDK encodes each provider's different option layout. */ type FceOptions = { cbu?: string; alias?: string; transfer?: "ADC" | "SCA"; annulment?: boolean; reference?: string; }; type Receiver = { condition: number; cuit?: string | number; dni?: string | number; document?: { type: number; number: string | number; }; } | { condition: "consumidor_final"; cuit?: number | string; dni?: number | string; } | { condition: Exclude; cuit: number | string; dni?: never; }; type IssueCommon = IssuanceFields & { family?: InvoiceFamily; salesPoint: number; to: Receiver; total?: number; date?: WsfeDateInput; currency?: "ARS" | "USD" | { id: string; }; exchangeRate?: string; service?: { from: WsfeDateInput; to: WsfeDateInput; dueDate: WsfeDateInput; }; }; type IssueInput = IssueCommon & ({ issuer: "responsable_inscripto"; items: readonly VatItem[]; amounts?: never; } | { issuer: "monotributo" | "exento" | "no_alcanzado"; items: readonly AmountItem[]; amounts?: never; } | { issuer: IssuerCondition; amounts: VoucherAmounts; items?: never; }); /** * The credited lines and, at most, the note's own sales point and date. * Class, receiver, currency, concept and service dates come from the originals. * * The mode is explicit: `items` or a reviewed `amounts` breakdown credits the * chosen lines, `all: true` credits the whole original. A forgotten field never * credits the whole invoice. A full note mirrors the original's tributes; a * partial note carries the `taxes` the caller chose, never a prorated share. */ type CreditNoteInput = Pick & { /** * The authorized invoice or debit note the note corrects, or a non-empty * list of them. Every original is consulted and every one is associated to * the note; they must agree on everything the note inherits. */ for: VoucherCoordinates | readonly VoucherCoordinates[]; salesPoint?: number; date?: WsfeDateInput; /** * The receiver's IVA condition, used only when the consulted original does * not report one. ARCA omits it on vouchers authorized before the field * existed. When the original reports it, the two must agree. */ to?: { condition: ReceiverCondition | number; }; } & ({ items: NonNullable; total?: number; all?: never; amounts?: never; } | { amounts: VoucherAmounts; items?: never; total?: number; all?: never; } | { all: true; items?: never; total?: never; amounts?: never; }); type PeriodNoteInput = IssueInput & { associatedPeriod: { from: WsfeDateInput; to: WsfeDateInput; }; for?: never; }; type DebitNoteInput = (CreditNoteInput & { all?: never; }) | PeriodNoteInput; type NotePreview = IssuePreview & { /** The originals consulted, in input order; absent for a period note. */ originals?: readonly VoucherSummary[]; }; type RecoveryOptions = Pick; type VouchersService = { /** Consults a durable reservation. Never allocates or authorizes a voucher. */ recover(idempotencyKey: string, options?: O): Promise>; /** * Issues a debit note against the same originals `issueCreditNote()` accepts, * or against a period with `associatedPeriod`. It has no `all: true` mode: * a debit note adds to the account, so its lines are always explicit. */ issueDebitNote(input: DebitNoteInput, options?: O): Promise>; /** * Derives what issueCreditNote() would send. Unlike the zero-I/O preview(), * it consults each original once: reads only, no write and no number * reserved. A linked note returns those raw-free originals in `originals`. A * period note carries its own business input and needs no lookup at all. */ previewCreditNote(input: CreditNoteInput | PeriodNoteInput, options?: O): Promise>>; /** Same contract as previewCreditNote(), for issueDebitNote() input. */ previewDebitNote(input: DebitNoteInput, options?: O): Promise>>; /** * Issues a credit note against an authorized invoice or debit note of the * ordinary, retention-legend or FCE families, or against a period with * `associatedPeriod`. The note credits the chosen `items` or reviewed * `amounts`, or the whole original with `all: true`. * * For a linked note everything except the credited lines, the note's sales * point and its date comes from the originals: class, receiver, currency, * concept and service dates. `for` takes one original or a list of them, * and every one is associated to the note. ARCA has no cancellation; every * mode writes a real fiscal document. */ issueCreditNote(input: CreditNoteInput | PeriodNoteInput, options?: O): Promise>; /** * Configure a store and pass idempotencyKey to recover retries after a crash. * * Without a key: one next-number read, one authorization and at most one lookup. * Keyed replay consults the reserved number; only not_found permits a write. * Local validation and next-number read failures throw before authorization. */ issue(input: IssueInput, options?: O): Promise>; /** * Derives what issue() would send for the same input, with no I/O at all: * no store, no WSAA, no SOAP and no next-number read. * * It throws every input error issue() throws before its first call, so a * caller that previews and then issues sees no new local error. */ preview = { service?: never; }>(input: IssueInput, options?: O): IssuePreview>; }; type PreviewOptions = { representedTaxId?: number | string; service?: "wsfe" | "wsmtxca"; forceRefresh?: boolean; abortSignal?: AbortSignal; }; /** Immutable, credential-free operational view of an ARCA client configuration. */ type ArcaClientConfigView = Readonly<{ taxId: string; environment: ArcaEnvironment; timeout?: number; retries?: number; retryDelay?: number; }>; /** Fully wired ARCA client with access to all service modules. */ type ArcaClient = { readonly config: ArcaClientConfigView; /** Issues an invoice from business input. Idempotent with a store and key. */ issue: VouchersService["issue"]; /** Derives what issue() would send for the same input, with no I/O. */ preview: VouchersService["preview"]; /** Issues a credit note against an authorized original or a period. */ issueCreditNote: VouchersService["issueCreditNote"]; /** Consults a durable reservation. Never allocates or authorizes a voucher. */ recover: VouchersService["recover"]; /** Issues a debit note against an authorized original or a period. */ issueDebitNote: VouchersService["issueDebitNote"]; /** Derives a credit note; reads the original but reserves no number. */ previewCreditNote: VouchersService["previewCreditNote"]; /** Derives a debit note; reads the original but reserves no number. */ previewDebitNote: VouchersService["previewDebitNote"]; wsfe: WsfeService; wsmtxca: WsmtxcaService; padron: PadronService; }; /** * Creates an ARCA client from the given configuration. * Validates the config, wires WSAA authentication and SOAP transport, * and returns an object with `issue()`, `preview()`, `issueCreditNote()`, * `issueDebitNote()`, `previewCreditNote()`, `previewDebitNote()`, `recover()` * and the `.wsfe`, `.wsmtxca`, and `.padron` service modules. * * @throws {ArcaConfigurationError} When the config is missing or invalid. */ declare function createArcaClient(config?: ArcaClientOptions): ArcaClient; export { type ArcaClient as A, type CreditNoteInput as C, type DebitNoteInput as D, type FceOptions as F, type InvoiceFamily as I, type NotePreview as N, type PeriodNoteInput as P, type Receiver as R, type Tribute as T, type VatItem as V, type WsfeIdentityMatch as W, type AmountItem as a, type ArcaClientConfigView as b, type FiscalHeader as c, type IssuanceFields as d, type IssuanceService as e, type IssueAmounts as f, type IssueCommon as g, type IssueInput as h, type IssueOptions as i, type IssueOutcome as j, type IssuePreview as k, type IssueRequest as l, type IssuedVoucher as m, type ItemLine as n, type PreviewOptions as o, type RecoveryOptions as p, type VatRate as q, type VoucherAmounts as r, type VoucherCoordinates as s, type VoucherSummary as t, type VouchersService as u, type WsmtxcaIssueRequest as v, type WsmtxcaLine as w, createArcaClient as x, matchWsfeVoucherIdentity as y };