afipws 1.1.0 → 1.2.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +6 -1
  3. data/README.md +1 -0
  4. data/afipws.gemspec +1 -0
  5. data/lib/afipws.rb +1 -1
  6. data/lib/afipws/client.rb +0 -1
  7. data/lib/afipws/persona_service_a100.rb +14 -6
  8. data/lib/afipws/persona_service_a4.rb +14 -4
  9. data/lib/afipws/version.rb +1 -1
  10. data/lib/afipws/w_cons_declaracion.rb +63 -0
  11. data/lib/afipws/ws_constancia_inscripcion.rb +15 -5
  12. data/lib/afipws/wsaa.rb +2 -2
  13. data/lib/afipws/wsfe.rb +8 -6
  14. data/spec/afipws/core_ext/hash_spec.rb +3 -3
  15. data/spec/afipws/persona_service_a100_spec.rb +3 -3
  16. data/spec/afipws/persona_service_a4_spec.rb +1 -1
  17. data/spec/afipws/w_cons_declaracion_spec.rb +87 -0
  18. data/spec/afipws/ws_constancia_inscripcion_spec.rb +12 -14
  19. data/spec/afipws/wsaa_spec.rb +2 -2
  20. data/spec/afipws/wsfe_spec.rb +49 -47
  21. data/spec/fixtures/wconsdeclaracion/detallada_estado/success.xml +24 -0
  22. data/spec/fixtures/wconsdeclaracion/detallada_lista_declaraciones/por_fecha_success.xml +39 -0
  23. data/spec/fixtures/wconsdeclaracion/detallada_lista_declaraciones/por_id_inexistente.xml +16 -0
  24. data/spec/fixtures/wconsdeclaracion/detallada_lista_declaraciones/por_id_success.xml +29 -0
  25. data/spec/fixtures/wconsdeclaracion/dummy/success.xml +12 -0
  26. data/spec/fixtures/wconsdeclaracion/wconsdeclaracion.wsdl +2976 -0
  27. data/spec/fixtures/{constancia_inscripcion_dummy → ws_sr_constancia_inscripcion/dummy}/success.xml +0 -0
  28. data/spec/fixtures/{constancia_inscripcion_get_persona → ws_sr_constancia_inscripcion/get_persona}/failure.xml +0 -0
  29. data/spec/fixtures/{constancia_inscripcion_get_persona → ws_sr_constancia_inscripcion/get_persona}/fault.xml +0 -0
  30. data/spec/fixtures/{constancia_inscripcion_get_persona → ws_sr_constancia_inscripcion/get_persona}/success.xml +0 -0
  31. data/spec/fixtures/{ws_constancia_inscripcion.wsdl → ws_sr_constancia_inscripcion/ws_constancia_inscripcion.wsdl} +0 -0
  32. data/spec/fixtures/{login_cms → wsaa/login_cms}/fault.xml +0 -0
  33. data/spec/fixtures/{login_cms → wsaa/login_cms}/success.xml +0 -0
  34. data/spec/fixtures/{login_cms → wsaa/login_cms}/token_expirado.xml +0 -0
  35. data/spec/fixtures/{wsaa.wsdl → wsaa/wsaa.wsdl} +0 -0
  36. data/spec/fixtures/{fe_comp_consultar → wsfe/fe_comp_consultar}/success.xml +0 -0
  37. data/spec/fixtures/{fe_comp_tot_x_request → wsfe/fe_comp_tot_x_request}/success.xml +0 -0
  38. data/spec/fixtures/{fe_comp_ultimo_autorizado → wsfe/fe_comp_ultimo_autorizado}/success.xml +0 -0
  39. data/spec/fixtures/{fe_dummy → wsfe/fe_dummy}/success.xml +0 -0
  40. data/spec/fixtures/{fe_param_get_cotizacion → wsfe/fe_param_get_cotizacion}/dolar.xml +0 -0
  41. data/spec/fixtures/{fe_param_get_cotizacion → wsfe/fe_param_get_cotizacion}/inexistente.xml +0 -0
  42. data/spec/fixtures/{fe_param_get_ptos_venta → wsfe/fe_param_get_ptos_venta}/success.xml +0 -0
  43. data/spec/fixtures/{fe_param_get_tipos_cbte → wsfe/fe_param_get_tipos_cbte}/failure_1_error.xml +0 -0
  44. data/spec/fixtures/{fe_param_get_tipos_cbte → wsfe/fe_param_get_tipos_cbte}/failure_2_errors.xml +0 -0
  45. data/spec/fixtures/{fe_param_get_tipos_cbte → wsfe/fe_param_get_tipos_cbte}/success.xml +0 -0
  46. data/spec/fixtures/{fe_param_get_tipos_concepto → wsfe/fe_param_get_tipos_concepto}/success.xml +0 -0
  47. data/spec/fixtures/{fe_param_get_tipos_doc → wsfe/fe_param_get_tipos_doc}/success.xml +0 -0
  48. data/spec/fixtures/{fe_param_get_tipos_iva → wsfe/fe_param_get_tipos_iva}/success.xml +0 -0
  49. data/spec/fixtures/{fe_param_get_tipos_monedas → wsfe/fe_param_get_tipos_monedas}/success.xml +0 -0
  50. data/spec/fixtures/{fe_param_get_tipos_opcional → wsfe/fe_param_get_tipos_opcional}/success.xml +0 -0
  51. data/spec/fixtures/{fe_param_get_tipos_tributos → wsfe/fe_param_get_tipos_tributos}/success.xml +0 -0
  52. data/spec/fixtures/{fecae_solicitar → wsfe/fecae_solicitar}/autorizacion_1_cbte.xml +0 -0
  53. data/spec/fixtures/{fecae_solicitar → wsfe/fecae_solicitar}/autorizacion_2_cbtes.xml +0 -0
  54. data/spec/fixtures/{fecae_solicitar → wsfe/fecae_solicitar}/dos_observaciones.xml +0 -0
  55. data/spec/fixtures/{fecae_solicitar → wsfe/fecae_solicitar}/una_observacion.xml +0 -0
  56. data/spec/fixtures/{fecaea_consultar → wsfe/fecaea_consultar}/success.xml +0 -0
  57. data/spec/fixtures/{fecaea_reg_informativo → wsfe/fecaea_reg_informativo}/informe_rtdo_parcial.xml +0 -0
  58. data/spec/fixtures/{fecaea_sin_movimiento_informar → wsfe/fecaea_sin_movimiento_informar}/success.xml +0 -0
  59. data/spec/fixtures/{fecaea_solicitar → wsfe/fecaea_solicitar}/caea_ya_otorgado.xml +0 -0
  60. data/spec/fixtures/{fecaea_solicitar → wsfe/fecaea_solicitar}/error_distinto.xml +0 -0
  61. data/spec/fixtures/{fecaea_solicitar → wsfe/fecaea_solicitar}/success.xml +0 -0
  62. data/spec/fixtures/{wsfe.wsdl → wsfe/wsfe.wsdl} +1371 -1371
  63. data/spec/spec_helper.rb +3 -2
  64. data/spec/support/fake_wsaa.rb +11 -0
  65. metadata +105 -75
  66. data/lib/afipws/ws_base.rb +0 -18
