arca.rb 1.0.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 (131) hide show
  1. checksums.yaml +7 -0
  2. data/.devcontainer/Dockerfile +8 -0
  3. data/.devcontainer/devcontainer.json +12 -0
  4. data/.github/dependabot.yml +12 -0
  5. data/.github/workflows/ci.yml +16 -0
  6. data/.github/workflows/release.yml +37 -0
  7. data/.gitignore +8 -0
  8. data/.mise.toml +2 -0
  9. data/.rubocop.yml +8 -0
  10. data/.ruby-version +1 -0
  11. data/CHANGELOG.md +19 -0
  12. data/CONTRIBUTING.md +48 -0
  13. data/Gemfile +4 -0
  14. data/LICENSE +22 -0
  15. data/README.md +209 -0
  16. data/Rakefile +10 -0
  17. data/SECURITY.md +14 -0
  18. data/arca.gemspec +40 -0
  19. data/bin/console +7 -0
  20. data/lib/arca/client.rb +29 -0
  21. data/lib/arca/core_ext/hash.rb +13 -0
  22. data/lib/arca/errors/error.rb +13 -0
  23. data/lib/arca/errors/network_error.rb +15 -0
  24. data/lib/arca/errors/response_error.rb +18 -0
  25. data/lib/arca/errors/server_error.rb +6 -0
  26. data/lib/arca/persona_service_a100.rb +51 -0
  27. data/lib/arca/persona_service_a4.rb +34 -0
  28. data/lib/arca/persona_service_a5.rb +46 -0
  29. data/lib/arca/type_conversions.rb +44 -0
  30. data/lib/arca/version.rb +5 -0
  31. data/lib/arca/w_cons_declaracion.rb +66 -0
  32. data/lib/arca/ws_constancia_inscripcion.rb +34 -0
  33. data/lib/arca/wsaa.rb +140 -0
  34. data/lib/arca/wscdc.rb +149 -0
  35. data/lib/arca/wsfe.rb +205 -0
  36. data/lib/arca/wsfecred.rb +438 -0
  37. data/lib/arca/wsrgiva.rb +72 -0
  38. data/lib/arca.rb +31 -0
  39. data/test/arca/client_test.rb +43 -0
  40. data/test/arca/core_ext/hash_test.rb +15 -0
  41. data/test/arca/persona_service_a100_test.rb +45 -0
  42. data/test/arca/persona_service_a4_test.rb +31 -0
  43. data/test/arca/persona_service_a5_test.rb +31 -0
  44. data/test/arca/test.crt +19 -0
  45. data/test/arca/test.key +28 -0
  46. data/test/arca/type_conversions_test.rb +43 -0
  47. data/test/arca/w_cons_declaracion_test.rb +86 -0
  48. data/test/arca/ws_constancia_inscripcion_test.rb +87 -0
  49. data/test/arca/wsaa_test.rb +80 -0
  50. data/test/arca/wscdc_test.rb +103 -0
  51. data/test/arca/wsfe_test.rb +319 -0
  52. data/test/arca/wsfecred_test.rb +162 -0
  53. data/test/arca/wsrgiva_test.rb +91 -0
  54. data/test/fixtures/wconsdeclaracion/detallada_estado/success.xml +24 -0
  55. data/test/fixtures/wconsdeclaracion/detallada_lista_declaraciones/por_fecha_success.xml +39 -0
  56. data/test/fixtures/wconsdeclaracion/detallada_lista_declaraciones/por_id_inexistente.xml +16 -0
  57. data/test/fixtures/wconsdeclaracion/detallada_lista_declaraciones/por_id_success.xml +29 -0
  58. data/test/fixtures/wconsdeclaracion/dummy/success.xml +12 -0
  59. data/test/fixtures/wconsdeclaracion/wconsdeclaracion.wsdl +2976 -0
  60. data/test/fixtures/ws_sr_constancia_inscripcion/dummy/success.xml +11 -0
  61. data/test/fixtures/ws_sr_constancia_inscripcion/get_persona/failure.xml +35 -0
  62. data/test/fixtures/ws_sr_constancia_inscripcion/get_persona/fault.xml +8 -0
  63. data/test/fixtures/ws_sr_constancia_inscripcion/get_persona/success.xml +53 -0
  64. data/test/fixtures/ws_sr_constancia_inscripcion/ws_constancia_inscripcion.wsdl +230 -0
  65. data/test/fixtures/ws_sr_padron_a100/company_types/success.xml +23 -0
  66. data/test/fixtures/ws_sr_padron_a100/dummy/success.xml +11 -0
  67. data/test/fixtures/ws_sr_padron_a100/jurisdictions/success.xml +31 -0
  68. data/test/fixtures/ws_sr_padron_a100/public_organisms/success.xml +23 -0
  69. data/test/fixtures/ws_sr_padron_a100.wsdl +125 -0
  70. data/test/fixtures/ws_sr_padron_a4/dummy/success.xml +11 -0
  71. data/test/fixtures/ws_sr_padron_a4/get_persona/success.xml +133 -0
  72. data/test/fixtures/ws_sr_padron_a4.wsdl +229 -0
  73. data/test/fixtures/ws_sr_padron_a5/dummy/success.xml +11 -0
  74. data/test/fixtures/ws_sr_padron_a5/get_persona/success.xml +62 -0
  75. data/test/fixtures/ws_sr_padron_a5.wsdl +283 -0
  76. data/test/fixtures/wsaa/login_cms/fault.xml +12 -0
  77. data/test/fixtures/wsaa/login_cms/success.xml +16 -0
  78. data/test/fixtures/wsaa/login_cms/token_expirado.xml +14 -0
  79. data/test/fixtures/wsaa/wsaa.wsdl +103 -0
  80. data/test/fixtures/wscdc/comprobante_constatar/success.xml +22 -0
  81. data/test/fixtures/wscdc/comprobante_constatar/with_errors.xml +28 -0
  82. data/test/fixtures/wscdc/comprobante_dummy/success.xml +11 -0
  83. data/test/fixtures/wscdc/comprobantes_modalidad_consultar/success.xml +22 -0
  84. data/test/fixtures/wscdc/comprobantes_tipo_consultar/success.xml +22 -0
  85. data/test/fixtures/wscdc/documentos_tipo_consultar/success.xml +16 -0
  86. data/test/fixtures/wscdc/opcionales_tipo_consultar/success.xml +14 -0
  87. data/test/fixtures/wscdc/wscdc.wsdl +305 -0
  88. data/test/fixtures/wsfe/fe_comp_consultar/success.xml +41 -0
  89. data/test/fixtures/wsfe/fe_comp_tot_x_request/success.xml +9 -0
  90. data/test/fixtures/wsfe/fe_comp_ultimo_autorizado/success.xml +11 -0
  91. data/test/fixtures/wsfe/fe_dummy/success.xml +11 -0
  92. data/test/fixtures/wsfe/fe_param_get_cotizacion/dolar.xml +13 -0
  93. data/test/fixtures/wsfe/fe_param_get_cotizacion/inexistente.xml +14 -0
  94. data/test/fixtures/wsfe/fe_param_get_ptos_venta/success.xml +22 -0
  95. data/test/fixtures/wsfe/fe_param_get_tipos_cbte/failure_1_error.xml +14 -0
  96. data/test/fixtures/wsfe/fe_param_get_tipos_cbte/failure_2_errors.xml +18 -0
  97. data/test/fixtures/wsfe/fe_param_get_tipos_cbte/success.xml +22 -0
  98. data/test/fixtures/wsfe/fe_param_get_tipos_concepto/success.xml +17 -0
  99. data/test/fixtures/wsfe/fe_param_get_tipos_doc/success.xml +16 -0
  100. data/test/fixtures/wsfe/fe_param_get_tipos_iva/success.xml +16 -0
  101. data/test/fixtures/wsfe/fe_param_get_tipos_monedas/success.xml +22 -0
  102. data/test/fixtures/wsfe/fe_param_get_tipos_opcional/success.xml +16 -0
  103. data/test/fixtures/wsfe/fe_param_get_tipos_tributos/success.xml +16 -0
  104. data/test/fixtures/wsfe/fecae_solicitar/autorizacion_1_cbte.xml +30 -0
  105. data/test/fixtures/wsfe/fecae_solicitar/autorizacion_2_cbtes.xml +41 -0
  106. data/test/fixtures/wsfe/fecae_solicitar/dos_observaciones.xml +40 -0
  107. data/test/fixtures/wsfe/fecae_solicitar/una_observacion.xml +36 -0
  108. data/test/fixtures/wsfe/fecaea_consultar/success.xml +17 -0
  109. data/test/fixtures/wsfe/fecaea_reg_informativo/informe_rtdo_parcial.xml +45 -0
  110. data/test/fixtures/wsfe/fecaea_sin_movimiento_informar/success.xml +12 -0
  111. data/test/fixtures/wsfe/fecaea_solicitar/caea_ya_otorgado.xml +18 -0
  112. data/test/fixtures/wsfe/fecaea_solicitar/error_distinto.xml +18 -0
  113. data/test/fixtures/wsfe/fecaea_solicitar/success.xml +17 -0
  114. data/test/fixtures/wsfe/wsfe.wsdl +1372 -0
  115. data/test/fixtures/wsfecred/aceptar_f_e_cred/success.xml +14 -0
  116. data/test/fixtures/wsfecred/consultar_comprobantes/success.xml +17 -0
  117. data/test/fixtures/wsfecred/consultar_cta_cte/success.xml +13 -0
  118. data/test/fixtures/wsfecred/consultar_ctas_ctes/success.xml +16 -0
  119. data/test/fixtures/wsfecred/consultar_tipos_formas_cancelacion/success.xml +14 -0
  120. data/test/fixtures/wsfecred/consultar_tipos_motivos_rechazo/success.xml +14 -0
  121. data/test/fixtures/wsfecred/consultar_tipos_retenciones/failure.xml +14 -0
  122. data/test/fixtures/wsfecred/consultar_tipos_retenciones/success.xml +14 -0
  123. data/test/fixtures/wsfecred/dummy/success.xml +11 -0
  124. data/test/fixtures/wsfecred/wsfecred.wsdl +147 -0
  125. data/test/fixtures/wsrgiva/consultar_constancia_por_lote/one_error.xml +14 -0
  126. data/test/fixtures/wsrgiva/consultar_constancia_por_lote/success.xml +26 -0
  127. data/test/fixtures/wsrgiva/dummy/success.xml +11 -0
  128. data/test/fixtures/wsrgiva/wsrgiva.wsdl +118 -0
  129. data/test/support/savon_extensions.rb +43 -0
  130. data/test/test_helper.rb +44 -0
  131. metadata +319 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d9ec9a0d7ce9c36571a98f68101f9d64b2957c7b0b4102e42870ac48178735e0
