### Quick Start Example Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Demonstrates how to initialize the Arca SDK and get the server status. ```APIDOC ## Quick Start ```ts import { Arca } from "@arcasdk/core"; const arca = new Arca({ cuit: 20111111112, cert: process.env.AFIP_CERT!, key: process.env.AFIP_KEY!, production: false, }); await arca.electronicBillingService.getServerStatus(); ``` ``` -------------------------------- ### Minimum Arca SDK Usage Example Source: https://github.com/ralcorta/arcasdk/blob/main/AGENTS.md Demonstrates the basic setup of the Arca SDK client with CUIT, certificate, key, and environment settings, followed by calls to fetch server status, create an invoice, and get taxpayer details. ```typescript import { Arca } from "@arcasdk/core"; const arca = new Arca({ cuit: 20111111112, cert: process.env.AFIP_CERT!, // PEM o ruta al .crt key: process.env.AFIP_KEY!, // PEM o ruta al .key production: false, // homologación }); const status = await arca.electronicBillingService.getServerStatus(); const invoice = await arca.electronicBillingService.createNextVoucher({ /* ... */ }); const taxpayer = await arca.registerScopeFourService.getTaxpayerDetails(20111111111); ``` -------------------------------- ### Install Arca SDK Core Source: https://github.com/ralcorta/arcasdk/blob/main/docs/index.md Install the core package using npm, yarn, or pnpm. ```bash npm i @arcasdk/core ``` ```bash yarn add @arcasdk/core ``` ```bash pnpm add @arcasdk/core ``` -------------------------------- ### Install Project Dependencies and Run Scripts Source: https://github.com/ralcorta/arcasdk/blob/main/AGENTS.md Install all project dependencies, lint the code, run unit tests, build the project, and execute integration tests. Integration tests require certificates in the test-credentials directory. ```bash npm install npm run lint npm test npm run build npm run test:integration # requiere certificados en test-credentials/ ``` -------------------------------- ### Install Arca SDK Core and PDF Packages Source: https://github.com/ralcorta/arcasdk/blob/main/AGENTS.md Install the core SDK package for ARCA services and optionally the PDF generation package. ```bash npm i @arcasdk/core # opcional PDF npm i @arcasdk/pdf ``` -------------------------------- ### Install @arcasdk/pdf Source: https://github.com/ralcorta/arcasdk/blob/main/packages/pdf/README.md Install the package using npm. ```bash npm i @arcasdk/pdf ``` -------------------------------- ### Install Arca SDK with pnpm Source: https://github.com/ralcorta/arcasdk/blob/main/docs/introduction.md Use this command to install the Arca SDK using pnpm. ```sh pnpm add @arcasdk/core ``` -------------------------------- ### Install Arca SDK with yarn Source: https://github.com/ralcorta/arcasdk/blob/main/docs/introduction.md Use this command to install the Arca SDK using yarn. ```sh yarn add @arcasdk/core ``` -------------------------------- ### Install Arca SDK with npm Source: https://github.com/ralcorta/arcasdk/blob/main/docs/introduction.md Use this command to install the Arca SDK using npm. ```sh npm i @arcasdk/core --save ``` -------------------------------- ### Install @arcasdk/pdf using npm, yarn, or pnpm Source: https://github.com/ralcorta/arcasdk/blob/main/docs/packages/pdf.md Choose the package manager that suits your project to install the @arcasdk/pdf package. ```bash npm i @arcasdk/pdf ``` ```bash yarn add @arcasdk/pdf ``` ```bash pnpm add @arcasdk/pdf ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/ralcorta/arcasdk/blob/main/CONTRIBUTING.md Examples of valid commit messages following the Conventional Commits specification. ```bash git commit -m "feat(register): agregar validación de CUIT" ``` ```bash git commit -m "fix(auth): resolver issue de token expirado" ``` ```bash git commit -m "docs: actualizar README con ejemplos" ``` ```bash git commit -m "test(coverage): agregar tests para error handling" ``` -------------------------------- ### Accessing Web Services Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Illustrates how to access different ARCA web services through properties of the Arca instance and provides examples for common operations. ```APIDOC ## Accessing Web Services ### Description The `Arca` class exposes properties that correspond to different ARCA web services. You can call methods on these service properties to interact with the respective services. ### Service Properties | Property | Web service | Documentation | | --------- | ----------- | ------------- | | `electronicBillingService` | WSFE | [Facturación electrónica](/services/facturacion_electronica) | | `wsfexService` | WSFEX | [Facturación de exportación](/services/facturacion_electronica_exportacion) | | `wsfecredService` | WSFECRED | [Factura de crédito MiPyMEs](/services/factura_credito_electronica) | | `registerScopeFourService` | Padrón A4 | [Padrón alcance 4](/services/consulta_padron_alcance_4) | | `registerScopeFiveService` | Padrón A5 | [Padrón alcance 5](/services/consulta_padron_alcance_5) | | `registerScopeTenService` | Padrón A10 | [Padrón alcance 10](/services/consulta_padron_alcance_10) | | `registerScopeThirteenService` | Padrón A13 | [Padrón alcance 13](/services/consulta_padron_alcance_13) | | `registerInscriptionProofService` | Constancia inscripción | [Constancia de inscripción](/services/consulta_padron_constancia_inscripcion) | | `genericService` | Cualquier WSDL / SOAP genérico | [Servicio genérico](/services/generic-service) | ### Usage Examples ```ts import { Arca, ArcaServiceNames } from "@arcasdk/core"; // Assuming 'arca' is an initialized Arca instance // Electronic Billing Service await arca.electronicBillingService.getServerStatus(); // WSFEX Service await arca.wsfexService.dummy(); // WSFECRED Service await arca.wsfecredService.consultarTiposRetenciones(); // Register Scope Four Service await arca.registerScopeFourService.getTaxpayerDetails(20111111111); // Generic Service await arca.genericService.call(ArcaServiceNames.WSFE, "FEDummy", {}); ``` ``` -------------------------------- ### Pull Request Description Example Source: https://github.com/ralcorta/arcasdk/blob/main/CONTRIBUTING.md An example of a well-structured pull request description, including changes, related issues, and testing information. ```markdown ## Descripción Agregué validación de CUIT según normas AFIP ## Cambios - Valida que CUIT tenga 11 dígitos - Verifica dígito verificador con algoritmo AFIP ## Relacionado Closes #45 ## Tests - Tests unitarios agregados - Cobertura: 95% - CI/CD: Todos los checks pasaron ``` -------------------------------- ### Factura E Example (Export) Source: https://github.com/ralcorta/arcasdk/blob/main/docs/packages/pdf.md Example of a Factura E (export invoice) structure. This includes fields specific to international transactions like currency, exchange rates, and destination country. ```typescript const facturaE: InvoiceData = { emisor: { razonSocial: "Exportadora de Prueba S.A.", domicilioComercial: "Puerto Madero 100, CABA", condicionIva: "IVA Responsable Inscripto", cuit: "30111111118", iibb: "12-3456789-0", fechaInicioActividades: "20200101", }, receptor: { razonSocial: "Empresa Exterior de Prueba", domicilio: "1234 Market St, San Francisco, CA, USA", condicionIva: "Cliente del Exterior", documentoTipo: "CUIT", documentoNro: "55000000000", cuitPais: "55000002126 (ESTADOS UNIDOS - Persona Jurídica)", idImpositivo: "261907945", }, cbteTipo: 19, cbteLetra: "E", puntoVenta: 5, cbteDesde: 10, cbteHasta: 10, cbteFecha: "20240701", concepto: 1, moneda: "DOL", cotizacion: 1391.5, condicionIvaExportacion: "IVA EXENTO OPERACIÓN DE EXPORTACIÓN", divisa: "USD - Dólar Estadounidense", destinoComprobante: "ESTADOS UNIDOS", formaPago: "Transferencia SWIFT - Moneda Extranjera", fechaPago: "20240715", incoterms: "FOB", items: [ { descripcion: "Consulting services", cantidad: 40, unidadMedida: "horas", precioUnitario: 150, subtotal: 6000, }, ], importeNetoGravado: 6000, importeIva: 0, importeTotal: 6000, cae: "74512345678903", caeFechaVencimiento: "20240711", }; ``` -------------------------------- ### Implement Custom Ticket Storage Source: https://github.com/ralcorta/arcasdk/blob/main/docs/credential_management.md Use `ITicketStoragePort` for custom storage solutions like Redis or PostgreSQL. For short-lived processes like tests or scripts, `MemoryTicketStorage` is suitable. This example shows setting up file system storage. ```typescript import { Arca, MemoryTicketStorage, FileSystemTicketStorage, type ITicketStoragePort, } from "@arcasdk/core"; // Ejemplo: memoria (útil en tests; no persiste entre invocaciones Lambda) const ticketStorage: ITicketStoragePort = new MemoryTicketStorage({ cuit: 20111111112, production: false, }); // Ejemplo: filesystem en ruta controlada por vos const ticketStorageFs = new FileSystemTicketStorage({ ticketPath: "/tmp/arca-tickets", cuit: 20111111112, production: false, }); const arca = new Arca({ cuit: 20111111112, cert: "...", key: "...", ticketStorage: ticketStorageFs, }); ``` -------------------------------- ### Emit Factura B (Consumer Final) - Homologation Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Use createNextVoucher to automatically get the next voucher number for issuing a Factura B. This example is for homologation (testing) environment. ```typescript const fecha = new Date().toISOString().slice(0, 10).replace(/-/g, ""); const result = await arca.electronicBillingService.createNextVoucher({ CantReg: 1, PtoVta: 1, CbteTipo: 6, Concepto: 1, DocTipo: 99, DocNro: 0, CbteFch: fecha, ImpTotal: 121, ImpTotConc: 0, ImpNeto: 100, ImpOpEx: 0, ImpIVA: 21, ImpTrib: 0, MonId: "PES", MonCotiz: 1, Iva: [{ Id: 5, BaseImp: 100, Importe: 21 }], }); console.log(result.cae, result.caeFchVto); ``` -------------------------------- ### Arca Class Initialization Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Demonstrates how to instantiate the Arca class with necessary context like CUIT, certificate, key, and production environment flag. ```APIDOC ## Arca Class Initialization ### Description Instantiate the main `Arca` class by providing a `Context` object containing your CUIT, certificate, key, and production environment setting. ### Code Example ```ts import { Arca } from "@arcasdk/core"; const arca = new Arca({ cuit: 20111111112, cert: "...", key: "...", production: false, }); ``` ``` -------------------------------- ### Emit Factura B (Consumer Final) - Homologation Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Example of how to issue a Factura B for a final consumer using `createNextVoucher` to automatically get the next voucher number. This is for homologation (testing) purposes. ```APIDOC ## Emitir Factura B (consumidor final) — homologación Usar `createNextVoucher` para obtener el próximo número automáticamente: ```ts const fecha = new Date().toISOString().slice(0, 10).replace(/-/g, ""); const result = await arca.electronicBillingService.createNextVoucher({ CantReg: 1, PtoVta: 1, CbteTipo: 6, Concepto: 1, DocTipo: 99, DocNro: 0, CbteFch: fecha, ImpTotal: 121, ImpTotConc: 0, ImpNeto: 100, ImpOpEx: 0, ImpIVA: 21, ImpTrib: 0, MonId: "PES", MonCotiz: 1, Iva: [{ Id: 5, BaseImp: 100, Importe: 21 }], }); console.log(result.cae, result.caeFchVto); ``` ``` -------------------------------- ### Run Project Tests and Build Source: https://github.com/ralcorta/arcasdk/blob/main/CONTRIBUTING.md Execute linting, tests, coverage, and build commands to ensure code quality and functionality. ```bash npm run lint npm test npm run test:coverage npm run build ``` -------------------------------- ### Uso Básico del GenericService Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/generic-service.md Ejemplo de cómo inicializar el SDK y llamar a un método 'dummy' del servicio Padrón A4 usando el alias WSAA correspondiente. Requiere importar Arca y ArcaServiceNames. ```typescript import { Arca, ArcaServiceNames } from "@arcasdk/core"; const arca = new Arca({ cuit: 20111111111, cert: "...", key: "...", }); async function checkPadronStatus() { const result = await arca.genericService.call( ArcaServiceNames.WSSR_PADRON_FOUR, "dummy", {}, ); console.log(result); } ``` -------------------------------- ### Instantiate AuthRepository and Request Login Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Shows how to create an instance of AuthRepository with CUIT, certificate, key, and production flag. It then requests a login ticket for a specific service. ```typescript import { AuthRepository, ArcaServiceNames } from "@arcasdk/core"; const authRepository = new AuthRepository({ cuit: 20111111112, cert: "...", key: "...", production: false, }); const ticket = await authRepository.requestLogin(ArcaServiceNames.WSFE); const credentials = ticket.toLoginCredentials(); ``` -------------------------------- ### Clonar y Preparar el Proyecto Source: https://github.com/ralcorta/arcasdk/blob/main/CONTRIBUTING.md Clona el repositorio, navega al directorio y instala las dependencias necesarias usando npm. ```bash git clone https://github.com/ralcorta/arcasdk.git cd arcasdk npm install ``` -------------------------------- ### Initialize Arca SDK and Create Voucher Source: https://github.com/ralcorta/arcasdk/blob/main/docs/index.md Initialize the Arca SDK with your CUIT and credentials, then use it to create an electronic voucher. Ensure your certificate and key are available via environment variables. ```typescript import { Arca } from "@arcasdk/core"; const arca = new Arca({ cuit: 20111111112, cert: process.env.AFIP_CERT, key: process.env.AFIP_KEY, }); const invoice = await arca.electronicBillingService.createVoucher({ // ... tu comprobante }); ``` -------------------------------- ### Factura B Example Source: https://github.com/ralcorta/arcasdk/blob/main/docs/packages/pdf.md Example of a Factura B (domestic invoice) structure. Ensure all required fields for a domestic invoice are correctly populated. ```typescript const facturaB: InvoiceData = { emisor: { razonSocial: "Emisor de Prueba", domicilioComercial: "Av. Belgrano 789, CABA", condicionIva: "IVA Responsable Inscripto", cuit: "20111111117", iibb: "901-234567-0", fechaInicioActividades: "20150601", }, receptor: { razonSocial: "Receptor de Prueba", condicionIva: "Consumidor Final", documentoTipo: "DNI", documentoNro: "31456789", }, cbteTipo: 6, cbteLetra: "B", puntoVenta: 1, cbteDesde: 500, cbteHasta: 500, cbteFecha: "20240610", concepto: 2, fechaServicioDesde: "20240501", fechaServicioHasta: "20240531", fechaVtoPago: "20240625", items: [ { descripcion: "Liquidación de sueldos - Mayo 2024", cantidad: 1, unidadMedida: "servicio", precioUnitario: 25000, subtotal: 25000, }, ], importeNetoGravado: 25000, importeIva: 0, importeTotal: 25000, cae: "74512345678902", caeFechaVencimiento: "20240620", }; ``` -------------------------------- ### Generar Clave de Cifrado con OpenSSL Source: https://github.com/ralcorta/arcasdk/blob/main/docs/tutorial/obtain-production-certificate.md Utiliza este comando para generar un archivo de clave privada (key) necesario para el certificado. Asegúrate de reemplazar `[nombre de archivo]` con un nombre descriptivo y de guardar este archivo de forma segura, ya que es esencial para el funcionamiento del certificado. ```bash openssl genrsa -out [nombre de archivo] 2048 ``` ```bash openssl genrsa -out keytest 2048 ``` -------------------------------- ### Get Server Status Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/consulta_padron_alcance_10.md Checks if the Padrón A10 service is operational. ```APIDOC ## Get Server Status ### Description Verifies if the Padrón A10 service is operational. ### Method Not explicitly defined, but implied to be a service call. ### Endpoint Not explicitly defined, but part of `registerScopeTenService`. ### Parameters This method does not require any parameters. ### Request Example ```ts const status = await arca.registerScopeTenService.getServerStatus(); console.log(status); ``` ### Response #### Success Response (200) - **appServer** (string) - Status of the application server. - **dbServer** (string) - Status of the database server. - **authServer** (string) - Status of the authentication server. #### Response Example ```json { "appServer": "OK", "dbServer": "OK", "authServer": "OK" } ``` ``` -------------------------------- ### Configuración de SOAP 1.1 para Servicios Específicos Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/generic-service.md Muestra cómo deshabilitar SOAP 1.2 para la instancia de Arca si se necesita usar SOAP 1.1, lo cual es requerido por algunos servicios como Padrón o WSFECRED si se utiliza un WSDL custom que solo soporta SOAP 1.1. ```typescript const arca = new Arca({ cuit: 20111111111, cert: "...", key: "...", useSoap12: false, }); ``` -------------------------------- ### Get Server Status Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/consulta_padron_constancia_inscripcion.md Checks if the Constancia de Inscripción service is operational. ```APIDOC ## Get Server Status ### Description Verifies if the Constancia de Inscripción service is operational. ### Method ```ts getServerStatus(): Promise ``` ### Request Example ```ts const status = await arca.registerInscriptionProofService.getServerStatus(); console.log(status); ``` ### Response #### Success Response (200) - **appServer** (string) - Status of the application server. - **dbServer** (string) - Status of the database server. - **authServer** (string) - Status of the authentication server. #### Response Example ```json { "appServer": "OK", "dbServer": "OK", "authServer": "OK" } ``` ``` -------------------------------- ### Get Taxpayers Details Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/consulta_padron_constancia_inscripcion.md Allows querying up to 250 CUITs in a single request. ```APIDOC ## Get Taxpayers Details ### Description Allows querying up to 250 CUITs in a single request. ### Method ```ts getTaxpayersDetails(cuits: number[]): Promise ``` ### Parameters #### Path Parameters - **cuits** (array of numbers) - Required - An array of CUITs to query. ### Request Example ```ts const taxpayers = await arca.registerInscriptionProofService.getTaxpayersDetails([20111111111, 20222222222]); console.log(`Se encontraron ${taxpayers.cantidadRegistros} contribuyentes.`); ``` ### Response #### Success Response (200) - **metadata** (object) - Contains information about the request timestamp and server. - **cantidadRegistros** (number) - The total number of taxpayers found. - **persona** (array of objects) - An array containing details for each queried taxpayer. #### Response Example ```json { "metadata": { "fechaHora": "2024-01-01T12:00:00.000-03:00", "servidor": "server1" }, "cantidadRegistros": 2, "persona": [ { "datosGenerales": { "idPersona": 20111111111 // ... más datos } }, { "datosGenerales": { "idPersona": 20222222222 // ... más datos } } ] } ``` ``` -------------------------------- ### Consultar Padrón (Scope 4) Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Example of how to query taxpayer details from the Padrón A4 scope. ```APIDOC ## Consultar padrón (alcance 4) ```ts const details = await arca.registerScopeFourService.getTaxpayerDetails(20111111111); ``` ``` -------------------------------- ### Llamadas a Servicios con WSDL Incluido Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/generic-service.md Demuestra cómo llamar a diferentes métodos de servicios ARCA que tienen WSDL preconfigurado en el SDK, como WSFE, WSFEX, WSFECRED y Padrón A4. No se requiere 'wsdlContent'. ```typescript // WSFE — estado del servidor await arca.genericService.call(ArcaServiceNames.WSFE, "FEDummy", {}); // WSFEX — dummy de exportación await arca.genericService.call(ArcaServiceNames.WSFEX, "FEXDummy", {}); // WSFECRED — consulta de parámetros await arca.genericService.call( ArcaServiceNames.WSFECRED, "consultarTiposRetenciones", {}, ); // Padrón A4 — consulta de contribuyente (auth inyectada automáticamente) await arca.genericService.call(ArcaServiceNames.WSSR_PADRON_FOUR, "getPersona", { idPersona: 20111111111, }); ``` -------------------------------- ### Get CAEA Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/facturacion_electronica.md Retrieves the advance electronic authorization code (CAEA) for a given period and order. ```APIDOC ## GET /electronicBillingService/getCaea ### Description Retrieves the advance electronic authorization code (CAEA) for a given period and order. ### Method GET ### Endpoint /electronicBillingService/getCaea ### Parameters #### Query Parameters - **period** (integer) - Required - The period in YYYYMM format (e.g., 202406). - **order** (integer) - Required - The order of the fortnight: 1 for the 1st fortnight, 2 for the 2nd fortnight. ### Response #### Success Response (200) - **resultGet.caea** (string) - The obtained CAEA code. ``` -------------------------------- ### Obtener Monedas con Cotización Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/facturacion_electronica_exportacion.md Recupera la lista de monedas para las cuales se puede obtener una cotización para una fecha específica. ```typescript const result = await arca.wsfexService.getParamMonConCotizacion({ Fecha_CTZ: "20240601", }); ``` -------------------------------- ### Get Enabled Sales Points Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Fetches a list of sales points that are enabled for the current issuer. ```APIDOC ## Puntos de venta habilitados ```ts const points = await arca.electronicBillingService.getSalesPoints(); ``` ``` -------------------------------- ### Crear una Rama para Contribuciones Source: https://github.com/ralcorta/arcasdk/blob/main/CONTRIBUTING.md Utiliza convenciones de nombres claras al crear nuevas ramas para features, correcciones de bugs, documentación o mejoras de rendimiento. ```bash # Features git checkout -b feature/nombre-descriptivo # Bug fixes git checkout -b fix/descripcion-del-bug # Documentation git checkout -b docs/tema # Performance git checkout -b perf/descripcion ``` -------------------------------- ### Get Enabled Sales Points Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Fetch a list of sales points that are enabled for the current issuer. ```typescript const points = arca.electronicBillingService.getSalesPoints(); ``` -------------------------------- ### Access and Use Arca Services Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Demonstrates how to call methods on different ARCA services after initializing the Arca instance. Ensure the Arca instance is properly configured before making calls. ```typescript import { Arca, ArcaServiceNames } from "@arcasdk/core"; await arca.electronicBillingService.getServerStatus(); await arca.wsfexService.dummy(); await arca.wsfecredService.consultarTiposRetenciones(); await arca.registerScopeFourService.getTaxpayerDetails(20111111111); await arca.genericService.call(ArcaServiceNames.WSFE, "FEDummy", {}); ``` -------------------------------- ### Get Last Authorized Voucher Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Retrieves the last authorized voucher for a given point of sale and voucher type. ```APIDOC ## Último comprobante autorizado ```ts const last = await arca.electronicBillingService.getLastVoucher(1, 6); ``` ``` -------------------------------- ### Comandos Útiles para Desarrollo y Calidad Source: https://github.com/ralcorta/arcasdk/blob/main/CONTRIBUTING.md Ejecuta comandos para linting, pruebas unitarias (con o sin cobertura), compilación y modo watch para desarrollo. ```bash # Lint (verifica código) npm run lint # Tests (unit tests) npm run test # Tests con cobertura npm run test:coverage # Build npm run build # Watch mode para desarrollo npm run test -- --watch ``` -------------------------------- ### Get Last Authorized Voucher Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Retrieve the last authorized voucher for a given point of sale and voucher type. ```typescript const last = await arca.electronicBillingService.getLastVoucher(1, 6); ``` -------------------------------- ### Initialize Arca SDK Source: https://github.com/ralcorta/arcasdk/blob/main/docs/public/llms.txt Initialize the Arca SDK with CUIT, certificate, private key, and environment setting. Ensure environment variables for AFIP_CERT and AFIP_KEY are set. ```typescript import { Arca } from "@arcasdk/core"; const arca = new Arca({ cuit: 20111111112, cert: process.env.AFIP_CERT!, key: process.env.AFIP_KEY!, production: false, }); await arca.electronicBillingService.getServerStatus(); ``` -------------------------------- ### Generate PDF as a Stream Source: https://github.com/ralcorta/arcasdk/blob/main/packages/pdf/README.md Generate the PDF document as a stream, which can be piped directly to a response object, for example, in an Express.js application. ```typescript const stream = await generator.generateStream(data); stream.pipe(res); // Express response ``` -------------------------------- ### Verificar Estado del Servidor WSFEX Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/facturacion_electronica_exportacion.md Utiliza este método para comprobar si los servicios de WSFEX están operativos. Requiere inicializar la SDK de Arca. ```typescript const status = await arca.wsfexService.dummy(); console.log(status.FEXDummyResult); // { AppServer: "OK", DbServer: "OK", AuthServer: "OK" } ``` -------------------------------- ### Get Taxpayer Details Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/consulta_padron_alcance_10.md Retrieves the details of an individual or legal entity using their CUIT. This endpoint is suitable for querying Exentos and Monotributistas. ```APIDOC ## Get Taxpayer Details ### Description Consults the details of an individual or legal entity by their CUIT. ### Method Not explicitly defined, but implied to be a service call. ### Endpoint Not explicitly defined, but part of `registerScopeTenService`. ### Parameters #### Path Parameters - **cuit** (number) - Required - The CUIT of the taxpayer to query. ### Request Example ```ts // Consultar datos del CUIT 20111111111 const taxpayerDetails = await arca.registerScopeTenService.getTaxpayerDetails(20111111111); if (taxpayerDetails) { console.log("Datos del contribuyente:", taxpayerDetails); } else { console.log("Contribuyente no encontrado."); } ``` ### Response #### Success Response (200) - **metadata** (object) - Contains server and timestamp information. - **persona** (object) - Contains the taxpayer's personal information. - **idPersona** (number) - The unique identifier for the person. - **tipoPersona** (string) - The type of person (e.g., 'FISICA'). - **estadoClave** (string) - The status of the taxpayer's key (e.g., 'ACTIVO'). - **datosGenerales** (object) - General data about the taxpayer. - **piso** (string) - Floor number of the address. - **departamento** (string) - Apartment or unit number. - **numeroCalle** (number) - Street number. - **codPostal** (string) - Postal code. - **tipoDomicilio** (string) - Type of address (e.g., 'FISCAL'). - **domicilio** (string) - Full street address. #### Response Example ```json { "metadata": { "fechaHora": "2024-01-01T12:00:00.000-03:00", "servidor": "server1" }, "persona": { "idPersona": 20111111111, "tipoPersona": "FISICA", "estadoClave": "ACTIVO", "datosGenerales": { "piso": "1", "departamento": "A", "numeroCalle": 123, "codPostal": "1000", "tipoDomicilio": "FISCAL", "domicilio": "CALLE FALSA 123" } } } ``` ``` -------------------------------- ### Regenerar Vista Previa de Documentación Source: https://github.com/ralcorta/arcasdk/blob/main/docs/packages/pdf.md Ejecuta este comando en la terminal para regenerar la vista previa de la documentación después de realizar cambios en el template del PDF. ```bash npm run generate:docs-demo --workspace=@arcasdk/pdf ``` -------------------------------- ### Respuesta Completa de Creación de Comprobante Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/facturacion_electronica.md Ejemplo de la respuesta JSON recibida después de una llamada exitosa a `createVoucher`, mostrando los campos principales del CAE. ```json { "CAE": "74154876254185", "CAEFchVto": "20240111", "Resultado": "A", "Reproceso": "N", "PtoVta": 1, "CbteTipo": 6 } ``` -------------------------------- ### registerScopeTenService (Padrón A10) Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Provides methods to retrieve taxpayer details from Padrón A10. Includes functions to get the server status and details for a single taxpayer. ```APIDOC ## getServerStatus() ### Description Gets the server status for the Padrón A10 service. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters None ### Request Example ``` await arca.registerScopeTenService.getServerStatus() ``` ### Response #### Success Response (200) - **status** (string) - The status of the server. ``` ```APIDOC ## getTaxpayerDetails(identifier) ### Description Retrieves details for a single taxpayer from Padrón A10 using their identifier. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters #### Path Parameters - **identifier** (string) - Required - The unique identifier of the taxpayer. ### Request Example ``` await arca.registerScopeTenService.getTaxpayerDetails('some-identifier') ``` ### Response #### Success Response (200) - **details** (object) - An object containing the taxpayer's details. ``` -------------------------------- ### registerInscriptionProofService (Constancia) Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Provides methods to retrieve inscription proofs for taxpayers. Includes functions to get server status, a single taxpayer's proof, and multiple proofs in a batch. ```APIDOC ## getServerStatus() ### Description Gets the server status for the Constancia service. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters None ### Request Example ``` await arca.registerInscriptionProofService.getServerStatus() ``` ### Response #### Success Response (200) - **status** (string) - The status of the server. ``` ```APIDOC ## getTaxpayerDetails(identifier) ### Description Retrieves the inscription proof for a single taxpayer using their identifier. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters #### Path Parameters - **identifier** (string) - Required - The unique identifier of the taxpayer. ### Request Example ``` await arca.registerInscriptionProofService.getTaxpayerDetails('some-identifier') ``` ### Response #### Success Response (200) - **proof** (object) - An object containing the taxpayer's inscription proof. ``` ```APIDOC ## getTaxpayersDetails(identifiers) ### Description Retrieves inscription proofs for multiple taxpayers in a batch using a list of identifiers. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters #### Path Parameters - **identifiers** (array) - Required - An array of taxpayer identifiers. ### Request Example ``` await arca.registerInscriptionProofService.getTaxpayersDetails(['id1', 'id2', 'id3']) ``` ### Response #### Success Response (200) - **proofs** (array) - An array of objects, each containing a taxpayer's inscription proof. ``` -------------------------------- ### Uso de WSDL Personalizado Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/generic-service.md Ejemplo de cómo llamar a un servicio ARCA que no está preconfigurado en el SDK, proporcionando el contenido del WSDL manualmente. Requiere leer el archivo WSDL y pasarlo como una opción. ```typescript import { Arca } from "@arcasdk/core"; import * as fs from "fs"; const arca = new Arca({ cuit: 20111111111, cert: "...", key: "...", }); async function callCustomService() { const wsdlContent = fs.readFileSync("./mi-servicio.wsdl", "utf8"); const result = await arca.genericService.call( "mi_alias_wsaa", // debe coincidir con el alias autorizado en WSAA "someMethod", { param1: "value" }, { wsdlContent }, ); console.log(result); } ``` -------------------------------- ### Ejemplo Básico de Creación de Comprobante (Factura B) Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/facturacion_electronica.md Demuestra cómo llamar al método `createVoucher` para generar una Factura B para Consumidor Final, especificando todos los detalles necesarios del comprobante. ```typescript const invoice = await arca.electronicBillingService.createVoucher({ CantReg: 1, PtoVta: 1, CbteTipo: 6, // Factura B Concepto: 1, // Productos DocTipo: 99, // Consumidor Final DocNro: 0, CbteDesde: 1, CbteHasta: 1, CbteFch: "20240101", // String en formato YYYYMMDD ImpTotal: 121, ImpTotConc: 0, ImpNeto: 100, ImpOpEx: 0, ImpIVA: 21, ImpTrib: 0, MonId: "PES", MonCotiz: 1, Iva: [ { Id: 5, // 21% BaseImp: 100, Importe: 21, }, ], }); ``` -------------------------------- ### registerScopeThirteenService (Padrón A13) Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Provides methods to retrieve taxpayer details and CUIT from Padrón A13. Includes functions to get server status, single taxpayer details, and CUIT by document number. ```APIDOC ## getServerStatus() ### Description Gets the server status for the Padrón A13 service. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters None ### Request Example ``` await arca.registerScopeThirteenService.getServerStatus() ``` ### Response #### Success Response (200) - **status** (string) - The status of the server. ``` ```APIDOC ## getTaxpayerDetails(identifier) ### Description Retrieves details for a single taxpayer from Padrón A13 using their identifier. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters #### Path Parameters - **identifier** (string) - Required - The unique identifier of the taxpayer. ### Request Example ``` await arca.registerScopeThirteenService.getTaxpayerDetails('some-identifier') ``` ### Response #### Success Response (200) - **details** (object) - An object containing the taxpayer's details. ``` ```APIDOC ## getTaxIDByDocument(documentNumber) ### Description Retrieves the CUIT (tax identification number) for a taxpayer given their document number from Padrón A13. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters #### Path Parameters - **documentNumber** (string) - Required - The taxpayer's document number. ### Request Example ``` await arca.registerScopeThirteenService.getTaxIDByDocument('12345678') ``` ### Response #### Success Response (200) - **cuit** (string) - The CUIT of the taxpayer. ``` -------------------------------- ### registerScopeFiveService (Padrón A5) Source: https://github.com/ralcorta/arcasdk/blob/main/docs/referencia-api.md Provides methods to retrieve taxpayer details from Padrón A5. Includes functions to get the server status, details for a single taxpayer, and details for multiple taxpayers in a batch. ```APIDOC ## getServerStatus() ### Description Gets the server status for the Padrón A5 service. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters None ### Request Example ``` await arca.registerScopeFiveService.getServerStatus() ``` ### Response #### Success Response (200) - **status** (string) - The status of the server. ``` ```APIDOC ## getTaxpayerDetails(identifier) ### Description Retrieves details for a single taxpayer from Padrón A5 using their identifier. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters #### Path Parameters - **identifier** (string) - Required - The unique identifier of the taxpayer. ### Request Example ``` await arca.registerScopeFiveService.getTaxpayerDetails('some-identifier') ``` ### Response #### Success Response (200) - **details** (object) - An object containing the taxpayer's details. ``` ```APIDOC ## getTaxpayersDetails(identifiers) ### Description Retrieves details for multiple taxpayers in a batch from Padrón A5 using a list of identifiers. ### Method Not specified (assumed to be part of a client library call) ### Endpoint Not specified ### Parameters #### Path Parameters - **identifiers** (array) - Required - An array of taxpayer identifiers. ### Request Example ``` await arca.registerScopeFiveService.getTaxpayersDetails(['id1', 'id2', 'id3']) ``` ### Response #### Success Response (200) - **details** (array) - An array of objects, each containing a taxpayer's details. ``` -------------------------------- ### Initialize Arca with Credentials Source: https://github.com/ralcorta/arcasdk/blob/main/docs/credential_management.md Instantiate the Arca SDK with pre-generated credentials for manual ticket handling. Ensure `handleTicket` is set to `true` when using this parameter. The `credentials` object should contain `header` and `credentials` properties for authentication. ```typescript const arca = new Arca({ cuit: 20111111112, cert: "...", key: "...", credentials: { // Tipo: ILoginCredentials header: { // Información de autenticación }, credentials: { // Token y firma }, }, handleTicket: true, // Necesario cuando usas credentials }); ``` -------------------------------- ### createNextVoucher Source: https://github.com/ralcorta/arcasdk/blob/main/docs/services/facturacion_electronica.md Crea el siguiente comprobante automáticamente combinando la obtención del último comprobante y su creación en un solo paso. No requiere especificar el rango de comprobantes. ```APIDOC ## createNextVoucher ### Description Crea el siguiente comprobante automáticamente combinando la obtención del último comprobante y su creación en un solo paso. No requiere especificar el rango de comprobantes. ### Method `createNextVoucher` ### Parameters #### Request Body - **CantReg** (number) - Required - Cantidad de registros. - **PtoVta** (number) - Required - Punto de venta. - **CbteTipo** (number) - Required - Tipo de comprobante. - **Concepto** (number) - Required - Concepto del comprobante. - **DocTipo** (number) - Required - Tipo de documento del receptor. - **DocNro** (number) - Required - Número de documento del receptor. - **CbteFch** (string) - Required - Fecha del comprobante en formato YYYYMMDD. - **ImpTotal** (number) - Required - Importe total del comprobante. - **ImpTotConc** (number) - Required - Importe total de conceptos no facturables. - **ImpNeto** (number) - Required - Importe neto del comprobante. - **ImpOpEx** (number) - Required - Importe de operacionesexentas. - **ImpIVA** (number) - Required - Importe total de IVA. - **ImpTrib** (number) - Required - Importe total de tributos. - **MonId** (string) - Required - Identificador de la moneda. - **MonCotiz** (number) - Required - Cotización de la moneda. - **Iva** (array) - Required - Array de alícuotas de IVA. - **Id** (number) - Required - ID de la alícuota. - **BaseImp** (number) - Required - Base imponible. - **Importe** (number) - Required - Importe del IVA. ### Request Example ```json { "CantReg": 1, "PtoVta": 1, "CbteTipo": 6, "Concepto": 1, "DocTipo": 99, "DocNro": 0, "CbteFch": "20240501", "ImpTotal": 121, "ImpTotConc": 0, "ImpNeto": 100, "ImpOpEx": 0, "ImpIVA": 21, "ImpTrib": 0, "MonId": "PES", "MonCotiz": 1, "Iva": [ { "Id": 5, "BaseImp": 100, "Importe": 21 } ] } ``` ### Response #### Success Response (200) - **invoice** (object) - Datos del comprobante creado. ```