@@ -8,30 +8,30 @@ module Afipws
8
8
 
9
9
  context 'métodos API' do
10
10
  it 'dummy' do
11
- savon.expects(:dummy).returns(fixture('constancia_inscripcion_dummy/success'))
11
+ savon.expects(:dummy).returns(fixture('ws_sr_constancia_inscripcion/dummy/success'))
12
12
  ws.dummy.should == { appserver: 'OK', dbserver: 'OK', authserver: 'OK' }
13
13
  end
14
14
 
15
15
  it 'debería devolver un hash con los datos generales y regímenes impositivos' do
16
16
  savon.expects(:get_persona)
17
17
  .with(message: message.merge(id_persona: '20294834487'))
18
- .returns(fixture('constancia_inscripcion_get_persona/success'))
18
+ .returns(fixture('ws_sr_constancia_inscripcion/get_persona/success'))
19
19
  r = ws.get_persona '20294834487'
20
- r[:datos_generales].should have_entries(
20
+ r[:datos_generales].should include(
21
21
  estado_clave: 'ACTIVO', mes_cierre: '6', razon_social: 'LA REGALERIA S A',
22
22
  tipo_clave: 'CUIT', tipo_persona: 'JURIDICA'
23
23
  )
24
- r[:datos_generales][:domicilio_fiscal].should have_entries(
24
+ r[:datos_generales][:domicilio_fiscal].should include(
25
25
  cod_postal: '2300', descripcion_provincia: 'SANTA FE',
26
26
  direccion: 'AV SIEMPRE VIVA 123', localidad: 'NUEVA YORK', tipo_domicilio: 'FISCAL'
27
27
  )
28
- r[:datos_regimen_general][:actividad].should have_entries(
28
+ r[:datos_regimen_general][:actividad].should include(
29
29
  id_actividad: '477330', nomenclador: '883', orden: '2', periodo: '201311'
30
30
  )
31
- r[:datos_regimen_general][:impuesto][1].should have_entries(
31
+ r[:datos_regimen_general][:impuesto][1].should include(
32
32
  descripcion_impuesto: 'IVA', id_impuesto: '30', periodo: '198903'
33
33
  )
34
- r[:datos_regimen_general][:regimen].should have_entries(
34
+ r[:datos_regimen_general][:regimen].should include(
35
35
  id_impuesto: '208', id_regimen: '159', periodo: '199403'
36
36
  )
37
37
  end
@@ -39,9 +39,9 @@ module Afipws
39
39
  it 'cuando hay errores en la constancia sigue la misma lógica' do
40
40
  savon.expects(:get_persona)
41
41
  .with(message: message.merge(id_persona: '20294834489'))
42
- .returns(fixture('constancia_inscripcion_get_persona/failure'))
42
+ .returns(fixture('ws_sr_constancia_inscripcion/get_persona/failure'))
43
43
  r = ws.get_persona '20294834489'
44
- r[:error_regimen_general].should have_entries(
44
+ r[:error_regimen_general].should include(
45
45
  error: 'El contribuyente cuenta con impuestos con baja de oficio por Decreto 1299/98',
46
46
  mensaje: 'No cumple con las condiciones para enviar datos del regimen general'
47
47
  )
@@ -50,7 +50,7 @@ module Afipws
50
50
  it 'cuando no existe la persona' do
51
51
  savon.expects(:get_persona)
52
52
  .with(message: message.merge(id_persona: '123'))
53
- .returns(fixture('constancia_inscripcion_get_persona/fault'))
53
+ .returns(fixture('ws_sr_constancia_inscripcion/get_persona/fault'))
54
54
  -> { ws.get_persona '123' }.should raise_error WSError, /No existe persona con ese Id/
55
55
  end
56
56
  end
@@ -59,15 +59,13 @@ module Afipws
59
59
  it 'debería usar las url para development cuando el env es development' do
60
60
  Client.expects(:new).with(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl')
61
61
  Client.expects(:new).with(wsdl: 'https://awshomo.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL', soap_version: 1)
62
- wsci = WSConstanciaInscripcion.new env: :development
63
- wsci.env.should == :development
62
+ WSConstanciaInscripcion.new env: :development
64
63
  end
65
64
 
66
65
  it 'debería usar las url para production cuando el env es production' do
67
66
  Client.expects(:new).with(wsdl: 'https://wsaa.afip.gov.ar/ws/services/LoginCms?wsdl')
68
67
  Client.expects(:new).with(wsdl: 'https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL', soap_version: 1)
69
- wsci = WSConstanciaInscripcion.new env: 'production'
70
- wsci.env.should == :production
68
+ WSConstanciaInscripcion.new env: :production
71
69
  end
72
70
  end
73
71
  end
@@ -32,7 +32,7 @@ module Afipws
32
32
  it 'debería mandar el TRA al WS y obtener el TA' do
33
33
  ws = WSAA.new key: 'key', cert: 'cert'
34
34
  ws.expects(:tra).with('key', 'cert', 'wsfe', 2400).returns('tra')
35
- savon.expects(:login_cms).with(message: {in0: 'tra'}).returns(fixture('login_cms/success'))
35
+ savon.expects(:login_cms).with(message: {in0: 'tra'}).returns(fixture('wsaa/login_cms/success'))
36
36
  ta = ws.login
37
37
  ta[:token].should == 'PD94='
38
38
  ta[:sign].should == 'i9xDN='
@@ -42,7 +42,7 @@ module Afipws
42
42
 
43
43
  it 'debería encapsular SOAP Faults' do
44
44
  subject.stubs(:tra).returns('')
45
- savon.expects(:login_cms).with(message: :any).returns(fixture('login_cms/fault'))
45
+ savon.expects(:login_cms).with(message: :any).returns(fixture('wsaa/login_cms/fault'))
46
46
  -> { subject.login }.should raise_error WSError, /CMS no es valido/
47
47
  end
48
48
  end
@@ -8,12 +8,12 @@ module Afipws
8
8
 
9
9
  context 'métodos de negocio' do
10
10
  it 'dummy' do
11
- savon.expects(:fe_dummy).returns(fixture('fe_dummy/success'))
11
+ savon.expects(:fe_dummy).returns(fixture('wsfe/fe_dummy/success'))
12
12
  ws.dummy.should == { app_server: 'OK', db_server: 'OK', auth_server: 'OK' }
13
13
  end
14
14
 
15
15
  it 'tipos_comprobantes' do
16
- savon.expects(:fe_param_get_tipos_cbte).with(message: auth).returns(fixture('fe_param_get_tipos_cbte/success'))
16
+ savon.expects(:fe_param_get_tipos_cbte).with(message: auth).returns(fixture('wsfe/fe_param_get_tipos_cbte/success'))
17
17
  ws.tipos_comprobantes.should == [
18
18
  { id: 1, desc: 'Factura A', fch_desde: Date.new(2010, 9, 17), fch_hasta: nil },
19
19
  { id: 2, desc: 'Nota de Débito A', fch_desde: Date.new(2010, 9, 18), fch_hasta: Date.new(2011, 9, 18) }
@@ -21,17 +21,17 @@ module Afipws
21
21
  end
22
22
 
23
23
  it 'tipos_documentos' do
24
- savon.expects(:fe_param_get_tipos_doc).with(message: auth).returns(fixture('fe_param_get_tipos_doc/success'))
24
+ savon.expects(:fe_param_get_tipos_doc).with(message: auth).returns(fixture('wsfe/fe_param_get_tipos_doc/success'))
25
25
  ws.tipos_documentos.should == [{ id: 80, desc: 'CUIT', fch_desde: Date.new(2008, 7, 25), fch_hasta: nil }]
26
26
  end
27
27
 
28
28
  it 'tipos_concepto' do
29
- savon.expects(:fe_param_get_tipos_concepto).with(message: auth).returns(fixture('fe_param_get_tipos_concepto/success'))
30
- ws.tipos_concepto.should == [{ id: 1, desc: "Producto", fch_desde: Date.new(2008,7,25), fch_hasta: nil }]
29
+ savon.expects(:fe_param_get_tipos_concepto).with(message: auth).returns(fixture('wsfe/fe_param_get_tipos_concepto/success'))
30
+ ws.tipos_concepto.should == [{ id: 1, desc: 'Producto', fch_desde: Date.new(2008, 7, 25), fch_hasta: nil }]
31
31
  end
32
32
 
33
33
  it 'tipos_monedas' do
34
- savon.expects(:fe_param_get_tipos_monedas).with(message: auth).returns(fixture('fe_param_get_tipos_monedas/success'))
34
+ savon.expects(:fe_param_get_tipos_monedas).with(message: auth).returns(fixture('wsfe/fe_param_get_tipos_monedas/success'))
35
35
  ws.tipos_monedas.should == [
36
36
  { id: 'PES', desc: 'Pesos Argentinos', fch_desde: Date.new(2009, 4, 3), fch_hasta: nil },
37
37
  { id: '002', desc: 'Dólar Libre EEUU', fch_desde: Date.new(2009, 4, 16), fch_hasta: nil }
@@ -39,22 +39,22 @@ module Afipws
39
39
  end
40
40
 
41
41
  it 'tipos_opcional' do
42
- savon.expects(:fe_param_get_tipos_opcional).with(message: auth).returns(fixture('fe_param_get_tipos_opcional/success'))
42
+ savon.expects(:fe_param_get_tipos_opcional).with(message: auth).returns(fixture('wsfe/fe_param_get_tipos_opcional/success'))
43
43
  ws.tipos_opcional.should == []
44
44
  end
45
45
 
46
46
  it 'tipos_iva' do
47
- savon.expects(:fe_param_get_tipos_iva).with(message: auth).returns(fixture('fe_param_get_tipos_iva/success'))
47
+ savon.expects(:fe_param_get_tipos_iva).with(message: auth).returns(fixture('wsfe/fe_param_get_tipos_iva/success'))
48
48
  ws.tipos_iva.should == [{ id: 5, desc: '21%', fch_desde: Date.new(2009, 2, 20), fch_hasta: nil }]
49
49
  end
50
50
 
51
51
  it 'tipos_tributos' do
52
- savon.expects(:fe_param_get_tipos_tributos).with(message: auth).returns(fixture('fe_param_get_tipos_tributos/success'))
52
+ savon.expects(:fe_param_get_tipos_tributos).with(message: auth).returns(fixture('wsfe/fe_param_get_tipos_tributos/success'))
53
53
  ws.tipos_tributos.should == [{ id: 2, desc: 'Impuestos provinciales', fch_desde: Date.new(2010, 9, 17), fch_hasta: nil }]
54
54
  end
55
55
 
56
56
  it 'puntos_venta' do
57
- savon.expects(:fe_param_get_ptos_venta).with(message: auth).returns(fixture('fe_param_get_ptos_venta/success'))
57
+ savon.expects(:fe_param_get_ptos_venta).with(message: auth).returns(fixture('wsfe/fe_param_get_ptos_venta/success'))
58
58
  ws.puntos_venta.should == [
59
59
  { nro: 1, emision_tipo: 'CAE', bloqueado: false, fch_baja: nil },
60
60
  { nro: 2, emision_tipo: 'CAEA', bloqueado: true, fch_baja: Date.new(2011, 1, 31) }
@@ -63,18 +63,18 @@ module Afipws
63
63
 
64
64
  context 'cotizacion' do
65
65
  it 'cuando la moneda solicitada existe' do
66
- savon.expects(:fe_param_get_cotizacion).with(message: auth.merge(mon_id: 'DOL')).returns(fixture('fe_param_get_cotizacion/dolar'))
66
+ savon.expects(:fe_param_get_cotizacion).with(message: auth.merge(mon_id: 'DOL')).returns(fixture('wsfe/fe_param_get_cotizacion/dolar'))
67
67
  ws.cotizacion('DOL').should == 3.976
68
68
  end
69
69
 
70
70
  it 'cuando la moneda no existe' do
71
- savon.expects(:fe_param_get_cotizacion).with(message: auth.merge(mon_id: 'PES')).returns(fixture('fe_param_get_cotizacion/inexistente'))
71
+ savon.expects(:fe_param_get_cotizacion).with(message: auth.merge(mon_id: 'PES')).returns(fixture('wsfe/fe_param_get_cotizacion/inexistente'))
72
72
  -> { ws.cotizacion('PES') }.should raise_error WSError, /602: Sin Resultados/
73
73
  end
74
74
  end
75
75
 
76
76
  it 'cant_max_registros_x_lote' do
77
- savon.expects(:fe_comp_tot_x_request).with(message: auth).returns(fixture('fe_comp_tot_x_request/success'))
77
+ savon.expects(:fe_comp_tot_x_request).with(message: auth).returns(fixture('wsfe/fe_comp_tot_x_request/success'))
78
78
  ws.cant_max_registros_x_lote.should == 250
79
79
  end
80
80
 
@@ -96,7 +96,7 @@ module Afipws
96
96
  '//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Tributos/Tributo[1]/BaseImp' => 150,
97
97
  '//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Tributos/Tributo[1]/Alic' => 5.2,
98
98
  '//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Tributos/Tributo[1]/Importe' => 7.8
99
- )).returns(fixture('fecae_solicitar/autorizacion_1_cbte'))
99
+ )).returns(fixture('wsfe/fecae_solicitar/autorizacion_1_cbte'))
100
100
  rta = ws.autorizar_comprobantes(cbte_tipo: 1, pto_vta: 2, comprobantes: [
101
101
  {
102
102
  cbte_nro: 1, concepto: 1, doc_nro: 30_521_189_203, doc_tipo: 80, cbte_fch: Date.new(2011, 0o1, 13),
@@ -105,8 +105,10 @@ module Afipws
105
105
  tributos: { tributo: [{ id: 0, base_imp: 150, alic: 5.2, importe: 7.8 }] }
106
106
  }
107
107
  ])
108
- rta[0].should have_entries cae: '61023008595705', cae_fch_vto: Date.new(2011, 0o1, 23), cbte_nro: 1,
109
- resultado: 'A', observaciones: []
108
+ rta[0].should include(
109
+ cae: '61023008595705', cae_fch_vto: Date.new(2011, 0o1, 23), cbte_nro: 1,
110
+ resultado: 'A', observaciones: []
111
+ )
110
112
  rta.size.should == 1
111
113
  end
112
114
 
@@ -116,7 +118,7 @@ module Afipws
116
118
  '//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Iva/AlicIva[1]/Importe' => 21,
117
119
  '//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Iva/AlicIva[2]/Id' => 4,
118
120
  '//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Iva/AlicIva[2]/Importe' => 5.25
119
- )).returns(fixture('fecae_solicitar/autorizacion_1_cbte'))
121
+ )).returns(fixture('wsfe/fecae_solicitar/autorizacion_1_cbte'))
120
122
  ws.autorizar_comprobantes(cbte_tipo: 1, pto_vta: 2, comprobantes: [{iva: {alic_iva: [
121
123
  { id: 5, base_imp: 100, importe: 21 },
122
124
  { id: 4, base_imp: 50, importe: 5.25 }
@@ -130,33 +132,35 @@ module Afipws
130
132
  '//FeCAEReq/FeDetReq/FECAEDetRequest[1]/CbteHasta' => 5,
131
133
  '//FeCAEReq/FeDetReq/FECAEDetRequest[2]/CbteDesde' => 6,
132
134
  '//FeCAEReq/FeDetReq/FECAEDetRequest[2]/CbteHasta' => 6
133
- )).returns(fixture('fecae_solicitar/autorizacion_2_cbtes'))
135
+ )).returns(fixture('wsfe/fecae_solicitar/autorizacion_2_cbtes'))
134
136
  rta = ws.autorizar_comprobantes(cbte_tipo: 1, pto_vta: 2, comprobantes: [{ cbte_nro: 5 }, { cbte_nro: 6 }])
135
- rta[0].should have_entries cbte_nro: 5, cae: '61033008894096'
136
- rta[1].should have_entries cbte_nro: 6, cae: '61033008894101'
137
+ rta[0].should include cbte_nro: 5, cae: '61033008894096'
138
+ rta[1].should include cbte_nro: 6, cae: '61033008894101'
137
139
  end
138
140
 
139
141
  it 'con 2 observaciones' do
140
- savon.expects(:fecae_solicitar).with(message: :any).returns(fixture('fecae_solicitar/dos_observaciones'))
142
+ savon.expects(:fecae_solicitar).with(message: :any).returns(fixture('wsfe/fecae_solicitar/dos_observaciones'))
141
143
  rta = ws.autorizar_comprobantes comprobantes: []
142
- rta[0].should have_entries cbte_nro: 3, cae: nil, resultado: 'R', observaciones: [
144
+ rta[0].should include cbte_nro: 3, cae: nil, resultado: 'R', observaciones: [
143
145
  {code: 10_048, msg: 'Msg 1'}, {code: 10_018, msg: 'Msg 2'}
144
146
  ]
145
147
  end
146
148
 
147
149
  it 'con 1 observación' do
148
- savon.expects(:fecae_solicitar).with(message: :any).returns(fixture('fecae_solicitar/una_observacion'))
150
+ savon.expects(:fecae_solicitar).with(message: :any).returns(fixture('wsfe/fecae_solicitar/una_observacion'))
149
151
  rta = ws.autorizar_comprobantes comprobantes: []
150
- rta[0].should have_entries observaciones: [{code: 10_048, msg: 'Msg 1'}]
152
+ rta[0].should include observaciones: [{code: 10_048, msg: 'Msg 1'}]
151
153
  end
152
154
  end
153
155
 
154
156
  context 'solicitar_caea' do
155
157
  it 'debería mandar automáticamente el período y orden' do
156
158
  Date.stubs today: Date.new(2011, 1, 27)
157
- savon.expects(:fecaea_solicitar).with(message: has_path('//Periodo' => '201102', '//Orden' => 1)).returns(fixture('fecaea_solicitar/success'))
158
- ws.solicitar_caea.should have_entries caea: '21043476341977', fch_tope_inf: Date.new(2011, 0o3, 17),
159
- fch_vig_desde: Date.new(2011, 0o2, 0o1), fch_vig_hasta: Date.new(2011, 0o2, 15)
159
+ savon.expects(:fecaea_solicitar).with(message: has_path('//Periodo' => '201102', '//Orden' => 1)).returns(fixture('wsfe/fecaea_solicitar/success'))
160
+ ws.solicitar_caea.should include(
161
+ caea: '21043476341977', fch_tope_inf: Date.new(2011, 0o3, 17),
162
+ fch_vig_desde: Date.new(2011, 0o2, 0o1), fch_vig_hasta: Date.new(2011, 0o2, 15)
163
+ )
160
164
  end
161
165
 
162
166
  context 'periodo_para_solicitud_caea' do
@@ -179,15 +183,15 @@ module Afipws
179
183
  Date.stubs today: Date.new(2011, 1, 27)
180
184
  savon.expects(:fecaea_solicitar)
181
185
  .with(message: has_path('//Periodo' => '201102', '//Orden' => 1))
182
- .returns(fixture('fecaea_solicitar/caea_ya_otorgado'))
186
+ .returns(fixture('wsfe/fecaea_solicitar/caea_ya_otorgado'))
183
187
  savon.expects(:fecaea_consultar)
184
188
  .with(message: has_path('//Periodo' => '201102', '//Orden' => 1))
185
- .returns(fixture('fecaea_consultar/success'))
186
- ws.solicitar_caea.should have_entries caea: '21043476341977', fch_vig_desde: Date.new(2011, 0o2, 0o1)
189
+ .returns(fixture('wsfe/fecaea_consultar/success'))
190
+ ws.solicitar_caea.should include caea: '21043476341977', fch_vig_desde: Date.new(2011, 0o2, 0o1)
187
191
  end
188
192
 
189
193
  it 'cuando hay otro error debería burbujearlo' do
190
- savon.expects(:fecaea_solicitar).with(message: :any).returns(fixture('fecaea_solicitar/error_distinto'))
194
+ savon.expects(:fecaea_solicitar).with(message: :any).returns(fixture('wsfe/fecaea_solicitar/error_distinto'))
191
195
  -> { ws.solicitar_caea }.should raise_error WSError, /15007/
192
196
  end
193
197
  end
@@ -204,12 +208,12 @@ module Afipws
204
208
  '//FeCAEARegInfReq/FeDetReq/FECAEADetRequest[2]/CbteDesde' => 2,
205
209
  '//FeCAEARegInfReq/FeDetReq/FECAEADetRequest[2]/CbteHasta' => 2,
206
210
  '//FeCAEARegInfReq/FeDetReq/FECAEADetRequest[2]/CAEA' => '21043476341977'
207
- )).returns(fixture('fecaea_reg_informativo/informe_rtdo_parcial'))
211
+ )).returns(fixture('wsfe/fecaea_reg_informativo/informe_rtdo_parcial'))
208
212
  rta = ws.informar_comprobantes_caea(cbte_tipo: 1, pto_vta: 3, comprobantes: [
209
213
  { cbte_nro: 1, caea: '21043476341977' }, { cbte_nro: 2, caea: '21043476341977' }
210
214
  ])
