afipws 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- afipws (0.1.3)
4
+ afipws (0.1.4)
5
5
  activesupport
6
6
  builder
7
7
  httpclient
@@ -1,3 +1,3 @@
1
1
  module Afipws
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/afipws/wsfe.rb CHANGED
@@ -60,13 +60,7 @@ module Afipws
60
60
  comprobantes = opciones[:comprobantes]
61
61
  request = { 'FeCAEReq' => {
62
62
  'FeCabReq' => opciones.select_keys(:cbte_tipo, :pto_vta).merge(:cant_reg => comprobantes.size),
63
- 'FeDetReq' => {
64
- 'FECAEDetRequest' => comprobantes.map do |comprobante|
65
- comprobante.merge(:cbte_desde => comprobante[:cbte_nro], :cbte_hasta => comprobante[:cbte_nro]).
66
- select_keys(:concepto, :doc_tipo, :doc_nro, :cbte_desde,
67
- :cbte_hasta, :cbte_fch, :imp_total, :imp_tot_conc, :imp_neto, :imp_op_ex, :imp_trib,
68
- :mon_id, :mon_cotiz, :iva).merge({ 'ImpIVA' => comprobante[:imp_iva] })
69
- end
63
+ 'FeDetReq' => { 'FECAEDetRequest' => comprobantes.map { |comprobante| comprobante_to_request comprobante }
70
64
  }}}
71
65
  r = @client.fecae_solicitar auth.merge r2x(request, :cbte_fch => :date)
72
66
  r = Array.wrap(r[:fe_det_resp][:fecae_det_response]).map do |h|
@@ -76,6 +70,13 @@ module Afipws
76
70
  x2r r, :cae_fch_vto => :date, :cbte_nro => :integer, :code => :integer
77
71
  end
78
72
 
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] })
78
+ end
79
+
79
80
  def solicitar_caea
80
81
  convertir_rta_caea @client.fecaea_solicitar auth.merge(periodo_para_solicitud_caea)
81
82
  rescue Afipws::WSError => e
@@ -94,12 +95,8 @@ module Afipws
94
95
  comprobantes = opciones[:comprobantes]
95
96
  request = { 'FeCAEARegInfReq' => {
96
97
  'FeCabReq' => opciones.select_keys(:cbte_tipo, :pto_vta).merge(:cant_reg => comprobantes.size),
97
- 'FeDetReq' => {
98
- 'FECAEADetRequest' => comprobantes.map do |comprobante|
99
- comprobante.merge(:cbte_desde => comprobante[:cbte_nro], :cbte_hasta => comprobante[:cbte_nro]).
100
- select_keys(:concepto, :doc_tipo, :doc_nro, :cbte_desde,
101
- :cbte_hasta, :cbte_fch, :imp_total, :imp_tot_conc, :imp_neto, :imp_op_ex, :imp_trib,
102
- :mon_id, :mon_cotiz, :iva).merge({ 'ImpIVA' => comprobante[:imp_iva], 'CAEA' => comprobante[:caea] })
98
+ 'FeDetReq' => { 'FECAEADetRequest' => comprobantes.map do |comprobante|
99
+ comprobante_to_request(comprobante).merge('CAEA' => comprobante[:caea])
103
100
  end
104
101
  }}}
105
102
  r = @client.fecaea_reg_informativo auth.merge r2x(request, :cbte_fch => :date)
@@ -80,12 +80,17 @@ describe Afipws::WSFE do
80
80
  '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/ImpTotal' => 1270.48,
81
81
  '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/ImpIVA' => 220.5,
82
82
  '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/Iva/AlicIva[0]/Id' => 5,
83
- '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/Iva/AlicIva[0]/Importe' => 220.5
83
+ '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/Iva/AlicIva[0]/Importe' => 220.5,
84
+ '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/Tributos/Tributo[0]/Id' => 0,
85
+ '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/Tributos/Tributo[0]/BaseImp' => 150,
86
+ '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/Tributos/Tributo[0]/Alic' => 5.2,
87
+ '/FeCAEReq/FeDetReq/FECAEDetRequest[0]/Tributos/Tributo[0]/Importe' => 7.8
84
88
  ).returns(:autorizacion_1_cbte)
85
89
  rta = ws.autorizar_comprobantes(:cbte_tipo => 1, :pto_vta => 2, :comprobantes => [{:cbte_nro => 1, :concepto => 1,
86
90
  :doc_nro => 30521189203, :doc_tipo => 80, :cbte_fch => Date.new(2011,01,13),
87
91
  :imp_total => 1270.48, :imp_neto => 1049.98, :imp_iva => 220.50, :mon_id => 'PES', :mon_cotiz => 1,
88
- :iva => { :alic_iva => [{ :id => 5, :base_imp => 1049.98, :importe => 220.50 }]}
92
+ :iva => { :alic_iva => [{ :id => 5, :base_imp => 1049.98, :importe => 220.50 }]},
93
+ :tributos => { :tributo => [{ :id => 0, :base_imp => 150, :alic => 5.2, :importe => 7.8 }] }
89
94
  }])