4
+ data.tar.gz: d0c45d34625ca35615e333d1d68622f136914311c9377375e6a3a0c383801e83
5
+ SHA512:
6
+ metadata.gz: cd47f11cd3f4465fa1c38f1a1d511a5d29ebb79e371421b48c7244f51b00d4d898e859ddedf0861d536f30035cfd9ba5f27b729635b266a60097a971a366a9d8
7
+ data.tar.gz: d5cdf8bfc5b2f1d9de87b382364e70ce1f14ec2b54008914e591ec06d4858cad76f5df86fbd001ba425390c43794a7dcdc0856783d0671fcd9bef6148f5d22fd
@@ -0,0 +1,8 @@
1
+ # Matches .ruby-version
2
+ ARG RUBY_VERSION=3.4.7
3
+ FROM ruby:${RUBY_VERSION}
4
+
5
+ # postCreateCommand runs "bundle install && rake"
6
+ RUN gem install bundler
7
+
8
+ ENV BINDING="0.0.0.0"
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "arca",
3
+ "build": {
4
+ "dockerfile": "Dockerfile",
5
+ "context": "..",
6
+ "args": { "RUBY_VERSION": "3.4.7" }
7
+ },
8
+ "features": {
9
+ "ghcr.io/devcontainers/features/github-cli:1": {}
10
+ },
11
+ "postCreateCommand": "bundle install && rake"
12
+ }
@@ -0,0 +1,12 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for more information:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+ # https://containers.dev/guide/dependabot
6
+
7
+ version: 2
8
+ updates:
9
+ - package-ecosystem: "devcontainers"
10
+ directory: "/"
11
+ schedule:
12
+ interval: weekly
@@ -0,0 +1,16 @@
1
+ name: CI
2
+ on: push
3
+ jobs:
4
+ test:
5
+ runs-on: ubuntu-latest
6
+ env:
7
+ BUNDLE_FROZEN: false
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version-file: .ruby-version
14
+ bundler-cache: true
15
+ - name: Run tests
16
+ run: bundle exec rake
@@ -0,0 +1,37 @@
1
+ # Publish to RubyGems using the official release-gem action (Trusted Publishing).
2
+ # Run this workflow manually after bumping version and pushing to main. Tests run first.
3
+ name: Release
4
+ on:
5
+ workflow_dispatch:
6
+ jobs:
7
+ release:
8
+ name: Test and push gem to RubyGems.org
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ BUNDLE_FROZEN: false
12
+ permissions:
13
+ id-token: write # required for RubyGems Trusted Publishing
14
+ contents: write # required for rake release to push the release tag
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ with:
18
+ persist-credentials: false
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version-file: .ruby-version
23
+ bundler-cache: true
24
+ - name: Run tests
25
+ run: bundle exec rake
26
+ - name: Publish to RubyGems.org
27
+ uses: rubygems/release-gem@v1
28
+ - name: Set release tag
29
+ id: tag
30
+ run: echo "tag=v$(ruby -e "require './lib/arca/version'; puts Arca::VERSION")" >> $GITHUB_OUTPUT
31
+ - name: Create GitHub Release
32
+ uses: softprops/action-gh-release@v2
33
+ with:
34
+ tag_name: ${{ steps.tag.outputs.tag }}
35
+ files: pkg/arca-*.gem
36
+ body_path: CHANGELOG.md
37
+ generate_release_notes: false
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ pkg/*
2
+ *.gem
3
+ Gemfile.lock
4
+ .bundle
5
+ .DS_Store
6
+ tmp
7
+ /.direnv
8
+ /keys
data/.mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [settings]
2
+ idiomatic_version_file_enable_tools = ["ruby"]
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ # Omakase Ruby styling for Rails
2
+ inherit_gem: { rubocop-rails-omakase: rubocop.yml }
3
+
4
+ # Overwrite or add rules to create your own house style
5
+ #
6
+ # # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
7
+ # Layout/SpaceInsideArrayLiteralBrackets:
8
+ # Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.7
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # Arca Changelog
2
+
3
+ ## [1.0.0] - 2025-01-31
4
+
5
+ - Primer release.
6
+ - Cliente Ruby para webservices de ARCA. Requiere Ruby >= 3.4.4.
7
+
8
+ ### Servicios / clientes
9
+
10
+ - **WSAA** — Autenticación. TA (token/sign) cacheado como JSON; path del archivo TA sanitizado; ambientes development / production / test.
11
+ - **WSFE** — Factura Electrónica: dummy, tipos (comprobantes, documentos, monedas, IVA, tributos, etc.), puntos_venta, cotizacion, autorizar_comprobantes, CAE/CAEA (solicitar, consultar, informar, sin movimiento).
12
+ - **WSConstanciaInscripcion** — Constancia de inscripción (padrón).
13
+ - **PersonaServiceA4** — Padrón A4 (get_persona).
14
+ - **PersonaServiceA5** — Padrón A5 (get_persona, get_persona_list).
15
+ - **PersonaServiceA100** — Padrón A100 (dummy, jurisdictions, company_types, public_organisms).
16
+ - **WConsDeclaracion** — Declaraciones (tipo_agente, rol; detallada_lista_declaraciones, detallada_estado).
17
+ - **WSFeCred** — Factura Electrónica de Crédito MiPyMEs (FECredService): dummy, aceptar_f_e_cred, rechazar_f_e_cred, rechazar_nota_dc, informar_factura_agt_dpto_cltv, informar_cancelacion_total_f_e_cred, modificar_opcion_transferencia, consultar_comprobantes, consultar_ctas_ctes, consultar_cta_cte, consultar_cuentas_en_agt_dpto_cltv, consultar_monto_obligado_recepcion, consultar_tipos_retenciones, consultar_tipos_motivos_rechazo, consultar_facturas_agt_dpto_cltv, consultar_tipos_formas_cancelacion, obtener_remitos, consultar_historial_estados_comprobante, consultar_historial_estados_cta_cte, consultar_tipos_ajustes_operacion.
18
+ - **WSCDC** — Constatación de Comprobantes.
19
+ - **WSRgIVA** — RG IVA.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,48 @@
1
+ # Contributing to Arca
2
+
3
+ ## Getting up and running
4
+
5
+ - Clone this repository
6
+ - `bundle install`
7
+ - `bundle exec rake test` (or `bundle exec rake`), which runs the full test suite
8
+
9
+ Optional: run RuboCop with `bundle exec rubocop` if you have it; the project uses `.rubocop.yml` for style.
10
+
11
+ ## Test setup
12
+
13
+ Tests live under `test/` with `*_test.rb` files. Most examples use stubbed SOAP responses; fixtures (WSDL and XML responses) are under `test/fixtures/` per service (e.g. `test/fixtures/wsaa/`, `test/fixtures/wsfe/`). Use `env: :test` in constructors so the client loads the local WSDL and tests don’t hit real endpoints.
14
+
15
+ ## Running tests
16
+
17
+ - Full suite: `bundle exec rake test` or `bundle exec rake`
18
+ - Single file: `ruby -Ilib -Itest test/arca/wsfe_test.rb`
19
+ - Or run one file via Rake: `bundle exec rake test TEST=test/arca/wsfe_test.rb`
20
+
21
+ ## Pushing to GitHub and CI
22
+
23
+ - Push your branch: `git push origin main` (or your branch name).
24
+ - **CI** (`.github/workflows/ci.yml`) runs on every push: it installs dependencies and runs `bundle exec rake` (tests). Ensure tests pass before releasing.
25
+ - View runs: **Actions** tab at https://github.com/arcakit/arca.rb/actions.
26
+
27
+ ## Publishing to RubyGems via CI
28
+
29
+ Releases use the official [rubygems/release-gem](https://github.com/rubygems/release-gem) action with **Trusted Publishing** (no API key secrets). The workflow runs tests, then runs `rake release` (build, push gem, create and push the version tag).
30
+
31
+ ### One-time setup: Trusted Publishing
32
+
33
+ 1. On RubyGems.org: log in → your gem **arca** → **Publishing** (or **Edit gem**) → add a **Trusted publisher**.
34
+ 2. Choose **GitHub Actions** and link this repo: `arcakit/arca.rb` (or your fork). Follow [RubyGems: Adding a publisher](https://guides.rubygems.org/trusted-publishing/adding-a-publisher/).
35
+ 3. No GitHub secrets are needed; the action uses OIDC to authenticate to RubyGems.
36
+
37
+ ### Release steps
38
+
39
+ - **Prechecks**
40
+ - [ ] CI is green on the branch you're releasing from.
41
+ - [ ] Update `CHANGELOG.md` and `lib/arca/version.rb` (e.g. `1.0.1`).
42
+ - [ ] Commit and push: `git add -A && git commit -m "Release 1.0.1" && git push`.
43
+ - **Run the Release workflow**
44
+ - [ ] Open **Actions** → **Release** → **Run workflow**. Select the branch (e.g. `main`) and run.
45
+ - [ ] The workflow runs tests, then [rubygems/release-gem](https://github.com/rubygems/release-gem) runs `rake release`: builds the gem, pushes to RubyGems.org, and creates/pushes the tag (e.g. `v1.0.1`).
46
+ - **After publish**
47
+ - [ ] Create a GitHub release at https://github.com/arcakit/arca.rb/releases (optional; tag is already pushed).
48
+ - [ ] Bump `lib/arca/version.rb` to a prerelease if you use one (e.g. `1.0.2.dev`).
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in arca.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2025 ARCA Kit
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # Arca.rb
2
+
3
+ Cliente Ruby para integrar webservices SOAP de AFIP y ARCA en Argentina. Soporta facturación electrónica (WSFE), factura electrónica de crédito MiPyMEs (WSFeCred), autenticación WSAA, consulta de padrón de contribuyentes, constatación de comprobantes fiscales y todos los servicios tributarios de la API de AFIP. Ideal para aplicaciones Rails que necesitan generar facturas electrónicas y comprobantes en Argentina.
4
+
5
+ [![CI](https://github.com/arcakit/arca.rb/actions/workflows/ci.yml/badge.svg)](https://github.com/arcakit/arca.rb/actions/workflows/ci.yml)
6
+
7
+ ## Características
8
+
9
+ - **Facturación Electrónica (WSFE)** - Generá facturas, notas de crédito y débito
10
+ - **Factura Electrónica de Crédito MiPyMEs (WSFeCred)** - FEC para PyMEs
11
+ - **Comprobantes AFIP** - Acceso completo a todos los webservices ARCA
12
+ - **SOAP simplificado** - API Ruby idiomática sobre los servicios SOAP de AFIP
13
+ - **Autenticación WSAA** - Manejo automático de tokens y certificados
14
+ - **Producción y homologación** - Ambientes configurables
15
+ - **Padrón AFIP** - Consulta de contribuyentes (A4, A5, A100)
16
+
17
+ ## Requisitos
18
+
19
+ - Ruby >= 3.3.4
20
+ - Clave privada y certificado de ARCA/AFIP: seguí los [pasos para solicitar certificado](http://www.afip.gov.ar/ws/WSAA/cert-req-howto.txt)
21
+
22
+ ## Instalación
23
+
24
+ Agregá a tu Gemfile:
25
+ ```ruby
26
+ gem 'arca.rb'
27
+ ```
28
+
29
+ Ejecutá `bundle install`. O instalá directamente: `gem install arca.rb`.
30
+
31
+ ## Inicio rápido
32
+
33
+ 1. **Obtené certificado y clave** de ARCA/AFIP (ver link arriba). Vas a tener un `.crt` (certificado) y una clave privada (`.key` o `.pem`).
34
+
35
+ 2. **Instalá la ** y requerila:
36
+ ```ruby
37
+ require 'arca'
38
+ ```
39
+
40
+ 3. **Elegí el ambiente**: usá `:development` (homologación) para testing, `:production` para operaciones reales.
41
+
42
+ 4. **Creá un cliente** con tu CUIT, clave y certificado, después llamá al servicio:
43
+ ```ruby
44
+ ws = Arca::WSFE.new(
45
+ env: :development,
46
+ cuit: '20123456789',
47
+ key: File.read('ruta/a/clave-privada.key'),
48
+ cert: File.read('ruta/a/certificado.crt')
49
+ )
50
+ puts ws.cotizacion('DOL') # cotización dólar
51
+ ```
52
+
53
+ ## Ambientes
54
+
55
+ | `env` | Uso |
56
+ |-------|-----|
57
+ | `:test` | Solo WSDL/fixtures locales (para tests). Sin llamadas de red. |
58
+ | `:development` | Homologación — servidores de prueba de AFIP. Usá para testing de integración. |
59
+ | `:production` | Producción — endpoints reales de AFIP. |
60
+
61
+ Opción del constructor: `env: :development` o `env: :production` (symbol o string). Por defecto es `:test`.
62
+
63
+ ## Servicios disponibles
64
+
65
+ | Servicio (WSDL) | Clase | Descripción |
66
+ |----------------|-------|-------------|
67
+ | WSAA | `Arca::WSAA` | Autenticación y autorización |
68
+ | WSFE | `Arca::WSFE` | Facturación electrónica |
69
+ | WSFeCred | `Arca::WSFeCred` | Factura electrónica de crédito MiPyMEs |
70
+ | WSCDC | `Arca::WSCDC` | Constatación de comprobantes |
71
+ | WSRGIVA | `Arca::WSRGIVA` | Régimen percepción IVA |
72
+ | WS Constancia Inscripción | `Arca::WSConstanciaInscripcion` | Constancia de inscripción |
73
+ | Padrón A4 / A5 / A100 | `Arca::PersonaServiceA4`, `PersonaServiceA5`, `PersonaServiceA100` | Consulta padrón de contribuyentes |
74
+ | WConsDeclaracion | `Arca::WConsDeclaracion` | Declaraciones aduaneras |
75
+
76
+ ## Uso
77
+
78
+ Opciones comunes del constructor: `env`, `cuit`, `key`, `cert`. Opcionales: `savon` (hash pasado a Savon), `ta_path` (WSAA), etc.
79
+
80
+ ### Cliente de bajo nivel (`Arca::Client`)
81
+
82
+ `Arca::Client` es el cliente SOAP base que envuelve [Savon](https://github.com/savonrb/savon). Las clases de servicio de alto nivel (WSFE, WSAA, etc.) se construyen sobre este. Podés usarlo directamente para WSDLs custom o llamadas SOAP raw.
83
+
84
+ **Constructor:** `Arca::Client.new(savon_options)` — acepta cualquier [opción de cliente Savon](https://www.savonrb.com/version2/globals.html). Las opciones se combinan con estos defaults (necesarios para AFIP/ARCA):
85
+
86
+ | Opción | Default | Propósito |
87
+ |---------------|----------------------|-----------|
88
+ | `soap_version`| `2` | SOAP 1.2 |
89
+ | `ssl_version` | `:TLSv1_2` | TLS 1.2 para AFIP |
90
+ | `ssl_ciphers` | `'DEFAULT:!DH:!DHE'` | Excluye ciphers DH/DHE para evitar "dh key too small" con ARCA (OpenSSL 1.1.1+ SECLEVEL=2 rechaza claves DH pequeñas). |
91
+
92
+ **Métodos:**
93
+
94
+ - **`request(action, body = nil)`** — Envía un request SOAP para la `action` dada con `body` opcional. Levanta `Arca::ServerError` en errores SOAP/HTTP, `Arca::NetworkError` en timeouts (connect timeouts se marcan `retriable: true`).
95
+ - **`operations`** — Delegado al cliente Savon; devuelve la lista de operaciones SOAP disponibles del WSDL.
96
+
97
+ Ejemplo (WSDL custom):
98
+ ```ruby
99
+ client = Arca::Client.new(
100
+ wsdl: 'https://example.afip.gov.ar/ws/MiServicio?wsdl',
101
+ wsse_auth: ['ruta/a/cert.crt', 'ruta/a/key.pem']
102
+ )
103
+ client.operations # => lista de operaciones
104
+ response = client.request(:mi_operacion, { key: 'valor' })
105
+ ```
106
+
107
+ ### WSAA (autenticación)
108
+
109
+ Token y sign son usados internamente por otros servicios; podés llamar WSAA directamente si lo necesitás:
110
+ ```ruby
111
+ wsaa = Arca::WSAA.new(env: :development, cuit: '20123456789', key: key, cert: cert)
112
+ auth = wsaa.auth # => { token: '...', sign: '...' }
113
+ ```
114
+
115
+ ### WSFE (Factura Electrónica)
116
+ ```ruby
117
+ ws = Arca::WSFE.new(env: :development, cuit: '20123456789', key: key, cert: cert)
118
+ ws.dummy # verificación de conectividad
119
+ ws.cotizacion('DOL') # cotización moneda
120
+ ws.tipos_comprobantes # tipos de comprobante
121
+ ws.ptos_venta # puntos de venta
122
+ # ... fe_comp_ultimo_autorizado, fecae_solicitar, etc.
123
+ ```
124
+
125
+ ### WSFeCred (Factura Electrónica de Crédito MiPyMEs)
126
+ ```ruby
127
+ ws = Arca::WSFeCred.new(env: :development, cuit: '20123456789', key: key, cert: cert)
128
+ ws.dummy
129
+ ws.consultar_tipos_retenciones
130
+ ws.consultar_cta_cte(id_cta_cte)
131
+ # ... aceptar_f_e_cred, rechazar_f_e_cred, etc.
132
+ ```
133
+
134
+ ### WSCDC (Constatación de Comprobantes)
135
+ ```ruby
136
+ ws = Arca::WSCDC.new(env: :development, cuit: '20123456789', key: key, cert: cert)
137
+ ws.dummy
138
+ ws.comprobante_constatar(
139
+ cbte_modo: 1,
140
+ cuit_emisor: '...',
141
+ pto_vta: 1,
142
+ cbte_tipo: 1,
143
+ cbte_nro: 1,
144
+ cbte_fch: '20250101',
145
+ imp_total: 100.0,
146
+ cod_autorizacion: '...'
147
+ )
148
+ ```
149
+
150
+ ### WSRGIVA (Régimen Percepción IVA)
151
+ ```ruby
152
+ ws = Arca::WSRGIVA.new(env: :development, cuit: '20123456789', key: key, cert: cert)
153
+ ws.dummy
154
+ ws.consultar_constancia_por_lote(['20123456789', '20999888777'])
155
+ ```
156
+
157
+ ### Padrón (PersonaService A4 / A5 / A100)
158
+ ```ruby
159
+ # Padrón A5
160
+ padron = Arca::PersonaServiceA5.new(env: :development, cuit: '20123456789', key: key, cert: cert)
161
+ padron.get_persona('20123456789')
162
+ # A4: PersonaServiceA4, A100: PersonaServiceA100 (tipos de sociedad, jurisdicciones, etc.)
163
+ ```
164
+
165
+ ### WS Constancia Inscripción
166
+ ```ruby
167
+ ws = Arca::WSConstanciaInscripcion.new(env: :development, cuit: '20123456789', key: key, cert: cert)
168
+ ws.get_persona('20123456789')
169
+ ```
170
+
171
+ ### WConsDeclaracion (Declaraciones aduaneras)
172
+ ```ruby
173
+ ws = Arca::WConsDeclaracion.new(cuit: '20123456789', key: key, cert: cert, env: :development)
174
+ ws.dummy
175
+ ws.detallada_lista_declaraciones(fecha_oficializacion_desde: Date.new(2025, 1, 1))
176
+ ws.detallada_estado('identificador')
177
+ ```
178
+
179
+ Mirá `test/` para más ejemplos.
180
+
181
+ ## ¿Necesitás algo más simple?
182
+
183
+ Si preferís una API REST en lugar de trabajar directamente con SOAP, probá **[Arca Kit](https://arcakit.dev)** — nuestro servicio hosteado (y también de código abierto y libre para te lo instales donde quieras) que cubre todos los webservices de AFIP con una API facilonga, webhooks y multi tenancy.
184
+
185
+ ## Desarrollo
186
+
187
+ Usá el [devcontainer](.devcontainer/devcontainer.json): abrí este repo en tu IDE y elegí **Reopen in Container**. El container ejecuta `bundle install` y el test suite después de crearse.
188
+
189
+ Después ejecutá los tests:
190
+ ```bash
191
+ bundle exec rake test
192
+ ```
193
+
194
+ O `bundle exec rake` (la task default ejecuta tests).
195
+
196
+ **CI:** cada push corre tests en GitHub Actions. Para publicar en RubyGems se usa el action oficial [rubygems/release-gem](https://github.com/rubygems/release-gem) con Trusted Publishing; ver [CONTRIBUTING.md](CONTRIBUTING.md#publishing-to-rubygems-via-ci) para los pasos.
197
+
198
+ ## Reportar bugs o solicitar features
199
+
200
+ Si encontrás un bug o tenés una sugerencia para mejorar `arca.rb`, por favor [abrí un issue](https://github.com/arcakit/arca.rb/issues) en GitHub. Tu feedback nos ayuda a mejorar la gema para toda la comunidad.
201
+
202
+ ## Licencia
203
+ ARCA usa licencia MIT.
204
+
205
+ ## Créditos
206
+
207
+ Versión original de esta gem: https://github.com/eeng/afipws/
208
+
209
+ ---
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ require 'rake/testtask'
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'lib' << 'test'
8
+ t.test_files = FileList['test/**/*_test.rb']
9
+ end
10
+ task default: :test
data/SECURITY.md ADDED
@@ -0,0 +1,14 @@
1
+ # Reporting a Vulnerability
2
+
3
+ If you come across any security concern or vulnerability, please report the information via email to security@arcakit.com instead of opening a GitHub issue. We will promptly respond and will collaborate with you to validate the issue, and resolve it ASAP.
4
+
5
+ **We have a bug bounty program to reward security researchers.**
6
+
7
+ Out of scope vulnerabilities:
8
+
9
+ - CSRF
10
+ - DNSSEC, CAA, CSP headers
11
+ - DNS or email security related
12
+ - Rate Limiting
13
+
14
+ Note: We reserve the right to classify any reported vulnerability as out of scope for the bug bounty program.
data/arca.gemspec ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+ require 'arca/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'arca.rb'
8
+ s.version = Arca::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.required_ruby_version = '>= 3.3.4'
11
+ s.authors = [ 'Arca Kit' ]
12
+ s.email = [ 'hola@arcakit.dev' ]
13
+ s.homepage = 'https://arcakit.dev'
14
+ s.summary = 'Cliente Ruby para webservices de AFIP/ARCA: facturación electrónica, comprobantes y servicios tributarios de Argentina'
15
+ s.description = 'Cliente Ruby para integrar webservices SOAP de ARCA/AFIPen Argentina. Soporta facturación electrónica (WSFE), factura electrónica de crédito MiPyMEs (WSFeCred), autenticación WSAA, consulta de padrón de contribuyentes, constatación de comprobantes fiscales y todos los servicios tributarios de la API de AFIP. Ideal para aplicaciones Rails que necesitan generar facturas electrónicas y comprobantes en Argentina.'
16
+ s.license = 'MIT'
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
+ s.require_paths = [ 'lib' ]
21
+
22
+ s.metadata = {
23
+ 'source_code_uri' => 'https://github.com/arcakit/arca.rb',
24
+ 'bug_tracker_uri' => 'https://github.com/arcakit/arca.rb/issues',
25
+ 'changelog_uri' => 'https://github.com/arcakit/arca.rb/blob/main/CHANGELOG.md',
26
+ 'rubygems_mfa_required' => 'true'
27
+ }
28
+
29
+ s.add_development_dependency 'minitest'
30
+ s.add_development_dependency 'mocha'
31
+ s.add_development_dependency 'pry'
32
+ s.add_development_dependency 'rake'
33
+ s.add_development_dependency 'rubocop-rails-omakase'
34
+
35
+ s.add_dependency 'activesupport'
36
+ s.add_dependency 'builder'
37
+ s.add_dependency 'httpclient'
38
+ s.add_dependency 'nokogiri'
39
+ s.add_dependency 'savon', '~> 2.15.0'
40
+ end
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'arca'
5
+
6
+ require 'pry'
7
+ Pry.start
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arca
4
+ class Client
5
+ def initialize(savon_options)
6
+ savon_opts = savon_options.reverse_merge(
7
+ soap_version: 2,
8
+ ssl_version: :TLSv1_2,
9
+ ssl_ciphers: "DEFAULT:!DH:!DHE",
10
+ # This will load the CA certificates from the system's certificate store.
11
+ ssl_ca_cert_file: "/etc/ssl/certs/ca-certificates.crt"
12
+ )
13
+
14
+ @savon = Savon.client savon_opts
15
+ end
16
+
17
+ def request(action, body = nil)
18
+ @savon.call action, message: body
19
+ rescue Savon::SOAPFault, Savon::HTTPError => e
20
+ raise ServerError, e
21
+ rescue HTTPClient::ConnectTimeoutError => e
22
+ raise NetworkError.new(e, retriable: true)
23
+ rescue HTTPClient::TimeoutError => e
24
+ raise NetworkError, e
25
+ end
26
+
27
+ delegate :operations, to: :@savon
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arca
4
+ module CoreExt
5
+ module Hash
6
+ refine ::Hash do
7
+ def select_keys(*keys)
8
+ slice(*keys)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arca
4
+ class Error < StandardError
5
+ def code?(_code)
6
+ false
7
+ end
8
+
9
+ def retriable?
10
+ false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arca
4
+ class NetworkError < Error
5
+ def initialize(e, retriable: false)
6
+ super(e)
7
+
8
+ @retriable = retriable
9
+ end
10
+
11
+ def retriable?
12
+ @retriable
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arca
4
+ class ResponseError < Error
5
+ attr_reader :errors
6
+
7
+ def initialize(errors)
8
+ raise ArgumentError, "`errors` must be an array of maps, each with :code and :msg keys" unless errors.is_a? Array
9
+
10
+ super(errors.map { |e| "#{e[:code]}: #{e[:msg]}" }.join "; ")
11
+ @errors = errors
12
+ end
13
+
14
+ def code?(code)
15
+ @errors.any? { |e| e[:code].to_s == code.to_s }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arca
4
+ class ServerError < Error
5
+ end
6
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Arca
4
+ class PersonaServiceA100
5
+ WSDL = {
6
+ development: "https://awshomo.afip.gov.ar/sr-parametros/webservices/parameterServiceA100?WSDL",
7
+ production: "https://aws.afip.gov.ar/sr-parametros/webservices/parameterServiceA100?WSDL",
8
+ test: "#{Root}/test/fixtures/ws_sr_padron_a100.wsdl"
9
+ }.freeze
10
+
11
+ attr_reader :wsaa
12
+
13
+ def initialize(options = {})
14
+ @cuit = options[:cuit]
15
+ @wsaa = WSAA.new options.merge(service: "ws_sr_padron_a100")
16
+ @client = Client.new Hash(options[:savon]).reverse_merge(wsdl: WSDL[@wsaa.env], soap_version: 1)
17
+ end
18
+
19
+ def dummy
20
+ request(:dummy)[:return]
21
+ end
22
+
23
+ def jurisdictions
24
+ get_parameter_collection_by_name "SUPA.E_PROVINCIA"
25
+ end
26
+
27
+ def company_types
28
+ get_parameter_collection_by_name "SUPA.TIPO_EMPRESA_JURIDICA"
29
+ end
30
+
31
+ def public_organisms
32
+ get_parameter_collection_by_name "SUPA.E_ORGANISMO_INFORMANTE"
33
+ end
34
+
35
+ private
36
+
37
+ def get_parameter_collection_by_name(type)
38
+ message = {
39
+ token: @wsaa.auth[:token],
40
+ sign: @wsaa.auth[:sign],
41
+ cuitRepresentada: @cuit,
42
+ collectionName: type
43
+ }
44
+ request(:get_parameter_collection_by_name, message)[:parameter_collection_return][:parameter_collection]
45
+ end
46
+
47
+ def request(action, body = nil)
48
+ @client.request(action, body).to_hash[:"#{action}_response"]
49
+ end
50
+ end
51
+ end