211
- rta[0].should have_entries cbte_nro: 1, caea: '21043476341977', resultado: 'A', observaciones: []
212
- rta[1].should have_entries cbte_nro: 2, caea: '21043476341977', resultado: 'R', observaciones: [{code: 724, msg: 'Msg'}]
215
+ rta[0].should include cbte_nro: 1, caea: '21043476341977', resultado: 'A', observaciones: []
216
+ rta[1].should include cbte_nro: 2, caea: '21043476341977', resultado: 'R', observaciones: [{code: 724, msg: 'Msg'}]
213
217
  end
214
218
 
215
219
  it 'informar_caea_sin_movimientos' do
@@ -217,27 +221,27 @@ module Afipws
217
221
  '//Auth/Token' => 't',
218
222
  '//PtoVta' => 4,
219
223
  '//CAEA' => '21043476341977'
220
- )).returns(fixture('fecaea_sin_movimiento_informar/success'))
224
+ )).returns(fixture('wsfe/fecaea_sin_movimiento_informar/success'))
221
225
  rta = ws.informar_caea_sin_movimientos('21043476341977', 4)
222
- rta.should have_entries caea: '21043476341977', resultado: 'A'
226
+ rta.should include caea: '21043476341977', resultado: 'A'
223
227
  end
224
228
 
