afipws 0.1.4 → 0.1.6
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.
- data/.gitignore +2 -1
- data/Gemfile.lock +1 -1
- data/lib/afipws/core_ext/hash.rb +29 -0
- data/lib/afipws/version.rb +1 -1
- data/lib/afipws/wsfe.rb +5 -6
- data/lib/afipws.rb +1 -1
- data/spec/{core_ext → afipws/core_ext}/hash_spec.rb +1 -1
- data/spec/afipws/wsfe_spec.rb +2 -1
- metadata +7 -7
- data/lib/core_ext/hash.rb +0 -21
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Afipws
|
2
|
+
module CoreExt
|
3
|
+
module Hash
|
4
|
+
def fetch_path path
|
5
|
+
path.split('/').drop(1).inject(self) do |hash, key|
|
6
|
+
if scan = key.scan(/\[[\d+]\]/).first
|
7
|
+
key.sub! scan, ''
|
8
|
+
idx = scan.scan(/\d+/).first.to_i
|
9
|
+
hash.respond_to?(:has_key?) && hash.has_key?(key) ? hash[key][idx] : break
|
10
|
+
else
|
11
|
+
hash.respond_to?(:has_key?) && hash.has_key?(key) ? hash[key] : break
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def select_keys *keys
|
17
|
+
select { |k, _| keys.include? k }
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_entries? entries
|
21
|
+
entries.each_pair.all? { |k, v| self[k] == v }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Hash
|
28
|
+
include Afipws::CoreExt::Hash
|
29
|
+
end
|
data/lib/afipws/version.rb
CHANGED
data/lib/afipws/wsfe.rb
CHANGED
@@ -71,10 +71,9 @@ module Afipws
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def comprobante_to_request comprobante
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
:mon_id, :mon_cotiz, :iva, :tributos).merge({ 'ImpIVA' => comprobante[:imp_iva] })
|
74
|
+
nro = comprobante.delete :cbte_nro
|
75
|
+
iva = comprobante.delete :imp_iva
|
76
|
+
comprobante.merge :cbte_desde => nro, :cbte_hasta => nro, 'ImpIVA' => iva
|
78
77
|
end
|
79
78
|
|
80
79
|
def solicitar_caea
|
@@ -96,7 +95,7 @@ module Afipws
|
|
96
95
|
request = { 'FeCAEARegInfReq' => {
|
97
96
|
'FeCabReq' => opciones.select_keys(:cbte_tipo, :pto_vta).merge(:cant_reg => comprobantes.size),
|
98
97
|
'FeDetReq' => { 'FECAEADetRequest' => comprobantes.map do |comprobante|
|
99
|
-
comprobante_to_request
|
98
|
+
comprobante_to_request comprobante.merge('CAEA' => comprobante.delete(:caea))
|
100
99
|
end
|
101
100
|
}}}
|
102
101
|
r = @client.fecaea_reg_informativo auth.merge r2x(request, :cbte_fch => :date)
|
@@ -116,7 +115,7 @@ module Afipws
|
|
116
115
|
end
|
117
116
|
|
118
117
|
def consultar_comprobante opciones
|
119
|
-
@client.fe_comp_consultar(auth.merge(opciones))[:result_get]
|
118
|
+
@client.fe_comp_consultar(auth.merge(:fe_comp_cons_req => opciones))[:result_get]
|
120
119
|
end
|
121
120
|
|
122
121
|
def cant_max_registros_x_lote
|
data/lib/afipws.rb
CHANGED
data/spec/afipws/wsfe_spec.rb
CHANGED
@@ -215,7 +215,8 @@ describe Afipws::WSFE do
|
|
215
215
|
end
|
216
216
|
|
217
217
|
it "consultar_comprobante" do
|
218
|
-
savon.expects('FECompConsultar').with(
|
218
|
+
savon.expects('FECompConsultar').with(has_path '/Auth/Token' => 't',
|
219
|
+
'/FeCompConsReq/PtoVta' => 1, '/FeCompConsReq/CbteTipo' => 2, '/FeCompConsReq/CbteNro' => 3).returns(:success)
|
219
220
|
rta = ws.consultar_comprobante(:pto_vta => 1, :cbte_tipo => 2, :cbte_nro => 3)
|
220
221
|
rta[:cod_autorizacion].should == '61023008595705'
|
221
222
|
rta[:emision_tipo].should == 'CAE'
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: afipws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Emmanuel Nicolau
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-07 00:00:00 -03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -134,18 +134,18 @@ files:
|
|
134
134
|
- autotest/discover.rb
|
135
135
|
- lib/afipws.rb
|
136
136
|
- lib/afipws/client.rb
|
137
|
+
- lib/afipws/core_ext/hash.rb
|
137
138
|
- lib/afipws/excepciones.rb
|
138
139
|
- lib/afipws/type_conversions.rb
|
139
140
|
- lib/afipws/version.rb
|
140
141
|
- lib/afipws/wsaa.rb
|
141
142
|
- lib/afipws/wsfe.rb
|
142
|
-
-
|
143
|
+
- spec/afipws/core_ext/hash_spec.rb
|
143
144
|
- spec/afipws/test.crt
|
144
145
|
- spec/afipws/test.key
|
145
146
|
- spec/afipws/type_conversions_spec.rb
|
146
147
|
- spec/afipws/wsaa_spec.rb
|
147
148
|
- spec/afipws/wsfe_spec.rb
|
148
|
-
- spec/core_ext/hash_spec.rb
|
149
149
|
- spec/fixtures/fe_comp_consultar/success.xml
|
150
150
|
- spec/fixtures/fe_comp_tot_x_request/success.xml
|
151
151
|
- spec/fixtures/fe_comp_ultimo_autorizado/success.xml
|
@@ -193,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
193
|
requirements:
|
194
194
|
- - ">="
|
195
195
|
- !ruby/object:Gem::Version
|
196
|
-
hash:
|
196
|
+
hash: -1452844401751397239
|
197
197
|
segments:
|
198
198
|
- 0
|
199
199
|
version: "0"
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
requirements:
|
203
203
|
- - ">="
|
204
204
|
- !ruby/object:Gem::Version
|
205
|
-
hash:
|
205
|
+
hash: -1452844401751397239
|
206
206
|
segments:
|
207
207
|
- 0
|
208
208
|
version: "0"
|
@@ -214,12 +214,12 @@ signing_key:
|
|
214
214
|
specification_version: 3
|
215
215
|
summary: Ruby wrapper para los servicios web de la AFIP
|
216
216
|
test_files:
|
217
|
+
- spec/afipws/core_ext/hash_spec.rb
|
217
218
|
- spec/afipws/test.crt
|
218
219
|
- spec/afipws/test.key
|
219
220
|
- spec/afipws/type_conversions_spec.rb
|
220
221
|
- spec/afipws/wsaa_spec.rb
|
221
222
|
- spec/afipws/wsfe_spec.rb
|
222
|
-
- spec/core_ext/hash_spec.rb
|
223
223
|
- spec/fixtures/fe_comp_consultar/success.xml
|
224
224
|
- spec/fixtures/fe_comp_tot_x_request/success.xml
|
225
225
|
- spec/fixtures/fe_comp_ultimo_autorizado/success.xml
|
data/lib/core_ext/hash.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
def fetch_path path
|
3
|
-
path.split('/').drop(1).inject(self) do |hash, key|
|
4
|
-
if scan = key.scan(/\[[\d+]\]/).first
|
5
|
-
key.sub! scan, ''
|
6
|
-
idx = scan.scan(/\d+/).first.to_i
|
7
|
-
hash.respond_to?(:has_key?) && hash.has_key?(key) ? hash[key][idx] : break
|
8
|
-
else
|
9
|
-
hash.respond_to?(:has_key?) && hash.has_key?(key) ? hash[key] : break
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def select_keys *keys
|
15
|
-
select { |k, _| keys.include? k }
|
16
|
-
end
|
17
|
-
|
18
|
-
def has_entries? entries
|
19
|
-
entries.each_pair.all? { |k, v| self[k] == v }
|
20
|
-
end
|
21
|
-
end
|