90
95
  rta[0].should have_entries :cae => '61023008595705', :cae_fch_vto => Date.new(2011,01,23), :cbte_nro => 1,
91
96
  :resultado => 'A', :observaciones => []
data/spec/manual/test.rb CHANGED
@@ -1,11 +1,8 @@
1
- $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../lib')))
2
- require 'afipws'
1
+ $LOAD_PATH.unshift(File.expand_path('lib')); require 'afipws'
3
2
 
4
3
  Savon.configure { |config| config.log = true }
5
4
 
6
- ws = Afipws::WSFE.new :env => :development, :cuit => '20300032673',
7
- :cert => File.read(File.dirname(__FILE__) + '/test.crt'),
8
- :key => File.read(File.dirname(__FILE__) + '/test.key')
5
+ ws = Afipws::WSFE.new :env => :development, :cuit => '20300032673', :cert => File.read('spec/manual/test.crt'), :key => File.read('spec/manual/test.key')
9
6
 
10
7
  def obtener_ta ws
11
8
  ws.cotizacion 'DOL'
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afipws
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
4
+ prerelease:
5
+ version: 0.1.4
10
6
  platform: ruby
11
7
  authors:
12
8
  - Emmanuel Nicolau
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-02-02 00:00:00 -03:00
13
+ date: 2011-02-04 00:00:00 -03:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -24,8 +20,6 @@ dependencies:
24
20
  requirements:
25
21
  - - ">="
26
22
  - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
23
  version: "0"
30
24
  type: :development
31
25
  prerelease: false
@@ -37,8 +31,6 @@ dependencies:
37
31
  requirements:
38
32
  - - ">="
39
33
  - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
34
  version: "0"
43
35
  type: :development
44
36
  prerelease: false
@@ -50,8 +42,6 @@ dependencies:
50
42
  requirements:
51
43
  - - ">="
52
44
  - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
45
  version: "0"
56
46
  type: :development
57
47
  prerelease: false
@@ -63,8 +53,6 @@ dependencies:
63
53
  requirements:
64
54
  - - ">="
65
55
  - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
56
  version: "0"
69
57
  type: :runtime
70
58
  prerelease: false
@@ -76,8 +64,6 @@ dependencies:
76
64
  requirements:
77
65
  - - ">="
78
66
  - !ruby/object:Gem::Version
79
- segments:
80
- - 0
81
67
  version: "0"
82
68
  type: :runtime
83
69
  prerelease: false
@@ -89,8 +75,6 @@ dependencies:
89
75
  requirements:
90
76
  - - ">="
91
77
  - !ruby/object:Gem::Version
92
- segments:
93
- - 0
94
78
  version: "0"
95
79
  type: :runtime
96
80
  prerelease: false
@@ -102,8 +86,6 @@ dependencies:
102
86
  requirements:
103
87
  - - ">="
104
88
  - !ruby/object:Gem::Version
105
- segments:
106
- - 0
107
89
  version: "0"
108
90
  type: :runtime
109
91
  prerelease: false
@@ -115,8 +97,6 @@ dependencies:
115
97
  requirements:
116
98
  - - ">="
117
99
  - !ruby/object:Gem::Version
118
- segments:
119
- - 0
120
100
  version: "0"
121
101
  type: :runtime
122
102
  prerelease: false
@@ -128,8 +108,6 @@ dependencies:
128
108
  requirements:
129
109
  - - ">="
130
110
  - !ruby/object:Gem::Version
131
- segments:
132
- - 0
133
111
  version: "0"
134
112
  type: :runtime
135
113
  prerelease: false
@@ -215,7 +193,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
193
  requirements:
216
194
  - - ">="
217
195
  - !ruby/object:Gem::Version
218
- hash: 2410002717626230803
196
+ hash: 1641972703349920218
219
197
  segments:
220
198
  - 0
221
199
  version: "0"
@@ -224,14 +202,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
224
202
  requirements:
225
203
  - - ">="
226
204
  - !ruby/object:Gem::Version
227
- hash: 2410002717626230803
205
+ hash: 1641972703349920218
228
206
  segments:
229
207
  - 0
230
208
  version: "0"
231
209
  requirements: []
232
210
 
233
211
  rubyforge_project: afipws
234
- rubygems_version: 1.3.7
212
+ rubygems_version: 1.5.0
235
213
  signing_key:
236
214
  specification_version: 3
237
215
  summary: Ruby wrapper para los servicios web de la AFIP