/** * AFIP/ARCA WSFE catalogs — the canonical IDs you pass to `solicitarCAE` for * comprobante type, document type, IVA rate, concept, and currency. * * These are stable AFIP constants (some date back to RG 100/1998); they don't * change. Mirroring them here lets agents resolve a human-readable label * (e.g. "Factura C" or "21%") to its WSFE numeric code WITHOUT a network * round-trip to AFIP's `FEParamGetTipos*` endpoints. * * For the authoritative live list, use `getTiposCbte()`, `getTiposDoc()`, * `getTiposIva()`, `getTiposConcepto()` from `wsfe.ts` — they hit AFIP in * real time and pick up newly-added codes (e.g., FCE MiPyMEs 2018). */ /** * Tipo de comprobante (CbteTipo). The first thing you pick when emitting: * what kind of fiscal document is this? * * The choice depends on (a) your tax condition as the issuer and (b) the * receiver's tax condition. Common matrix: * * | Issuer ↓ / Receiver → | RI | Mono | Cons. Final | Exento | Exterior | * | ----------------------- | -------- | -------- | ----------- | ------ | -------- | * | Responsable Inscripto | A (1) | A (1) | B (6) | B (6) | E (19) | * | Monotributista | C (11) | C (11) | C (11) | C (11) | E (19) | * | Exento | C (11) | C (11) | C (11) | C (11) | E (19) | * * For credit/debit notes, the rule is: same letter as the original invoice. * * Common pitfall: you can't issue Factura M unless AFIP has flagged your CUIT * as "Sujeto No Categorizado" — for normal flows ignore tipo 51. */ declare const CbteTipo: { readonly FACTURA_A: 1; readonly NOTA_DEBITO_A: 2; readonly NOTA_CREDITO_A: 3; readonly RECIBO_A: 4; readonly NOTA_VENTA_AL_CONTADO_A: 5; readonly FACTURA_B: 6; readonly NOTA_DEBITO_B: 7; readonly NOTA_CREDITO_B: 8; readonly RECIBO_B: 9; readonly NOTA_VENTA_AL_CONTADO_B: 10; readonly FACTURA_C: 11; readonly NOTA_DEBITO_C: 12; readonly NOTA_CREDITO_C: 13; readonly RECIBO_C: 15; readonly FACTURA_M: 51; readonly NOTA_DEBITO_M: 52; readonly NOTA_CREDITO_M: 53; readonly RECIBO_M: 54; readonly FCE_FACTURA_A: 201; readonly FCE_NOTA_DEBITO_A: 202; readonly FCE_NOTA_CREDITO_A: 203; readonly FCE_FACTURA_B: 206; readonly FCE_NOTA_DEBITO_B: 207; readonly FCE_NOTA_CREDITO_B: 208; readonly FCE_FACTURA_C: 211; readonly FCE_NOTA_DEBITO_C: 212; readonly FCE_NOTA_CREDITO_C: 213; readonly FACTURA_E: 19; readonly NOTA_DEBITO_E: 20; readonly NOTA_CREDITO_E: 21; }; type CbteTipoCode = (typeof CbteTipo)[keyof typeof CbteTipo]; /** * Tipo de documento (DocTipo) — what kind of identifier the receiver is * presenting. CUIT is the most common for B2B; DNI for consumer-facing flows. */ declare const DocTipo: { readonly CUIT: 80; readonly CUIL: 86; readonly CDI: 87; readonly LE: 89; readonly LC: 90; readonly CI_EXTRANJERA: 91; readonly EN_TRAMITE: 92; readonly ACTA_NACIMIENTO: 93; readonly PASAPORTE: 94; readonly CI_BS_AS_RNP: 95; readonly DNI: 96; /** * Special "no identification" code for consumer-facing sales below the AFIP * threshold (currently ~$417k as of 2026). Pair with `DocNro: 0`. */ readonly CONSUMIDOR_FINAL: 99; }; type DocTipoCode = (typeof DocTipo)[keyof typeof DocTipo]; /** * Condición frente al IVA del receptor — MANDATORY in FECAESolicitar since * AFIP Resolución General 5616 (request rejected with observación 10246 if * absent). Codes from AFIP's `FEParamGetCondicionIvaReceptor` catalog. For * a Factura C (monotributista emisor) to a walk-in buyer use * `CONSUMIDOR_FINAL` (5) with `DocTipo.CONSUMIDOR_FINAL` + `DocNro 0`. */ declare const CondicionIvaReceptor: { readonly RESPONSABLE_INSCRIPTO: 1; readonly SUJETO_EXENTO: 4; readonly CONSUMIDOR_FINAL: 5; readonly RESPONSABLE_MONOTRIBUTO: 6; readonly SUJETO_NO_CATEGORIZADO: 7; readonly PROVEEDOR_DEL_EXTERIOR: 8; readonly CLIENTE_DEL_EXTERIOR: 9; readonly IVA_LIBERADO_LEY_19640: 10; readonly MONOTRIBUTISTA_SOCIAL: 13; readonly IVA_NO_ALCANZADO: 15; readonly MONOTRIBUTO_TRABAJADOR_INDEPENDIENTE_PROMOVIDO: 16; }; type CondicionIvaReceptorCode = (typeof CondicionIvaReceptor)[keyof typeof CondicionIvaReceptor]; /** * Concepto del comprobante. Determines whether the `FchServDesde`, * `FchServHasta`, and `FchVtoPago` fields are required: * * - **Productos (1)**: dates not required. * - **Servicios (2)**: dates REQUIRED — represents the service period and * the payment due date. * - **Productos y Servicios (3)**: dates required. * * For SaaS subscriptions, use `SERVICIOS` and pass the billing period. */ declare const Concepto: { readonly PRODUCTOS: 1; readonly SERVICIOS: 2; readonly PRODUCTOS_Y_SERVICIOS: 3; }; type ConceptoCode = (typeof Concepto)[keyof typeof Concepto]; /** * Alícuotas de IVA. The numeric code goes inside the `` * element of the request; the percentage is what your customer sees. * * For monotributistas (Factura C), do NOT include any `` items — the * concept of IVA discrimination doesn't apply. `ImpIVA` must be 0. */ declare const AlicuotaIva: { readonly CERO: { readonly id: 3; readonly percent: 0; }; readonly DOS_CINCO: { readonly id: 9; readonly percent: 2.5; }; readonly CINCO: { readonly id: 8; readonly percent: 5; }; readonly DIEZ_CINCO: { readonly id: 4; readonly percent: 10.5; }; readonly VEINTIUNO: { readonly id: 5; readonly percent: 21; }; readonly VEINTISIETE: { readonly id: 6; readonly percent: 27; }; }; type AlicuotaIvaCode = (typeof AlicuotaIva)[keyof typeof AlicuotaIva]["id"]; /** * Result code from a `solicitarCAE` call. * * - **A — Aprobado**: CAE issued. Persist `cae` + `caeFchVto`. * - **R — Rechazado**: errors returned. Inspect `observaciones` and `errors`. * - **P — Parcial**: at least one detail rejected (rare with `CantReg=1`). */ type WsfeResultado = "A" | "R" | "P"; /** * Currency code (MonId). PES = Pesos Argentinos, the default. Use other codes * for export invoices (Factura E) or multi-currency invoices. */ declare const Moneda: { readonly PESOS: "PES"; readonly DOLAR: "DOL"; readonly EURO: "060"; readonly REAL: "012"; }; type MonedaCode = (typeof Moneda)[keyof typeof Moneda]; /** * Human-readable label for a comprobante type code. Use to render UI or to * surface the result of `consultarUltimoAutorizado()` to end users. */ declare function describeCbteTipo(code: number): string; /** * Type definitions for AFIP/ARCA WSFE (factura electrónica) operations. * * These mirror the SOAP request/response shapes but as flat TS types — no * XML namespacing, no SOAP envelope artifacts. The internals translate * to/from XML. */ /** "homo" for sandbox; "prod" for live. Mirrors `@ar-agents/identity`. */ type WsfeEnv = "homo" | "prod"; /** * Single IVA discrimination row. Required for Facturas A, B, M when * `ImpIVA > 0`. Omit entirely for Factura C (monotributista). */ interface IvaItem { /** Alícuota code (e.g., 5 for 21%). See `AlicuotaIva`. */ id: AlicuotaIvaCode; /** Net amount this alícuota applies to. */ baseImp: number; /** IVA amount (= baseImp × percent / 100). */ importe: number; } /** * Single tributo (provincial / municipal tax) row. Optional. Use this for * Ingresos Brutos, impuestos internos, percepciones, etc. */ interface TributoItem { /** * Tributo type ID. AFIP catalog: 1 = Impuestos nacionales, 2 = Impuestos * provinciales (Ingresos Brutos), 3 = Impuestos municipales, * 4 = Impuestos Internos, 99 = Otro. */ id: number; /** Description (e.g., "Ingresos Brutos CABA"). */ desc: string; /** Base imponible. */ baseImp: number; /** Alícuota (percent). */ alic: number; /** Importe (= baseImp × alic / 100). */ importe: number; } /** * Optional reference to associated comprobantes — required for credit/debit * notes (must reference the original invoice). */ interface CbteAsociado { /** Tipo del comprobante asociado. */ tipo: CbteTipoCode; /** Punto de venta del comprobante asociado. */ ptoVta: number; /** Número del comprobante asociado. */ nro: number; /** CUIT del emisor del comprobante asociado. */ cuit?: string; /** Fecha del comprobante asociado (YYYYMMDD). */ fecha?: string; } /** * Optional opcional row — used for FCE MiPyMEs (CBU del receptor de la * Factura de Crédito), entrega bs. CABA (jurisdicción), etc. * * Common opcional codes: * - 2101: CBU del receptor de la FCE * - 2102: Anulación FCE * - 27: SLU (Sistema de Liquidación Única) * - 22: Adicional sobre receptor */ interface OpcionalItem { /** Opcional ID per AFIP catalog. */ id: string; /** Value (interpreted per the ID). */ valor: string; } /** * Single comprobante to authorize. The `solicitarCAE()` API accepts an array * (AFIP supports batch up to 250 per request) but most agentic flows submit * one at a time for clear error attribution. */ interface SolicitarCaeInput { /** Punto de venta (sale point). 1–9999. Must be enabled in your AFIP panel. */ ptoVta: number; /** Comprobante type — see `CbteTipo`. */ cbteTipo: CbteTipoCode; /** Concept type — see `Concepto`. */ concepto: ConceptoCode; /** Document type for the receiver — see `DocTipo`. */ docTipo: DocTipoCode; /** Document number for the receiver. Pass `0` for `CONSUMIDOR_FINAL`. */ docNro: string | number; /** * Condición frente al IVA del receptor (AFIP `CondicionIVAReceptorId`). * MANDATORY since AFIP RG 5616 — omitting it is rejected with observación * 10246. See the `CondicionIvaReceptor` catalog. When omitted the request * builder derives a safe default (DocTipo CONSUMIDOR_FINAL → 5; otherwise * Responsable Inscripto = 1) so existing callers keep working; pass it * explicitly for any other receiver condition. */ condicionIvaReceptorId?: CondicionIvaReceptorCode; /** * Comprobante number range. For single-comprobante calls (the norm), * `cbteDesde === cbteHasta`. Get the next number from * `consultarUltimoAutorizado() + 1`. */ cbteDesde: number; cbteHasta: number; /** Comprobante date as `YYYYMMDD` (e.g., "20260506"). */ cbteFch: string; /** Importe total (= ImpNeto + ImpIVA + ImpTrib + ImpOpEx + ImpTotConc). */ impTotal: number; /** Importe neto no gravado. Default 0. */ impTotConc?: number; /** Importe neto gravado (subtotal before IVA). */ impNeto: number; /** Importe operaciones exentas. Default 0. */ impOpEx?: number; /** Importe total tributos (sum of `tributos[].importe`). Default 0. */ impTrib?: number; /** Importe IVA (sum of `iva[].importe`). 0 for Factura C. */ impIVA: number; /** * Service period start `YYYYMMDD`. REQUIRED when concepto = SERVICIOS or * PRODUCTOS_Y_SERVICIOS. Optional otherwise. */ fchServDesde?: string; /** Service period end `YYYYMMDD`. Same rules as `fchServDesde`. */ fchServHasta?: string; /** Payment due date `YYYYMMDD`. Same rules as `fchServDesde`. */ fchVtoPago?: string; /** Currency code. Default "PES". */ monId?: MonedaCode | string; /** Currency exchange rate vs ARS. Default 1 for PES. */ monCotiz?: number; /** IVA discrimination rows. Required when `impIVA > 0`. */ iva?: IvaItem[]; /** Tributo (provincial/municipal) rows. */ tributos?: TributoItem[]; /** Comprobantes asociados (required for notas de crédito/débito). */ cbtesAsoc?: CbteAsociado[]; /** Opcional rows (for FCE MiPyMEs etc.). */ opcionales?: OpcionalItem[]; } /** * Result of a single `solicitarCAE` call. The CAE is the AFIP-authorized * code you must print on the comprobante (along with its expiration date). */ interface SolicitarCaeResult { /** AFIP processing result. "A" = approved (CAE issued), "R" = rejected. */ resultado: WsfeResultado; /** * The 14-digit CAE (Código de Autorización Electrónico). MUST be printed on * the comprobante. `null` when `resultado !== "A"`. */ cae: string | null; /** * CAE expiration date as `YYYYMMDD`. The comprobante must be reported to * the receiver before this date. `null` when `resultado !== "A"`. */ caeFchVto: string | null; /** Punto de venta (echo from request). */ ptoVta: number; /** Comprobante type (echo from request). */ cbteTipo: CbteTipoCode; /** Comprobante number (echo from request). */ cbteDesde: number; cbteHasta: number; /** Comprobante date (echo from request). */ cbteFch: string; /** * AFIP processing date `YYYYMMDD` — when the request was processed * server-side, may differ from the comprobante date. */ fchProceso: string; /** * Per-detail observaciones (warnings or rejection reasons). Surface * verbatim — these come from AFIP and are actionable for the user. */ observaciones: WsfeObservacion[]; /** * Top-level errors (request was malformed). Distinct from per-detail * observaciones — these mean the entire request failed. */ errors: WsfeError[]; /** * Eventos (informational AFIP messages, e.g., maintenance window * notifications). Surface to ops dashboards. */ eventos: WsfeEvento[]; } interface WsfeObservacion { code: number; msg: string; } interface WsfeError { code: number; msg: string; } interface WsfeEvento { code: number; msg: string; } /** * Result of `consultarUltimoAutorizado()`. */ interface UltimoComprobanteResult { /** Punto de venta queried. */ ptoVta: number; /** Comprobante type queried. */ cbteTipo: CbteTipoCode; /** * The last authorized comprobante number for this (ptoVta, cbteTipo) pair. * `0` if no comprobante has ever been authorized — your next emission * uses `cbteDesde: 1`. */ cbteNro: number; } /** * Result of `consultarComprobante()` — full echo of an already-authorized * comprobante. Use this to verify a CAE is valid and matches what you have. */ interface ConsultarComprobanteResult { found: boolean; ptoVta: number; cbteTipo: CbteTipoCode; cbteDesde: number; cbteHasta: number; cbteFch: string; cae: string; caeFchVto: string; resultado: WsfeResultado; emisionTipo: string; docTipo: DocTipoCode; docNro: string; impTotal: number; impNeto: number; impIVA: number; observaciones: WsfeObservacion[]; } /** * Result of `dummy()` — AFIP health check. All three fields should be "OK" * when the system is up. Use for /health endpoints and pre-emission gating. */ interface DummyResult { /** Application server status. */ appServer: string; /** Database server status. */ dbServer: string; /** Auth server status. */ authServer: string; } export { AlicuotaIva as A, type CbteTipoCode as C, type DummyResult as D, type IvaItem as I, Moneda as M, type OpcionalItem as O, type SolicitarCaeInput as S, type TributoItem as T, type UltimoComprobanteResult as U, type WsfeEnv as W, type ConsultarComprobanteResult as a, type SolicitarCaeResult as b, type WsfeError as c, type AlicuotaIvaCode as d, type CbteAsociado as e, CbteTipo as f, Concepto as g, type ConceptoCode as h, CondicionIvaReceptor as i, type CondicionIvaReceptorCode as j, DocTipo as k, type DocTipoCode as l, type MonedaCode as m, type WsfeEvento as n, type WsfeObservacion as o, type WsfeResultado as p, describeCbteTipo as q };