afipws 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/lib/afipws/version.rb +1 -1
- data/lib/afipws/wsaa.rb +34 -9
- data/lib/afipws/wsfe.rb +1 -2
- data/spec/afipws/wsaa_spec.rb +14 -6
- data/spec/afipws/wsfe_spec.rb +51 -49
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bb1054b4ad45099d4b950edb154f0961e2a8100
|
4
|
+
data.tar.gz: 3768c0065771f1b021e136a30ce4d56fbdcf0204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beea7ebef5946e80acfd6ae40277000e9433964b38f669a0a0d6a4cb789b52e6e0856f35b5d804de7754b150501d8e68fa5d557ac1f2b4d0eb7cb7d30bdc75c8
|
7
|
+
data.tar.gz: bdcc106d8fdbeb4fee5000795ecba43d5483ede917a578874d52b2c66df60c930254c3da54ae9bcc54d5d8eca47956ed3aa5b507f8443f65e12e8f4e572f0d40
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/lib/afipws/version.rb
CHANGED
data/lib/afipws/wsaa.rb
CHANGED
@@ -16,6 +16,7 @@ module Afipws
|
|
16
16
|
@ttl = options[:ttl] || 2400
|
17
17
|
@cuit = options[:cuit]
|
18
18
|
@client = Client.new Hash(options[:savon]).reverse_merge(wsdl: WSDL[@env])
|
19
|
+
@ta_path = File.join(Dir.pwd, 'tmp', "#{@cuit}-#{@env}-ta.dump")
|
19
20
|
end
|
20
21
|
|
21
22
|
def generar_tra service, ttl
|
@@ -25,7 +26,6 @@ module Afipws
|
|
25
26
|
xml.header do
|
26
27
|
xml.uniqueId Time.now.to_i
|
27
28
|
xml.generationTime xsd_datetime Time.now - ttl
|
28
|
-
# TODO me parece que no le da mucha bola el WS al expirationTime
|
29
29
|
xml.expirationTime xsd_datetime Time.now + ttl
|
30
30
|
end
|
31
31
|
xml.service service
|
@@ -49,23 +49,36 @@ module Afipws
|
|
49
49
|
def login
|
50
50
|
response = @client.raw_request :login_cms, in0: tra(@key, @cert, @service, @ttl)
|
51
51
|
ta = Nokogiri::XML(Nokogiri::XML(response.to_xml).text)
|
52
|
-
{
|
52
|
+
{
|
53
|
+
token: ta.css('token').text,
|
54
|
+
sign: ta.css('sign').text,
|
53
55
|
generation_time: from_xsd_datetime(ta.css('generationTime').text),
|
54
|
-
expiration_time: from_xsd_datetime(ta.css('expirationTime').text)
|
56
|
+
expiration_time: from_xsd_datetime(ta.css('expirationTime').text)
|
57
|
+
}
|
55
58
|
rescue Savon::SOAPFault => f
|
56
59
|
raise WSError, f.message
|
57
60
|
end
|
58
61
|
|
59
|
-
# Obtiene un TA, lo cachea hasta que expire, y devuelve el hash Auth listo para pasarle al Client
|
60
|
-
# en los otros WS.
|
62
|
+
# Obtiene un TA, lo cachea hasta que expire, y devuelve el hash Auth listo para pasarle al Client en los otros WS
|
61
63
|
def auth
|
62
|
-
|
63
|
-
{
|
64
|
+
ta = obtener_y_cachear_ta
|
65
|
+
{auth: {token: ta[:token], sign: ta[:sign], cuit: @cuit}}
|
64
66
|
end
|
65
67
|
|
66
68
|
private
|
67
|
-
|
68
|
-
|
69
|
+
|
70
|
+
# Previene el error 'El CEE ya posee un TA valido para el acceso al WSN solicitado' que se genera cuando se pide el token varias veces en poco tiempo
|
71
|
+
def obtener_y_cachear_ta
|
72
|
+
@ta ||= restore_ta
|
73
|
+
if ta_expirado? @ta
|
74
|
+
@ta = login
|
75
|
+
persist_ta @ta
|
76
|
+
end
|
77
|
+
@ta
|
78
|
+
end
|
79
|
+
|
80
|
+
def ta_expirado? ta
|
81
|
+
ta.nil? || ta[:expiration_time] <= Time.now
|
69
82
|
end
|
70
83
|
|
71
84
|
def xsd_datetime time
|
@@ -75,5 +88,17 @@ module Afipws
|
|
75
88
|
def from_xsd_datetime str
|
76
89
|
Time.parse(str) rescue nil
|
77
90
|
end
|
91
|
+
|
92
|
+
def restore_ta
|
93
|
+
Marshal.load(File.read(@ta_path)) if File.exists?(@ta_path)
|
94
|
+
end
|
95
|
+
|
96
|
+
def persist_ta ta
|
97
|
+
dirname = File.dirname(@ta_path)
|
98
|
+
unless File.directory?(dirname)
|
99
|
+
FileUtils.mkdir_p(dirname)
|
100
|
+
end
|
101
|
+
File.open(@ta_path, "wb") { |f| f.write(Marshal.dump(ta)) }
|
102
|
+
end
|
78
103
|
end
|
79
104
|
end
|
data/lib/afipws/wsfe.rb
CHANGED
@@ -15,8 +15,7 @@ module Afipws
|
|
15
15
|
def initialize options = {}
|
16
16
|
@env = (options[:env] || :test).to_sym
|
17
17
|
@wsaa = options[:wsaa] || WSAA.new(options.merge(service: 'wsfe'))
|
18
|
-
|
19
|
-
@client = Client.new Hash(options[:savon]).reverse_merge(wsdl: WSDL[@env], ssl_version: ssl_version, convert_request_keys_to: :camelcase)
|
18
|
+
@client = Client.new Hash(options[:savon]).reverse_merge(wsdl: WSDL[@env], ssl_version: :TLSv1, convert_request_keys_to: :camelcase)
|
20
19
|
end
|
21
20
|
|
22
21
|
def dummy
|
data/spec/afipws/wsaa_spec.rb
CHANGED
@@ -47,13 +47,21 @@ describe Afipws::WSAA do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
context "auth" do
|
50
|
-
before
|
50
|
+
before do
|
51
|
+
FileUtils.rm_rf Dir.glob('tmp/*ta.dump')
|
52
|
+
Time.stubs(:now).returns(Time.local(2010, 1, 1))
|
53
|
+
end
|
51
54
|
|
52
|
-
it "debería cachear TA" do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
it "debería cachear TA en la instancia y disco" do
|
56
|
+
ws = Afipws::WSAA.new
|
57
|
+
ws.expects(:login).once.returns(ta = {token: 'token', sign: 'sign', expiration_time: Time.now + 60})
|
58
|
+
ws.auth
|
59
|
+
ws.auth
|
60
|
+
ws.ta.should equal ta
|
61
|
+
|
62
|
+
ws = Afipws::WSAA.new
|
63
|
+
ws.auth
|
64
|
+
ws.ta.should == ta
|
57
65
|
end
|
58
66
|
|
59
67
|
it "si el TA expiró debería ejecutar solicitar uno nuevo" do
|
data/spec/afipws/wsfe_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Afipws::WSFE do
|
4
4
|
let(:auth) { {auth: {token: 't', sign: 's', expiration_time: 12.hours.from_now}} }
|
5
5
|
let(:ws) { Afipws::WSFE.new cuit: '1', wsaa: Afipws::WSAA.new.tap { |wsaa| wsaa.stubs auth: auth } }
|
6
|
-
|
6
|
+
|
7
7
|
context "Métodos de negocio" do
|
8
8
|
it "dummy" do
|
9
9
|
savon.expects(:fe_dummy).returns(fixture('fe_dummy/success'))
|
@@ -13,56 +13,56 @@ describe Afipws::WSFE do
|
|
13
13
|
it "tipos_comprobantes" do
|
14
14
|
savon.expects(:fe_param_get_tipos_cbte).with(message: auth).returns(fixture('fe_param_get_tipos_cbte/success'))
|
15
15
|
ws.tipos_comprobantes.should == [
|
16
|
-
{ id: 1, desc: "Factura A", fch_desde: Date.new(2010,9,17), fch_hasta: nil },
|
16
|
+
{ id: 1, desc: "Factura A", fch_desde: Date.new(2010,9,17), fch_hasta: nil },
|
17
17
|
{ id: 2, desc: "Nota de Débito A", fch_desde: Date.new(2010,9,18), fch_hasta: Date.new(2011,9,18) }]
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "tipos_documentos" do
|
21
21
|
savon.expects(:fe_param_get_tipos_doc).with(message: auth).returns(fixture('fe_param_get_tipos_doc/success'))
|
22
22
|
ws.tipos_documentos.should == [{ id: 80, desc: "CUIT", fch_desde: Date.new(2008,7,25), fch_hasta: nil }]
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "tipos_monedas" do
|
26
26
|
savon.expects(:fe_param_get_tipos_monedas).with(message: auth).returns(fixture('fe_param_get_tipos_monedas/success'))
|
27
27
|
ws.tipos_monedas.should == [
|
28
|
-
{ id: 'PES', desc: "Pesos Argentinos", fch_desde: Date.new(2009,4,3), fch_hasta: nil },
|
28
|
+
{ id: 'PES', desc: "Pesos Argentinos", fch_desde: Date.new(2009,4,3), fch_hasta: nil },
|
29
29
|
{ id: '002', desc: "Dólar Libre EEUU", fch_desde: Date.new(2009,4,16), fch_hasta: nil }]
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
it "tipos_iva" do
|
33
33
|
savon.expects(:fe_param_get_tipos_iva).with(message: auth).returns(fixture('fe_param_get_tipos_iva/success'))
|
34
|
-
ws.tipos_iva.should == [{ id: 5, desc: "21%", fch_desde: Date.new(2009,2,20), fch_hasta: nil }]
|
34
|
+
ws.tipos_iva.should == [{ id: 5, desc: "21%", fch_desde: Date.new(2009,2,20), fch_hasta: nil }]
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "tipos_tributos" do
|
38
38
|
savon.expects(:fe_param_get_tipos_tributos).with(message: auth).returns(fixture('fe_param_get_tipos_tributos/success'))
|
39
39
|
ws.tipos_tributos.should == [{ id: 2, desc: "Impuestos provinciales", fch_desde: Date.new(2010,9,17), fch_hasta: nil }]
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "puntos_venta" do
|
43
43
|
savon.expects(:fe_param_get_ptos_venta).with(message: auth).returns(fixture('fe_param_get_ptos_venta/success'))
|
44
44
|
ws.puntos_venta.should == [
|
45
45
|
{ nro: 1, emision_tipo: "CAE", bloqueado: false, fch_baja: nil },
|
46
46
|
{ nro: 2, emision_tipo: "CAEA", bloqueado: true, fch_baja: Date.new(2011,1,31) }]
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
context "cotizacion" do
|
50
50
|
it "cuando la moneda solicitada existe" do
|
51
51
|
savon.expects(:fe_param_get_cotizacion).with(message: auth.merge(mon_id: 'DOL')).returns(fixture('fe_param_get_cotizacion/dolar'))
|
52
52
|
ws.cotizacion('DOL').should == 3.976
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
it "cuando la moneda no existe" do
|
56
56
|
savon.expects(:fe_param_get_cotizacion).with(message: auth.merge(mon_id: 'PES')).returns(fixture('fe_param_get_cotizacion/inexistente'))
|
57
57
|
lambda { ws.cotizacion('PES') }.should raise_error Afipws::WSError, /602: Sin Resultados/
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
it "cant_max_registros_x_lote" do
|
62
62
|
savon.expects(:fe_comp_tot_x_request).with(message: auth).returns(fixture('fe_comp_tot_x_request/success'))
|
63
63
|
ws.cant_max_registros_x_lote.should == 250
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
context "autorizar_comprobante" do
|
67
67
|
it "debería devolver un hash con el CAE y su fecha de vencimiento" do
|
68
68
|
savon.expects(:fecae_solicitar).with(message: has_path(
|
@@ -82,13 +82,13 @@ describe Afipws::WSFE do
|
|
82
82
|
'//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Tributos/Tributo[1]/Alic' => 5.2,
|
83
83
|
'//FeCAEReq/FeDetReq/FECAEDetRequest[1]/Tributos/Tributo[1]/Importe' => 7.8
|
84
84
|
)).returns(fixture('fecae_solicitar/autorizacion_1_cbte'))
|
85
|
-
rta = ws.autorizar_comprobantes(cbte_tipo: 1, pto_vta: 2, comprobantes: [{cbte_nro: 1, concepto: 1,
|
86
|
-
doc_nro: 30521189203, doc_tipo: 80, cbte_fch: Date.new(2011,01,13),
|
85
|
+
rta = ws.autorizar_comprobantes(cbte_tipo: 1, pto_vta: 2, comprobantes: [{cbte_nro: 1, concepto: 1,
|
86
|
+
doc_nro: 30521189203, doc_tipo: 80, cbte_fch: Date.new(2011,01,13),
|
87
87
|
imp_total: 1270.48, imp_neto: 1049.98, imp_iva: 220.50, mon_id: 'PES', mon_cotiz: 1,
|
88
88
|
iva: { alic_iva: [{ id: 5, base_imp: 1049.98, importe: 220.50 }]},
|
89
89
|
tributos: { tributo: [{ id: 0, base_imp: 150, alic: 5.2, importe: 7.8 }] }
|
90
90
|
}])
|
91
|
-
rta[0].should have_entries cae: '61023008595705', cae_fch_vto: Date.new(2011,01,23), cbte_nro: 1,
|
91
|
+
rta[0].should have_entries cae: '61023008595705', cae_fch_vto: Date.new(2011,01,23), cbte_nro: 1,
|
92
92
|
resultado: 'A', observaciones: []
|
93
93
|
rta.size.should == 1
|
94
94
|
end
|
@@ -105,7 +105,7 @@ describe Afipws::WSFE do
|
|
105
105
|
{ id: 4, base_imp: 50, importe: 5.25 }
|
106
106
|
]}}])
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
it "con varios comprobantes aprobados" do
|
110
110
|
savon.expects(:fecae_solicitar).with(message: has_path(
|
111
111
|
'//FeCAEReq/FeCabReq/CantReg' => 2,
|
@@ -118,7 +118,7 @@ describe Afipws::WSFE do
|
|
118
118
|
rta[0].should have_entries cbte_nro: 5, cae: '61033008894096'
|
119
119
|
rta[1].should have_entries cbte_nro: 6, cae: '61033008894101'
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
it "con 2 observaciones" do
|
123
123
|
savon.expects(:fecae_solicitar).with(message: :any).returns(fixture 'fecae_solicitar/dos_observaciones')
|
124
124
|
rta = ws.autorizar_comprobantes comprobantes: []
|
@@ -132,15 +132,15 @@ describe Afipws::WSFE do
|
|
132
132
|
rta[0].should have_entries observaciones: [{code: 10048, msg: 'Msg 1'}]
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
context "solicitar_caea" do
|
137
137
|
it "debería mandar automáticamente el período y orden" do
|
138
138
|
Date.stubs today: Date.new(2011,1,27)
|
139
139
|
savon.expects(:fecaea_solicitar).with(message: has_path('//Periodo' => '201102', '//Orden' => 1)).returns(fixture 'fecaea_solicitar/success')
|
140
|
-
ws.solicitar_caea.should have_entries caea: '21043476341977', fch_tope_inf: Date.new(2011,03,17),
|
140
|
+
ws.solicitar_caea.should have_entries caea: '21043476341977', fch_tope_inf: Date.new(2011,03,17),
|
141
141
|
fch_vig_desde: Date.new(2011,02,01), fch_vig_hasta: Date.new(2011,02,15)
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
context "periodo_para_solicitud_caea" do
|
145
145
|
it "cuando estoy en la primer quincena" do
|
146
146
|
Date.stubs today: Date.new(2011,1,12)
|
@@ -148,28 +148,28 @@ describe Afipws::WSFE do
|
|
148
148
|
Date.stubs today: Date.new(2011,1,15)
|
149
149
|
ws.periodo_para_solicitud_caea.should == { periodo: '201101', orden: 2 }
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
it "cuando estoy en la segunda quincena" do
|
153
153
|
Date.stubs today: Date.new(2011,1,16)
|
154
154
|
ws.periodo_para_solicitud_caea.should == { periodo: '201102', orden: 1 }
|
155
155
|
Date.stubs today: Date.new(2011,1,31)
|
156
156
|
ws.periodo_para_solicitud_caea.should == { periodo: '201102', orden: 1 }
|
157
|
-
end
|
157
|
+
end
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
it "cuando el caea ya fue otorgado debería consultarlo y devolverlo" do
|
161
161
|
Date.stubs today: Date.new(2011,1,27)
|
162
162
|
savon.expects(:fecaea_solicitar).with(message: has_path('//Periodo' => '201102', '//Orden' => 1)).returns(fixture 'fecaea_solicitar/caea_ya_otorgado')
|
163
163
|
savon.expects(:fecaea_consultar).with(message: has_path('//Periodo' => '201102', '//Orden' => 1)).returns(fixture 'fecaea_consultar/success')
|
164
164
|
ws.solicitar_caea.should have_entries caea: '21043476341977', fch_vig_desde: Date.new(2011,02,01)
|
165
|
-
end
|
166
|
-
|
165
|
+
end
|
166
|
+
|
167
167
|
it "cuando hay otro error debería burbujearlo" do
|
168
168
|
savon.expects(:fecaea_solicitar).with(message: :any).returns(fixture 'fecaea_solicitar/error_distinto')
|
169
169
|
lambda { ws.solicitar_caea }.should raise_error Afipws::WSError, /15007/
|
170
|
-
end
|
170
|
+
end
|
171
171
|
end
|
172
|
-
|
172
|
+
|
173
173
|
it "informar_comprobantes_caea" do
|
174
174
|
savon.expects(:fecaea_reg_informativo).with(message: has_path(
|
175
175
|
'//Auth/Token' => 't',
|
@@ -189,29 +189,29 @@ describe Afipws::WSFE do
|
|
189
189
|
rta[0].should have_entries cbte_nro: 1, caea: '21043476341977', resultado: 'A', observaciones: []
|
190
190
|
rta[1].should have_entries cbte_nro: 2, caea: '21043476341977', resultado: 'R', observaciones: [{code: 724, msg: 'Msg'}]
|
191
191
|
end
|
192
|
-
|
192
|
+
|
193
193
|
it "informar_caea_sin_movimientos" do
|
194
194
|
savon.expects(:fecaea_sin_movimiento_informar).with(message: has_path(
|
195
195
|
'//Auth/Token' => 't',
|
196
|
-
'//PtoVta' => 4,
|
196
|
+
'//PtoVta' => 4,
|
197
197
|
'//CAEA' => '21043476341977'
|
198
198
|
)).returns(fixture 'fecaea_sin_movimiento_informar/success')
|
199
199
|
rta = ws.informar_caea_sin_movimientos('21043476341977', 4)
|
200
200
|
rta.should have_entries caea: '21043476341977', resultado: 'A'
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
context "consultar_caea" do
|
204
204
|
it "consultar_caea" do
|
205
205
|
savon.expects(:fecaea_consultar).with(message: has_path('//Periodo' => '201101', '//Orden' => 1)).returns(fixture 'fecaea_consultar/success')
|
206
206
|
ws.consultar_caea(Date.new(2011,1,1)).should have_entries caea: '21043476341977', fch_tope_inf: Date.new(2011,03,17)
|
207
207
|
end
|
208
208
|
end
|
209
|
-
|
209
|
+
|
210
210
|
it "ultimo_comprobante_autorizado" do
|
211
211
|
savon.expects(:fe_comp_ultimo_autorizado).with(message: has_path('//PtoVta' => 1, '//CbteTipo' => 1)).returns(fixture 'fe_comp_ultimo_autorizado/success')
|
212
212
|
ws.ultimo_comprobante_autorizado(pto_vta: 1, cbte_tipo: 1).should == 20
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
it "consultar_comprobante" do
|
216
216
|
savon.expects(:fe_comp_consultar).with(message: has_path(
|
217
217
|
'//Auth/Token' => 't', '//FeCompConsReq/PtoVta' => 1, '//FeCompConsReq/CbteTipo' => 2, '//FeCompConsReq/CbteNro' => 3
|
@@ -221,21 +221,23 @@ describe Afipws::WSFE do
|
|
221
221
|
rta[:emision_tipo].should == 'CAE'
|
222
222
|
end
|
223
223
|
end
|
224
|
-
|
224
|
+
|
225
225
|
context "autenticacion" do
|
226
|
+
before { FileUtils.rm_rf Dir.glob('tmp/*ta.dump') }
|
227
|
+
|
226
228
|
it "debería autenticarse usando el WSAA" do
|
227
229
|
wsfe = Afipws::WSFE.new cuit: '1', cert: 'cert', key: 'key'
|
228
230
|
wsfe.wsaa.cert.should == 'cert'
|
229
231
|
wsfe.wsaa.key.should == 'key'
|
230
232
|
wsfe.wsaa.service.should == 'wsfe'
|
231
|
-
wsfe.wsaa.expects(:login).returns({
|
233
|
+
wsfe.wsaa.expects(:login).returns({token: 't', sign: 's'})
|
232
234
|
savon.expects(:fe_param_get_tipos_cbte).with(message: has_path(
|
233
235
|
'//Auth/Token' => 't', '//Auth/Sign' => 's', '//Auth/Cuit' => '1'
|
234
236
|
)).returns(fixture 'fe_param_get_tipos_cbte/success')
|
235
237
|
wsfe.tipos_comprobantes
|
236
238
|
end
|
237
239
|
end
|
238
|
-
|
240
|
+
|
239
241
|
context "entorno" do
|
240
242
|
it "debería usar las url para development cuando el env es development" do
|
241
243
|
Afipws::Client.expects(:new).with(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl')
|
@@ -251,27 +253,27 @@ describe Afipws::WSFE do
|
|
251
253
|
wsfe.env.should == :production
|
252
254
|
end
|
253
255
|
end
|
254
|
-
|
256
|
+
|
255
257
|
context "manejo de errores" do
|
256
258
|
it "cuando hay un error" do
|
257
259
|
savon.expects(:fe_param_get_tipos_cbte).with(message: :any).returns(fixture 'fe_param_get_tipos_cbte/failure_1_error')
|
258
|
-
lambda { ws.tipos_comprobantes }.should raise_error { |e|
|
260
|
+
lambda { ws.tipos_comprobantes }.should raise_error { |e|
|
259
261
|
e.should be_a Afipws::WSError
|
260
|
-
e.errors.should == [{ code: "600", msg: "No se corresponden token con firma" }]
|
261
|
-
e.message.should == "600: No se corresponden token con firma"
|
262
|
+
e.errors.should == [{ code: "600", msg: "No se corresponden token con firma" }]
|
263
|
+
e.message.should == "600: No se corresponden token con firma"
|
262
264
|
}
|
263
265
|
end
|
264
266
|
|
265
267
|
it "cuando hay varios errores" do
|
266
268
|
savon.expects(:fe_param_get_tipos_cbte).with(message: :any).returns(fixture 'fe_param_get_tipos_cbte/failure_2_errors')
|
267
|
-
lambda { ws.tipos_comprobantes }.should raise_error { |e|
|
269
|
+
lambda { ws.tipos_comprobantes }.should raise_error { |e|
|
268
270
|
e.should be_a Afipws::WSError
|
269
|
-
e.errors.should == [{ code: "600", msg: "No se corresponden token con firma" }, { code: "601", msg: "CUIT representada no incluida en token" }]
|
270
|
-
e.message.should == "600: No se corresponden token con firma; 601: CUIT representada no incluida en token"
|
271
|
+
e.errors.should == [{ code: "600", msg: "No se corresponden token con firma" }, { code: "601", msg: "CUIT representada no incluida en token" }]
|
272
|
+
e.message.should == "600: No se corresponden token con firma; 601: CUIT representada no incluida en token"
|
271
273
|
}
|
272
274
|
end
|
273
275
|
end
|
274
|
-
|
276
|
+
|
275
277
|
context "cálculo de fechas y períodos" do
|
276
278
|
it "periodo_para_consulta_caea" do
|
277
279
|
ws.periodo_para_consulta_caea(Date.new(2011,1,1)).should == { periodo: '201101', orden: 1 }
|
@@ -280,29 +282,29 @@ describe Afipws::WSFE do
|
|
280
282
|
ws.periodo_para_consulta_caea(Date.new(2011,1,31)).should == { periodo: '201101', orden: 2 }
|
281
283
|
ws.periodo_para_consulta_caea(Date.new(2011,2,2)).should == { periodo: '201102', orden: 1 }
|
282
284
|
end
|
283
|
-
|
285
|
+
|
284
286
|
it "fecha_inicio_quincena_siguiente" do
|
285
287
|
fecha_inicio_quincena_siguiente(Date.new(2010,1,1)).should == Date.new(2010,1,16)
|
286
288
|
fecha_inicio_quincena_siguiente(Date.new(2010,1,10)).should == Date.new(2010,1,16)
|
287
289
|
fecha_inicio_quincena_siguiente(Date.new(2010,1,15)).should == Date.new(2010,1,16)
|
288
|
-
|
290
|
+
|
289
291
|
fecha_inicio_quincena_siguiente(Date.new(2010,1,16)).should == Date.new(2010,2,1)
|
290
292
|
fecha_inicio_quincena_siguiente(Date.new(2010,1,20)).should == Date.new(2010,2,1)
|
291
293
|
fecha_inicio_quincena_siguiente(Date.new(2010,1,31)).should == Date.new(2010,2,1)
|
292
294
|
fecha_inicio_quincena_siguiente(Date.new(2010,12,31)).should == Date.new(2011,1,1)
|
293
295
|
end
|
294
|
-
|
296
|
+
|
295
297
|
def fecha_inicio_quincena_siguiente fecha
|
296
298
|
Date.stubs(today: fecha)
|
297
299
|
subject.fecha_inicio_quincena_siguiente
|
298
300
|
end
|
299
301
|
end
|
300
|
-
|
302
|
+
|
301
303
|
context "comprobante_to_request" do
|
302
304
|
def c2r comprobante
|
303
305
|
subject.comprobante_to_request comprobante
|
304
306
|
end
|
305
|
-
|
307
|
+
|
306
308
|
it "no debería enviar tag tributos si el impTrib es 0" do
|
307
309
|
c2r(imp_trib: 0.0, tributos: { tributo: [] }).should_not have_key :tributos
|
308
310
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: afipws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emmanuel Nicolau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|