225
229
  context 'consultar_caea' do
226
230
  it 'consultar_caea' do
227
- savon.expects(:fecaea_consultar).with(message: has_path('//Periodo' => '201101', '//Orden' => 1)).returns(fixture('fecaea_consultar/success'))
228
- ws.consultar_caea(Date.new(2011, 1, 1)).should have_entries caea: '21043476341977', fch_tope_inf: Date.new(2011, 0o3, 17)
231
+ savon.expects(:fecaea_consultar).with(message: has_path('//Periodo' => '201101', '//Orden' => 1)).returns(fixture('wsfe/fecaea_consultar/success'))
232
+ ws.consultar_caea(Date.new(2011, 1, 1)).should include caea: '21043476341977', fch_tope_inf: Date.new(2011, 0o3, 17)
229
233
  end
230
234
  end
231
235
 
232
236
  it 'ultimo_comprobante_autorizado' do
233
- savon.expects(:fe_comp_ultimo_autorizado).with(message: has_path('//PtoVta' => 1, '//CbteTipo' => 1)).returns(fixture('fe_comp_ultimo_autorizado/success'))
237
+ savon.expects(:fe_comp_ultimo_autorizado).with(message: has_path('//PtoVta' => 1, '//CbteTipo' => 1)).returns(fixture('wsfe/fe_comp_ultimo_autorizado/success'))
234
238
  ws.ultimo_comprobante_autorizado(pto_vta: 1, cbte_tipo: 1).should == 20
