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
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ module Arca
6
+ class WSRGIVATest < TestCase
7
+ def ta
8
+ @ta ||= { token: "t", sign: "s" }
9
+ end
10
+
11
+ def ws
12
+ @ws ||= WSRGIVA.new(cuit: "20123456789").tap { |w| w.wsaa.stubs auth: ta }
13
+ end
14
+
15
+ def test_dummy
16
+ savon.expects(:dummy).returns(fixture("wsrgiva/dummy/success"))
17
+ assert_equal({ app_server: "OK", auth_server: "OK", db_server: "OK" }, ws.dummy)
18
+ end
19
+
20
+ def test_consultar_constancia_por_lote_devuelve_array_de_constancias
21
+ savon.expects(:consultar_constancia_por_lote_v2)
22
+ .with(message: {
23
+ auth_request: ta.merge(cuit_representada: 20_123_456_789),
24
+ datos_transaccion_array: { datos_transaccion: [ { cuit_contribuyente: 20_123_456_789,
25
+ tipo_bienes_involucrados: 1 } ] }
26
+ })
27
+ .returns(fixture("wsrgiva/consultar_constancia_por_lote/success"))
28
+ r = ws.consultar_constancia_por_lote("20123456789")
29
+ assert_equal 2, r.size
30
+ assert_hash_includes r[0],
31
+ fecha_consulta: "23-03-2023", id_contribuyente: "20123456789",
32
+ descripcion_contribuyente: "RAZON SOCIAL EJEMPLO S.A.", vigencia: "23-09-2023",
33
+ codigo_leyenda: "18", descripcion_leyenda: "Alícuota 1% - Responsables inscriptos, sin incumplimientos.",
34
+ codigo_seguridad: "ABC123"
35
+ assert_equal "20234567890", r[1][:id_contribuyente]
36
+ assert_equal "2", r[1][:codigo_leyenda]
37
+ end
38
+
39
+ def test_consultar_constancia_por_lote_con_varios_cuits
40
+ savon.expects(:consultar_constancia_por_lote_v2)
41
+ .with(message: {
42
+ auth_request: ta.merge(cuit_representada: 20_123_456_789),
43
+ datos_transaccion_array: {
44
+ datos_transaccion: [
45
+ { cuit_contribuyente: 20_123_456_789, tipo_bienes_involucrados: 1 },
46
+ { cuit_contribuyente: 20_234_567_890, tipo_bienes_involucrados: 1 }
47
+ ]
48
+ }
49
+ })
50
+ .returns(fixture("wsrgiva/consultar_constancia_por_lote/success"))
51
+ ws.consultar_constancia_por_lote(%w[20123456789 20234567890])
52
+ end
53
+
54
+ def test_consultar_constancia_por_lote_con_constancia_de_error
55
+ savon.expects(:consultar_constancia_por_lote_v2).with(message: :any).returns(fixture("wsrgiva/consultar_constancia_por_lote/one_error"))
56
+ r = ws.consultar_constancia_por_lote("30636414936")
57
+ assert_equal 1, r.size
58
+ assert_hash_includes r[0], id_contribuyente: "30636414936", codigo_error: "4003",
59
+ descripcion_error: "CUIT Inexistente"
60
+ end
61
+
62
+ def test_rechaza_mas_de_100_cuits
63
+ cuits = (1..101).map { |i| "20#{i.to_s.rjust(9, '0')}" }
64
+ error = assert_raises(ArgumentError) { ws.consultar_constancia_por_lote(cuits) }
65
+ assert_match(/Maximum 100 CUITs/, error.message)
66
+ end
67
+
68
+ def test_rechaza_tipo_bienes_involucrados_distinto_de_1
69
+ error = assert_raises(ArgumentError) do
70
+ ws.consultar_constancia_por_lote("20123456789", tipo_bienes_involucrados: 2)
71
+ end
72
+ assert_match(/tipo_bienes_involucrados must be 1/, error.message)
73
+ end
74
+
75
+ def test_entorno_development
76
+ Client.expects(:new).with { |opts| opts[:wsdl] == WSAA::WSDL[:development] }.returns(stub(operations: []))
77
+ Client.expects(:new).with do |opts|
78
+ opts[:wsdl] == WSRGIVA::WSDL[:development] && opts[:soap_version] == 1
79
+ end.returns(stub(operations: []))
80
+ WSRGIVA.new(cuit: "1", env: :development)
81
+ end
82
+
83
+ def test_entorno_production
84
+ Client.expects(:new).with { |opts| opts[:wsdl] == WSAA::WSDL[:production] }.returns(stub(operations: []))
85
+ Client.expects(:new).with do |opts|
86
+ opts[:wsdl] == WSRGIVA::WSDL[:production] && opts[:soap_version] == 1
87
+ end.returns(stub(operations: []))
88
+ WSRGIVA.new(cuit: "1", env: :production)
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
+ <soap:Body>
4
+ <DetalladaEstadoResponse xmlns="Ar.Gob.Afip.Dga.wconsdeclaracion">
5
+ <DetalladaEstadoResult>
6
+ <ListaErrores>
7
+ <DetalleError>
8
+ <Codigo>0</Codigo>
9
+ <Descripcion>Ejecucion exitosa.
10
+ </Descripcion><DescripcionAdicional/></DetalleError>
11
+ </ListaErrores>
12
+ <Server>10.30.148.106</Server>
13
+ <TimeStamp>2019-07-15T15:47:19.4979795-03:00</TimeStamp>
14
+ <Estado><FechaPresentacion xsi:nil="true"/>
15
+ <FechaAutorizacionRetiro>2019-04-25T18:48:12</FechaAutorizacionRetiro>
16
+ <FechaSalida>2019-04-25T18:48:12</FechaSalida>
17
+ <FechaCancelacion>2019-07-04T02:29:34</FechaCancelacion><FechaOficializacionPermisoEmbarqueOriginal xsi:nil="true"/><FechaPresentacionPermisoEmbarqueOriginal xsi:nil="true"/><FechaPrecumplido xsi:nil="true"/><FechaRegistracionCumplido xsi:nil="true"/><FechaLibramientoCumplido xsi:nil="true"/><FechaVencimientoEmbarque xsi:nil="true"/>
18
+ <IndicadorPrecumplido>-</IndicadorPrecumplido>
19
+ <IndicadorCumplido>-</IndicadorCumplido>
20
+ </Estado>
21
+ </DetalladaEstadoResult>
22
+ </DetalladaEstadoResponse>
23
+ </soap:Body>
24
+ </soap:Envelope>
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
+ <soap:Body>
4
+ <DetalladaListaDeclaracionesResponse xmlns="Ar.Gob.Afip.Dga.wconsdeclaracion">
5
+ <DetalladaListaDeclaracionesResult>
6
+ <ListaErrores>
7
+ <DetalleError>
8
+ <Codigo>0</Codigo>
9
+ <Descripcion>Ejecucion exitosa.
10
+ </Descripcion><DescripcionAdicional/></DetalleError>
11
+ </ListaErrores>
12
+ <Server>10.30.148.83</Server>
13
+ <TimeStamp>2019-07-15T15:06:04.897196-03:00</TimeStamp>
14
+ <Declaraciones>
15
+ <Declaracion>
16
+ <IdentificadorDeclaracion>19092SIMI000313M</IdentificadorDeclaracion>
17
+ <CuitImportadorExportador>23076925089</CuitImportadorExportador>
18
+ <CuitDespachante>20180963295</CuitDespachante>
19
+ <FechaOficializacionDeclaracion>2019-04-03T12:54:36</FechaOficializacionDeclaracion>
20
+ <CodigoEstadoDeclaracion>SALI</CodigoEstadoDeclaracion>
21
+ <FechaEstadoDeclaracion>2019-04-06T13:09:53</FechaEstadoDeclaracion>
22
+ <CodigoViaTransporte>-</CodigoViaTransporte>
23
+ <MatriculaMedioTransporte>-</MatriculaMedioTransporte>
24
+ </Declaracion>
25
+ <Declaracion>
26
+ <IdentificadorDeclaracion>19092SIMI000314N</IdentificadorDeclaracion>
27
+ <CuitImportadorExportador>23076925089</CuitImportadorExportador>
28
+ <CuitDespachante>20180963295</CuitDespachante>
29
+ <FechaOficializacionDeclaracion>2019-04-03T13:03:07</FechaOficializacionDeclaracion>
30
+ <CodigoEstadoDeclaracion>CANC</CodigoEstadoDeclaracion>
31
+ <FechaEstadoDeclaracion>2019-06-20T02:23:31</FechaEstadoDeclaracion>
32
+ <CodigoViaTransporte>-</CodigoViaTransporte>
33
+ <MatriculaMedioTransporte>-</MatriculaMedioTransporte>
34
+ </Declaracion>
35
+ </Declaraciones>
36
+ </DetalladaListaDeclaracionesResult>
37
+ </DetalladaListaDeclaracionesResponse>
38
+ </soap:Body>
39
+ </soap:Envelope>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
+ <soap:Body>
4
+ <DetalladaListaDeclaracionesResponse xmlns="Ar.Gob.Afip.Dga.wconsdeclaracion">
5
+ <DetalladaListaDeclaracionesResult>
6
+ <ListaErrores>
7
+ <DetalleError>
8
+ <Codigo>21248</Codigo>
9
+ <Descripcion>Declaracion 19093SIMI000434. inexistente o invalida</Descripcion><DescripcionAdicional/></DetalleError>
10
+ </ListaErrores>
11
+ <Server>10.30.148.82</Server>
12
+ <TimeStamp>2019-07-15T15:30:00.2551764-03:00</TimeStamp>
13
+ </DetalladaListaDeclaracionesResult>
14
+ </DetalladaListaDeclaracionesResponse>
15
+ </soap:Body>
16
+ </soap:Envelope>
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
+ <soap:Body>
4
+ <DetalladaListaDeclaracionesResponse xmlns="Ar.Gob.Afip.Dga.wconsdeclaracion">
5
+ <DetalladaListaDeclaracionesResult>
6
+ <ListaErrores>
7
+ <DetalleError>
8
+ <Codigo>0</Codigo>
9
+ <Descripcion>Ejecucion exitosa.
10
+ </Descripcion><DescripcionAdicional/></DetalleError>
11
+ </ListaErrores>
12
+ <Server>10.30.148.106</Server>
13
+ <TimeStamp>2019-07-15T14:28:10.5546061-03:00</TimeStamp>
14
+ <Declaraciones>
15
+ <Declaracion>
16
+ <IdentificadorDeclaracion>19093SIMI000434X</IdentificadorDeclaracion>
17
+ <CuitImportadorExportador>23076925089</CuitImportadorExportador>
18
+ <CuitDespachante>20180963295</CuitDespachante>
19
+ <FechaOficializacionDeclaracion>2019-05-17T19:44:34</FechaOficializacionDeclaracion>
20
+ <CodigoEstadoDeclaracion>SALI</CodigoEstadoDeclaracion>
21
+ <FechaEstadoDeclaracion>2019-05-18T03:18:02</FechaEstadoDeclaracion>
22
+ <CodigoViaTransporte>-</CodigoViaTransporte>
23
+ <MatriculaMedioTransporte>-</MatriculaMedioTransporte>
24
+ </Declaracion>
25
+ </Declaraciones>
26
+ </DetalladaListaDeclaracionesResult>
27
+ </DetalladaListaDeclaracionesResponse>
28
+ </soap:Body>
29
+ </soap:Envelope>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3
+ <soap:Body>
4
+ <DummyResponse xmlns="Ar.Gob.Afip.Dga.wconsdeclaracion">
5
+ <DummyResult>
6
+ <AppServer>OK</AppServer>
7
+ <DbServer>OK</DbServer>
8
+ <AuthServer>OK</AuthServer>
9
+ </DummyResult>
10
+ </DummyResponse>
11
+ </soap:Body>
12
+ </soap:Envelope>