afipws 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,4 +2,5 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  spec/manual/*.key
5
- spec/manual/*.crt
5
+ spec/manual/*.crt
6
+ .DS_Store
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afipws (0.1.4)
4
+ afipws (0.1.6)
5
5
  activesupport
6
6
  builder
7
7
  httpclient
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Afipws
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.6"
3
3
  end
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
- comprobante.merge(:cbte_desde => comprobante[:cbte_nro], :cbte_hasta => comprobante[:cbte_nro]).
75
- select_keys(:concepto, :doc_tipo, :doc_nro, :cbte_desde,
76
- :cbte_hasta, :cbte_fch, :imp_total, :imp_tot_conc, :imp_neto, :imp_op_ex, :imp_trib,
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(comprobante).merge('CAEA' => comprobante[:caea])
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
@@ -8,7 +8,7 @@ require 'base64'
8
8
  require 'savon'
9
9
  require 'nokogiri'
10
10
  require 'active_support/core_ext'
11
- require 'core_ext/hash'
11
+ require 'afipws/core_ext/hash'
12
12
  require 'afipws/excepciones'
13
13
  require 'afipws/type_conversions'
14
14
  require 'afipws/client'
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
3
3
 
4
4
  describe Hash do
5
5
  context "fetch_path" do
@@ -215,7 +215,8 @@ describe Afipws::WSFE do
215
215
  end
216
216
 
217
217
  it "consultar_comprobante" do
218
- savon.expects('FECompConsultar').with(has_entries 'wsdl:PtoVta' => 1, 'wsdl:CbteTipo' => 2, 'wsdl:CbteNro' => 3).returns(:success)
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.4
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-04 00:00:00 -03:00
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
- - lib/core_ext/hash.rb
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: 1641972703349920218
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: 1641972703349920218
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