235
239
  end
236
240
 
237
241
  it 'consultar_comprobante' do
238
242
  savon.expects(:fe_comp_consultar).with(message: has_path(
239
243
  '//Auth/Token' => 't', '//FeCompConsReq/PtoVta' => 1, '//FeCompConsReq/CbteTipo' => 2, '//FeCompConsReq/CbteNro' => 3
240
- )).returns(fixture('fe_comp_consultar/success'))
244
+ )).returns(fixture('wsfe/fe_comp_consultar/success'))
241
245
  rta = ws.consultar_comprobante(pto_vta: 1, cbte_tipo: 2, cbte_nro: 3)
242
246
  rta[:cod_autorizacion].should == '61023008595705'
243
247
  rta[:emision_tipo].should == 'CAE'
@@ -255,7 +259,7 @@ module Afipws
255
259
  wsfe.wsaa.expects(:login).returns(token: 't', sign: 's')
256
260
  savon.expects(:fe_param_get_tipos_cbte).with(message: has_path(
257
261
  '//Auth/Token' => 't', '//Auth/Sign' => 's', '//Auth/Cuit' => '1'
258
- )).returns(fixture('fe_param_get_tipos_cbte/success'))
262
+ )).returns(fixture('wsfe/fe_param_get_tipos_cbte/success'))
259
263
  wsfe.tipos_comprobantes
