afipws 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +69 -0
- data/README.rdoc +32 -0
- data/Rakefile +7 -0
- data/afipws.gemspec +29 -0
- data/autotest/discover.rb +1 -0
- data/lib/afipws.rb +23 -0
- data/lib/afipws/client.rb +48 -0
- data/lib/afipws/excepciones.rb +13 -0
- data/lib/afipws/type_conversions.rb +38 -0
- data/lib/afipws/version.rb +3 -0
- data/lib/afipws/wsaa.rb +77 -0
- data/lib/afipws/wsfe.rb +88 -0
- data/lib/core_ext/hash.rb +21 -0
- data/lib/core_ext/string.rb +9 -0
- data/spec/afipws/test.crt +17 -0
- data/spec/afipws/test.key +15 -0
- data/spec/afipws/type_conversions_spec.rb +30 -0
- data/spec/afipws/wsaa_spec.rb +68 -0
- data/spec/afipws/wsfe_spec.rb +163 -0
- data/spec/core_ext/hash_spec.rb +44 -0
- data/spec/fixtures/fe_comp_consultar/success.xml +41 -0
- data/spec/fixtures/fe_comp_tot_x_request/success.xml +9 -0
- data/spec/fixtures/fe_comp_ultimo_autorizado/success.xml +11 -0
- data/spec/fixtures/fe_dummy/success.xml +11 -0
- data/spec/fixtures/fe_param_get_cotizacion/dolar.xml +13 -0
- data/spec/fixtures/fe_param_get_cotizacion/inexistente.xml +14 -0
- data/spec/fixtures/fe_param_get_tipos_cbte/failure_1_error.xml +14 -0
- data/spec/fixtures/fe_param_get_tipos_cbte/failure_2_errors.xml +18 -0
- data/spec/fixtures/fe_param_get_tipos_cbte/success.xml +22 -0
- data/spec/fixtures/fe_param_get_tipos_doc/success.xml +16 -0
- data/spec/fixtures/fe_param_get_tipos_iva/success.xml +16 -0
- data/spec/fixtures/fe_param_get_tipos_monedas/success.xml +22 -0
- data/spec/fixtures/fe_param_get_tipos_tributos/success.xml +16 -0
- data/spec/fixtures/fecae_solicitar/autorizacion_1_cbte.xml +30 -0
- data/spec/fixtures/fecae_solicitar/autorizacion_2_cbtes.xml +41 -0
- data/spec/fixtures/fecae_solicitar/observaciones.xml +40 -0
- data/spec/fixtures/login_cms/fault.xml +12 -0
- data/spec/fixtures/login_cms/success.xml +16 -0
- data/spec/fixtures/login_cms/token_expirado.xml +14 -0
- data/spec/fixtures/wsaa.wsdl +103 -0
- data/spec/fixtures/wsfe.wsdl +1372 -0
- data/spec/manual/autorizar_comprobante.rb +22 -0
- data/spec/manual/generar_keys.txt +8 -0
- data/spec/manual/obtener_ta.rb +18 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/matchers.rb +37 -0
- metadata +237 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../lib')))
|
2
|
+
require 'afipws'
|
3
|
+
|
4
|
+
Savon.configure { |config| config.log = true }
|
5
|
+
|
6
|
+
ws = Afipws::WSFE.new :env => :dev, :cuit => '20300032673',
|
7
|
+
:cert => File.read(File.dirname(__FILE__) + '/test.crt'),
|
8
|
+
:key => File.read(File.dirname(__FILE__) + '/test.key')
|
9
|
+
|
10
|
+
ultimo = ws.ultimo_comprobante_autorizado :pto_vta => 1, :cbte_tipo => 1
|
11
|
+
puts ws.autorizar_comprobantes(:cbte_tipo => 1, :pto_vta => 1, :comprobantes => [
|
12
|
+
{
|
13
|
+
:cbte_nro => ultimo + 1, :concepto => 1, :doc_nro => 30521189203, :doc_tipo => 80, :cbte_fch => Date.new(2011,01,13),
|
14
|
+
:imp_total => 1270.48, :imp_neto => 1049.98, :imp_iva => 220.50, :mon_id => 'PES', :mon_cotiz => 1,
|
15
|
+
:iva => { :alic_iva => [{ :id => 5, :base_imp => 1049.98, :importe => 220.50 }]}
|
16
|
+
},
|
17
|
+
{
|
18
|
+
:cbte_nro => ultimo + 2, :concepto => 1, :doc_nro => 30521189203, :doc_tipo => 80, :cbte_fch => Date.new(2011,01,13),
|
19
|
+
:imp_total => 1270.48, :imp_neto => 1049.98, :imp_iva => 220.50, :mon_id => 'PES', :mon_cotiz => 1,
|
20
|
+
:iva => { :alic_iva => [{ :id => 5, :base_imp => 1049.98, :importe => 220.60 }]}
|
21
|
+
}
|
22
|
+
])
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Generar clave privada
|
2
|
+
openssl genrsa -out test.key 1024
|
3
|
+
|
4
|
+
# Generar el CSR para enviar a la AFIP
|
5
|
+
openssl req -new -key test.key -subj "/C=AR/O=[empresa]/CN=[nombre]/serialNumber=CUIT [nro_cuit]" -out test.csr
|
6
|
+
|
7
|
+
# Genera un certificado firmado por nosotros, sería el paso que tiene que hacer la AFIP en base al CSR
|
8
|
+
openssl req -x509 -days 1095 -out test.crt -verify -key test.key -sha1 -new -batch
|
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../lib')))
|
2
|
+
require 'afipws'
|
3
|
+
|
4
|
+
Savon.configure { |config| config.log = true }
|
5
|
+
|
6
|
+
ws = Afipws::WSFE.new :env => :dev, :cuit => '20300032673',
|
7
|
+
:cert => File.read(File.dirname(__FILE__) + '/test.crt'),
|
8
|
+
:key => File.read(File.dirname(__FILE__) + '/test.key')
|
9
|
+
|
10
|
+
puts ws.cotizacion 'DOL'
|
11
|
+
|
12
|
+
xml = Builder::XmlMarkup.new indent: 2
|
13
|
+
xml.ar :Auth do
|
14
|
+
xml.ar :Token, ws.ta[:token]
|
15
|
+
xml.ar :Sign, ws.ta[:sign]
|
16
|
+
xml.ar :Cuit, ws.cuit
|
17
|
+
end
|
18
|
+
puts xml.target!
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'ruby-debug'
|
3
|
+
require 'afipws'
|
4
|
+
require 'savon_spec'
|
5
|
+
|
6
|
+
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.include Savon::Spec::Macros
|
10
|
+
end
|
11
|
+
|
12
|
+
Savon::Spec::Fixture.path = File.expand_path("../fixtures", __FILE__)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
RSpec::Matchers.define :match_xpath do |xpath, expected_text|
|
2
|
+
match do |xml|
|
3
|
+
xml = Nokogiri::XML xml
|
4
|
+
xml.xpath(xpath).text.should == expected_text
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'mocha/parameter_matchers/base'
|
9
|
+
|
10
|
+
module Mocha
|
11
|
+
module ParameterMatchers
|
12
|
+
def has_path(paths)
|
13
|
+
HasPath.new(paths)
|
14
|
+
end
|
15
|
+
|
16
|
+
class HasPath < Base # :nodoc:
|
17
|
+
def initialize(paths)
|
18
|
+
@paths = paths
|
19
|
+
end
|
20
|
+
|
21
|
+
def matches?(available_parameters)
|
22
|
+
parameter = available_parameters.shift
|
23
|
+
return false unless parameter.is_a? Hash
|
24
|
+
@paths.all? do |path|
|
25
|
+
path, expected_value = path
|
26
|
+
actual_value = parameter.fetch_path path.gsub('/', '/wsdl:')
|
27
|
+
@failed_path, @failed_value, @actual_value = path, expected_value, actual_value
|
28
|
+
expected_value == actual_value
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def mocha_inspect
|
33
|
+
"has_path(#{@failed_path.mocha_inspect} => #{@failed_value.mocha_inspect} | Actual: #{@actual_value.mocha_inspect})"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: afipws
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Emmanuel Nicolau
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-15 00:00:00 -03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: ruby-debug19
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
version: "0"
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: savon_spec
|
48
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
55
|
+
version: "0"
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: builder
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *id004
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: savon
|
74
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: *id005
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: nokogiri
|
87
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
type: :runtime
|
96
|
+
prerelease: false
|
97
|
+
version_requirements: *id006
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: activesupport
|
100
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
type: :runtime
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: *id007
|
111
|
+
description: ""
|
112
|
+
email:
|
113
|
+
- emmanicolau@gmail.com
|
114
|
+
executables: []
|
115
|
+
|
116
|
+
extensions: []
|
117
|
+
|
118
|
+
extra_rdoc_files: []
|
119
|
+
|
120
|
+
files:
|
121
|
+
- .gitignore
|
122
|
+
- .rspec
|
123
|
+
- .rvmrc
|
124
|
+
- Gemfile
|
125
|
+
- Gemfile.lock
|
126
|
+
- README.rdoc
|
127
|
+
- Rakefile
|
128
|
+
- afipws.gemspec
|
129
|
+
- autotest/discover.rb
|
130
|
+
- lib/afipws.rb
|
131
|
+
- lib/afipws/client.rb
|
132
|
+
- lib/afipws/excepciones.rb
|
133
|
+
- lib/afipws/type_conversions.rb
|
134
|
+
- lib/afipws/version.rb
|
135
|
+
- lib/afipws/wsaa.rb
|
136
|
+
- lib/afipws/wsfe.rb
|
137
|
+
- lib/core_ext/hash.rb
|
138
|
+
- lib/core_ext/string.rb
|
139
|
+
- spec/afipws/test.crt
|
140
|
+
- spec/afipws/test.key
|
141
|
+
- spec/afipws/type_conversions_spec.rb
|
142
|
+
- spec/afipws/wsaa_spec.rb
|
143
|
+
- spec/afipws/wsfe_spec.rb
|
144
|
+
- spec/core_ext/hash_spec.rb
|
145
|
+
- spec/fixtures/fe_comp_consultar/success.xml
|
146
|
+
- spec/fixtures/fe_comp_tot_x_request/success.xml
|
147
|
+
- spec/fixtures/fe_comp_ultimo_autorizado/success.xml
|
148
|
+
- spec/fixtures/fe_dummy/success.xml
|
149
|
+
- spec/fixtures/fe_param_get_cotizacion/dolar.xml
|
150
|
+
- spec/fixtures/fe_param_get_cotizacion/inexistente.xml
|
151
|
+
- spec/fixtures/fe_param_get_tipos_cbte/failure_1_error.xml
|
152
|
+
- spec/fixtures/fe_param_get_tipos_cbte/failure_2_errors.xml
|
153
|
+
- spec/fixtures/fe_param_get_tipos_cbte/success.xml
|
154
|
+
- spec/fixtures/fe_param_get_tipos_doc/success.xml
|
155
|
+
- spec/fixtures/fe_param_get_tipos_iva/success.xml
|
156
|
+
- spec/fixtures/fe_param_get_tipos_monedas/success.xml
|
157
|
+
- spec/fixtures/fe_param_get_tipos_tributos/success.xml
|
158
|
+
- spec/fixtures/fecae_solicitar/autorizacion_1_cbte.xml
|
159
|
+
- spec/fixtures/fecae_solicitar/autorizacion_2_cbtes.xml
|
160
|
+
- spec/fixtures/fecae_solicitar/observaciones.xml
|
161
|
+
- spec/fixtures/login_cms/fault.xml
|
162
|
+
- spec/fixtures/login_cms/success.xml
|
163
|
+
- spec/fixtures/login_cms/token_expirado.xml
|
164
|
+
- spec/fixtures/wsaa.wsdl
|
165
|
+
- spec/fixtures/wsfe.wsdl
|
166
|
+
- spec/manual/autorizar_comprobante.rb
|
167
|
+
- spec/manual/generar_keys.txt
|
168
|
+
- spec/manual/obtener_ta.rb
|
169
|
+
- spec/spec_helper.rb
|
170
|
+
- spec/support/matchers.rb
|
171
|
+
has_rdoc: true
|
172
|
+
homepage: ""
|
173
|
+
licenses: []
|
174
|
+
|
175
|
+
post_install_message:
|
176
|
+
rdoc_options: []
|
177
|
+
|
178
|
+
require_paths:
|
179
|
+
- lib
|
180
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
+
none: false
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
hash: 3053918470372458206
|
186
|
+
segments:
|
187
|
+
- 0
|
188
|
+
version: "0"
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
none: false
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
hash: 3053918470372458206
|
195
|
+
segments:
|
196
|
+
- 0
|
197
|
+
version: "0"
|
198
|
+
requirements: []
|
199
|
+
|
200
|
+
rubyforge_project: afipws
|
201
|
+
rubygems_version: 1.3.7
|
202
|
+
signing_key:
|
203
|
+
specification_version: 3
|
204
|
+
summary: Ruby wrapper para los servicios web de la AFIP
|
205
|
+
test_files:
|
206
|
+
- spec/afipws/test.crt
|
207
|
+
- spec/afipws/test.key
|
208
|
+
- spec/afipws/type_conversions_spec.rb
|
209
|
+
- spec/afipws/wsaa_spec.rb
|
210
|
+
- spec/afipws/wsfe_spec.rb
|
211
|
+
- spec/core_ext/hash_spec.rb
|
212
|
+
- spec/fixtures/fe_comp_consultar/success.xml
|
213
|
+
- spec/fixtures/fe_comp_tot_x_request/success.xml
|
214
|
+
- spec/fixtures/fe_comp_ultimo_autorizado/success.xml
|
215
|
+
- spec/fixtures/fe_dummy/success.xml
|
216
|
+
- spec/fixtures/fe_param_get_cotizacion/dolar.xml
|
217
|
+
- spec/fixtures/fe_param_get_cotizacion/inexistente.xml
|
218
|
+
- spec/fixtures/fe_param_get_tipos_cbte/failure_1_error.xml
|
219
|
+
- spec/fixtures/fe_param_get_tipos_cbte/failure_2_errors.xml
|
220
|
+
- spec/fixtures/fe_param_get_tipos_cbte/success.xml
|
221
|
+
- spec/fixtures/fe_param_get_tipos_doc/success.xml
|
222
|
+
- spec/fixtures/fe_param_get_tipos_iva/success.xml
|
223
|
+
- spec/fixtures/fe_param_get_tipos_monedas/success.xml
|
224
|
+
- spec/fixtures/fe_param_get_tipos_tributos/success.xml
|
225
|
+
- spec/fixtures/fecae_solicitar/autorizacion_1_cbte.xml
|
226
|
+
- spec/fixtures/fecae_solicitar/autorizacion_2_cbtes.xml
|
227
|
+
- spec/fixtures/fecae_solicitar/observaciones.xml
|
228
|
+
- spec/fixtures/login_cms/fault.xml
|
229
|
+
- spec/fixtures/login_cms/success.xml
|
230
|
+
- spec/fixtures/login_cms/token_expirado.xml
|
231
|
+
- spec/fixtures/wsaa.wsdl
|
232
|
+
- spec/fixtures/wsfe.wsdl
|
233
|
+
- spec/manual/autorizar_comprobante.rb
|
234
|
+
- spec/manual/generar_keys.txt
|
235
|
+
- spec/manual/obtener_ta.rb
|
236
|
+
- spec/spec_helper.rb
|
237
|
+
- spec/support/matchers.rb
|