260
264
  end
261
265
  end
@@ -264,21 +268,19 @@ module Afipws
264
268
  it 'debería usar las url para development cuando el env es development' do
265
269
  Client.expects(:new).with(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl')
266
270
  Client.expects(:new).with(wsdl: 'https://wswhomo.afip.gov.ar/wsfev1/service.asmx?WSDL', convert_request_keys_to: :camelcase)
267
- wsfe = WSFE.new env: :development
268
- wsfe.env.should == :development
271
+ WSFE.new env: :development
269
272
  end
270
273
 
271
274
  it 'debería usar las url para production cuando el env es production' do
272
275
  Client.expects(:new).with(wsdl: 'https://wsaa.afip.gov.ar/ws/services/LoginCms?wsdl')
273
276
  Client.expects(:new).with(wsdl: 'https://servicios1.afip.gov.ar/wsfev1/service.asmx?WSDL', convert_request_keys_to: :camelcase)
274
- wsfe = WSFE.new env: 'production'
275
- wsfe.env.should == :production
277
+ WSFE.new env: 'production'
276
278
  end
277
279
  end
278
280
 
279
281
  context 'manejo de errores' do
280
282
  it 'cuando hay un error' do
281
- savon.expects(:fe_param_get_tipos_cbte).with(message: :any).returns(fixture('fe_param_get_tipos_cbte/failure_1_error'))
283
+ savon.expects(:fe_param_get_tipos_cbte).with(message: :any).returns(fixture('wsfe/fe_param_get_tipos_cbte/failure_1_error'))
282
284
  -> { ws.tipos_comprobantes }.should raise_error { |e|
283
285
  e.should be_a WSError
284
286
  e.errors.should == [{ code: '600', msg: 'No se corresponden token con firma' }]
@@ -287,7 +289,7 @@ module Afipws
287
289
  end
288
290
 
289
291
  it 'cuando hay varios errores' do
290
- savon.expects(:fe_param_get_tipos_cbte).with(message: :any).returns(fixture('fe_param_get_tipos_cbte/failure_2_errors'))
292
+ savon.expects(:fe_param_get_tipos_cbte).with(message: :any).returns(fixture('wsfe/fe_param_get_tipos_cbte/failure_2_errors'))
291
293
  -> { ws.tipos_comprobantes }.should raise_error { |e|
292
294
  e.should be_a WSError
293
295
  e.errors.should == [{ code: '600', msg: 'No se corresponden token con firma' }, { code: '601', msg: 'CUIT representada no incluida en token' }]
@@ -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>