snoopy_afip 3.0.4 → 4.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e25964d283e53a6ecce44bb9e47da089d46845490b1ccfa86040c491d0c68ae2
4
- data.tar.gz: f307327754e7409b336b20ce719e833296938c8f82d0e60ef0b03aa160e02b64
3
+ metadata.gz: 694608362f999627a333c8ddf14fe9d7150186aed5a2b175f6a35e329432ceff
4
+ data.tar.gz: 801c21bbbab57815fb9e4b73782e52baeb4c2eddf718e183e7a4ff19fab8bdef
5
5
  SHA512:
6
- metadata.gz: 999693f1b1c3f5f9aa943c8718f6e3ffa9faece1afe4f2ee15ada2e836a2bd80864dcd70c14c394909c80a8b185ac72cb04aa8b8ced52a6b59e928f91d85d690
7
- data.tar.gz: 9366d0c79c6d6a76a95f3ed2251f8e46716ce6213d0f9adffd0dd431f667a161df0626ff4f8ad1eccadf95fc1ac5d1747153eb65af5d739a11d37f83a271f94c
6
+ metadata.gz: efc8c215810ab33ad8141ee5d4c046db40adcae31999137bbd774ff2c60ee5d5a5bfd11ce2414af2eaf958fbf582e9e0efb3406ec8ee0326e658ea0dd231d605
7
+ data.tar.gz: 0751d4decaadc34c8a7d0450c83e18945e4aa458fee02c061bd088e72321fa6f0c143f9eac09f5226cbea6a88a3c8f9de0a1856ba9a66527ede2e9186c39a0da
data/Gemfile CHANGED
@@ -1,16 +1,17 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- group :development do
4
- platforms :ruby_18 do
5
- gem "ruby-debug"
6
- end
7
- platforms :ruby_19 do
8
- gem 'ruby-debug-base19', "0.11.24"
9
- gem 'ruby-debug19', "0.11.6"
10
- end
11
- gem "rspec", "~> 2.4.0"
12
- gem "bundler", "~> 1.0.0"
13
- gem "jeweler", "~> 1.5.1"
14
- gem "rcov", ">= 0"
15
- end
3
+ gemspec
4
+ # group :development do
5
+ # platforms :ruby_18 do
6
+ # gem "ruby-debug"
7
+ # end
8
+ # platforms :ruby_19 do
9
+ # gem 'ruby-debug-base19', "0.11.24"
10
+ # gem 'ruby-debug19', "0.11.6"
11
+ # end
12
+ # gem "rspec", "~> 2.4.0"
13
+ # gem "bundler", "~> 1.0.0"
14
+ # gem "jeweler", "~> 1.5.1"
15
+ # gem "rcov", ">= 0"
16
+ # end
16
17
 
@@ -1,57 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ snoopy_afip (4.0.1)
5
+ akami (~> 1.3.1)
6
+ nokogiri (~> 1.10.9)
7
+ nori (~> 2.6.0)
8
+ savon (~> 2.12.0)
9
+ wasabi (~> 3.5.0)
10
+
1
11
  GEM
2
12
  remote: http://rubygems.org/
3
13
  specs:
4
- archive-tar-minitar (0.5.2)
5
- builder (3.0.0)
6
- columnize (0.3.2)
7
- crack (0.1.8)
8
- diff-lcs (1.1.2)
9
- git (1.2.5)
10
- jeweler (1.5.2)
11
- bundler (~> 1.0.0)
12
- git (>= 1.2.5)
13
- rake
14
- linecache (0.43)
15
- linecache19 (0.5.11)
16
- ruby_core_source (>= 0.1.4)
17
- rake (0.8.7)
18
- rcov (0.9.9)
19
- rspec (2.4.0)
20
- rspec-core (~> 2.4.0)
21
- rspec-expectations (~> 2.4.0)
22
- rspec-mocks (~> 2.4.0)
23
- rspec-core (2.4.0)
24
- rspec-expectations (2.4.0)
25
- diff-lcs (~> 1.1.2)
26
- rspec-mocks (2.4.0)
27
- ruby-debug (0.10.4)
28
- columnize (>= 0.1)
29
- ruby-debug-base (~> 0.10.4.0)
30
- ruby-debug-base (0.10.4)
31
- linecache (>= 0.3)
32
- ruby-debug-base19 (0.11.24)
33
- columnize (>= 0.3.1)
34
- linecache19 (>= 0.5.11)
35
- ruby_core_source (>= 0.1.4)
36
- ruby-debug19 (0.11.6)
37
- columnize (>= 0.3.1)
38
- linecache19 (>= 0.5.11)
39
- ruby-debug-base19 (>= 0.11.19)
40
- ruby_core_source (0.1.4)
41
- archive-tar-minitar (>= 0.5.2)
42
- savon (0.8.6)
14
+ akami (1.3.1)
15
+ gyoku (>= 0.4.0)
16
+ nokogiri
17
+ builder (3.2.4)
18
+ gyoku (1.3.1)
43
19
  builder (>= 2.1.2)
44
- crack (>= 0.1.4)
20
+ httpi (2.4.4)
21
+ rack
22
+ socksify
23
+ mini_portile2 (2.4.0)
24
+ nokogiri (1.10.9)
25
+ mini_portile2 (~> 2.4.0)
26
+ nori (2.6.0)
27
+ rack (2.2.2)
28
+ savon (2.12.0)
29
+ akami (~> 1.2)
30
+ builder (>= 2.1.2)
31
+ gyoku (~> 1.2)
32
+ httpi (~> 2.3)
33
+ nokogiri (>= 1.8.1)
34
+ nori (~> 2.4)
35
+ wasabi (~> 3.4)
36
+ socksify (1.7.1)
37
+ wasabi (3.5.0)
38
+ httpi (~> 2.0)
39
+ nokogiri (>= 1.4.2)
45
40
 
46
41
  PLATFORMS
47
42
  ruby
48
43
 
49
44
  DEPENDENCIES
50
- bundler (~> 1.0.0)
51
- jeweler (~> 1.5.1)
52
- rcov
53
- rspec (~> 2.4.0)
54
- ruby-debug
55
- ruby-debug-base19 (= 0.11.24)
56
- ruby-debug19 (= 0.11.6)
57
- savon (= 0.8.6)
45
+ snoopy_afip!
46
+
47
+ BUNDLED WITH
48
+ 2.1.4
@@ -54,10 +54,5 @@ module Snoopy
54
54
 
55
55
  # Savon::Request.log = false unless (Snoopy.verbose == "true") || (ENV["VERBOSE"] == true)
56
56
 
57
- # Savon.configure do |config|
58
- # config.log = Snoopy.log?
59
- # config.log_level = :debug
60
- # end
61
-
62
57
  end
63
58
 
@@ -113,7 +113,7 @@ module Snoopy
113
113
 
114
114
  def client_configuration
115
115
  { :wsdl => Snoopy.auth_url,
116
- :ssl_version => :TLSv1,
116
+ :ssl_version => ::Snoopy::SNOOPY_SSL_VERSION,
117
117
  :pretty_print_xml => true }
118
118
  end
119
119
  end
@@ -23,12 +23,24 @@ module Snoopy
23
23
  { "Token" => token, "Sign" => sign, "Cuit" => cuit }
24
24
  end
25
25
 
26
+ def invoice_informed?
27
+ return false unless bill.valid?
28
+
29
+ build_body_comp_cons_request
30
+ @response = client.call(:fe_comp_consultar, :message => @comp_cons_request)
31
+ parse_fe_comp_consultar_response
32
+
33
+ afip_errors.keys.empty?
34
+ end
35
+
26
36
  def authorize!
27
37
  return false unless bill.valid?
28
- set_bill_number!
38
+ @afip_errors = {}
39
+
29
40
  build_body_request
30
- @response = client.call( :fecae_solicitar, :message => @request )
41
+ @response = client.call(:fecae_solicitar, :message => @request)
31
42
  parse_fecae_solicitar_response
43
+
32
44
  !@response.nil?
33
45
  end
34
46
 
@@ -39,7 +51,8 @@ module Snoopy
39
51
  begin
40
52
  resp_errors = resp[:fe_comp_ultimo_autorizado_response][:fe_comp_ultimo_autorizado_result][:errors]
41
53
  resp_errors.each_value { |value| errors[value[:code]] = value[:msg] } unless resp_errors.nil?
42
- bill.number = resp[:fe_comp_ultimo_autorizado_response][:fe_comp_ultimo_autorizado_result][:cbte_nro].to_i + 1 if errors.empty?
54
+ bill.number = (resp[:fe_comp_ultimo_autorizado_response][:fe_comp_ultimo_autorizado_result][:cbte_nro].to_i + 1).to_s if errors.empty?
55
+ bill.number
43
56
  rescue => e
44
57
  raise Snoopy::Exception::AuthorizeAdapter::SetBillNumberParser.new(e.message, e.backtrace)
45
58
  end
@@ -71,7 +84,7 @@ module Snoopy
71
84
  detail["ImpNeto"] = bill.total_net.to_f
72
85
  detail["ImpIVA"] = bill.iva_sum
73
86
  detail["ImpTotal"] = bill.total
74
- detail["CbteDesde"] = detail["CbteHasta"] = bill.number
87
+ detail["CbteDesde"] = detail["CbteHasta"] = bill.number.to_s
75
88
 
76
89
  unless bill.concept == "Productos"
77
90
  detail.merge!({ "FchServDesde" => bill.service_date_from || today,
@@ -82,7 +95,7 @@ module Snoopy
82
95
  if bill.receiver_iva_cond.to_s.include?("nota_credito")
83
96
  detail.merge!({"CbtesAsoc" => {"CbteAsoc" => {"Nro" => bill.cbte_asoc_num,
84
97
  "PtoVta" => bill.cbte_asoc_to_sale_point,
85
- "Tipo" => bill.cbte_type }}})
98
+ "Tipo" => bill.cbte_asoc_type }}})
86
99
  end
87
100
 
88
101
  @request = { "Auth" => auth }.merge!(fecaereq)
@@ -90,6 +103,11 @@ module Snoopy
90
103
  raise Snoopy::Exception::AuthorizeAdapter::BuildBodyRequest.new(e.message, e.backtrace)
91
104
  end
92
105
 
106
+ def build_body_comp_cons_request
107
+ fecompconsreq = { "FeCompConsReq" => { "CbteTipo" => bill.cbte_type, "CbteNro" => bill.number.to_i, "PtoVta" => bill.sale_point.to_i } }
108
+ @comp_cons_request = { "Auth" => auth }.merge!(fecompconsreq)
109
+ end
110
+
93
111
  def parse_observations(fecae_observations)
94
112
  fecae_observations.each_value do |obs|
95
113
  [obs].flatten.each { |ob| afip_observations[ob[:code]] = ob[:msg] }
@@ -144,20 +162,20 @@ module Snoopy
144
162
  result_get = fe_comp_consultar_result[:result_get]
145
163
 
146
164
  unless result_get.nil?
147
- bill.result = result_get[:resultado]
148
- bill.number = result_get[:cbte_desde]
149
- bill.cae = result_get[:cod_autorizacion]
150
- bill.due_date_cae = result_get[:fch_vto]
151
- bill.imp_iva = result_get[:imp_iva]
152
- bill.document_num = result_get[:doc_numero]
153
- bill.process_date = result_get[:fch_proceso]
154
- bill.voucher_date = result_get[:cbte_fch]
155
- bill.service_date_to = result_get[:fch_serv_hasta]
156
- bill.service_date_from = result_get[:fch_serv_desde]
165
+ # bill.result = result_get[:resultado]
166
+ # bill.number = result_get[:cbte_desde]
167
+ # bill.cae = result_get[:cod_autorizacion]
168
+ # bill.due_date_cae = result_get[:fch_vto]
169
+ # bill.imp_iva = result_get[:imp_iva]
170
+ # bill.document_num = result_get[:doc_numero]
171
+ # bill.process_date = result_get[:fch_proceso]
172
+ # bill.voucher_date = result_get[:cbte_fch]
173
+ # bill.service_date_to = result_get[:fch_serv_hasta]
174
+ # bill.service_date_from = result_get[:fch_serv_desde]
157
175
  parse_events(result_get[:observaciones]) if result_get.has_key? :observaciones
158
176
  end
159
177
 
160
- self.parse_events(fe_comp_consultar_result[:errors]) if fe_comp_consultar_result and fe_comp_consultar_result.has_key? :errors
178
+ self.parse_errors(fe_comp_consultar_result[:errors]) if fe_comp_consultar_result and fe_comp_consultar_result.has_key? :errors
161
179
  self.parse_events(fe_comp_consultar_result[:events]) if fe_comp_consultar_result and fe_comp_consultar_result.has_key? :events
162
180
  rescue => e
163
181
  @errors << Snoopy::Exception::FecompConsultResponseParser.new(e.message, e.backtrace)
@@ -167,7 +185,7 @@ module Snoopy
167
185
  { :wsdl => Snoopy.service_url,
168
186
  :headers => { "Accept-Encoding" => "gzip, deflate", "Connection" => "Keep-Alive" },
169
187
  :namespaces => {"xmlns" => "http://ar.gov.afip.dif.FEV1/"},
170
- :ssl_version => :TLSv1,
188
+ :ssl_version => ::Snoopy::SNOOPY_SSL_VERSION,
171
189
  :read_timeout => Snoopy.read_timeout,
172
190
  :open_timeout => Snoopy.open_timeout,
173
191
  :ssl_cert_file => cert,
@@ -1,27 +1,23 @@
1
1
  # coding: utf-8
2
2
  module Snoopy
3
3
  class Bill
4
- attr_accessor :total_net, :document_num, :document_type, :concept, :currency, :result,
4
+ ATTRIBUTES = [:total_net, :document_num, :document_type, :concept, :currency, :result,
5
5
  :cbte_asoc_num, :cae, :service_date_to, :due_date,
6
6
  :number, :alicivas, :cuit, :sale_point, :service_date_from,
7
- :due_date_cae, :voucher_date, :process_date, :imp_iva, :cbte_asoc_sale_point,
8
- :receiver_iva_cond, :issuer_iva_cond, :errors
7
+ :due_date_cae, :voucher_date, :process_date, :imp_iva, :cbte_asoc_to_sale_point,
8
+ :receiver_iva_cond, :issuer_iva_cond, :errors, :asoc_receiver_iva_cond]
9
9
 
10
- ATTRIBUTES = [ :total_net, :document_num, :document_type, :concept, :currency, :result,
11
- :cbte_asoc_num, :cae, :service_date_to, :due_date,
12
- :number, :alicivas, :cuit, :sale_point, :service_date_from,
13
- :due_date_cae, :voucher_date, :process_date, :imp_iva, :cbte_asoc_sale_point,
14
- :receiver_iva_cond, :issuer_iva_cond, :errors ]
15
-
16
- TAX_ATTRIBUTES = [ :id, :amount, :taxeable_base ]
10
+ TAX_ATTRIBUTES = [:id, :amount, :taxeable_base]
17
11
 
18
12
  ATTRIBUTES_PRECENSE = [:total_net, :concept, :receiver_iva_cond, :alicivas, :document_type, :service_date_from, :service_date_to, :sale_point, :issuer_iva_cond]
19
13
 
14
+ attr_accessor *ATTRIBUTES
15
+
20
16
  def initialize(attrs={})
21
17
  # attrs = attrs.deep_symbolize_keys
22
18
  @cuit = attrs[:cuit]
23
19
  @result = nil
24
- @number = nil
20
+ @number = attrs[:number]
25
21
  @errors = {}
26
22
  @concept = attrs[:concept] || Snoopy.default_concept
27
23
  @imp_iva = attrs[:imp_iva] # Monto total de impuestos
@@ -36,6 +32,7 @@ module Snoopy
36
32
  @service_date_to = attrs[:service_date_to]
37
33
  @service_date_from = attrs[:service_date_from]
38
34
  @receiver_iva_cond = attrs[:receiver_iva_cond]
35
+ @asoc_receiver_iva_cond = attrs[:asoc_receiver_iva_cond]
39
36
  @cbte_asoc_to_sale_point = attrs[:cbte_asoc_to_sale_point] # Esto es el punto de venta de la factura para la nota de credito
40
37
  end
41
38
 
@@ -81,6 +78,10 @@ module Snoopy
81
78
  Snoopy::BILL_TYPE[receiver_iva_cond.to_sym]
82
79
  end
83
80
 
81
+ def cbte_asoc_type
82
+ Snoopy::BILL_TYPE[asoc_receiver_iva_cond.to_sym]
83
+ end
84
+
84
85
  def approved?
85
86
  result == 'A'
86
87
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  module Snoopy
3
2
  CBTE_TYPE = { '01' => 'Factura A',
4
3
  '02' => 'Nota de Débito A',
@@ -21,6 +20,9 @@ module Snoopy
21
20
  '63' => 'Liquidacion A',
22
21
  '64' => 'Liquidacion B' }
23
22
 
23
+ # [:TLSv1_2, :TLSv1_1, :TLSv1, :SSLv3, :SSLv23, :SSLv2]
24
+ SNOOPY_SSL_VERSION = (ENV['SNOOPY_SSL_VERSION'] || 'TLSv1').to_sym
25
+
24
26
  RESPONSABLE_INSCRIPTO = :responsable_inscripto
25
27
  RESPONSABLE_MONOTRIBUTO = :responsable_monotributo
26
28
 
@@ -1,3 +1,3 @@
1
1
  module Snoopy
2
- VERSION = "3.0.4"
2
+ VERSION = "4.2.0"
3
3
  end
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
21
21
  s.summary = "Adaptador AFIP wsfe."
22
22
  s.test_files = ["spec/snoopy_afip/authorizer_spec.rb", "spec/snoopy_afip/bill_spec.rb", "spec/spec_helper.rb"]
23
23
 
24
- s.add_runtime_dependency('savon', ["~> 2.4"])
25
- s.add_runtime_dependency('nokogiri', ["~> 1.6"])
26
- s.add_runtime_dependency('wasabi', ["~> 3.2"])
27
- s.add_runtime_dependency('akami', ["~> 1.2"])
28
- s.add_runtime_dependency('nori', ["~> 2.3"])
24
+ s.add_runtime_dependency('savon', ["~> 2.12.0"])
25
+ s.add_runtime_dependency('nokogiri', ["~> 1.10.9"])
26
+ s.add_runtime_dependency('wasabi', ["~> 3.5.0"])
27
+ s.add_runtime_dependency('akami', ["~> 1.3.1"])
28
+ s.add_runtime_dependency('nori', ["~> 2.6.0"])
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snoopy_afip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - g.edera
@@ -16,70 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: 2.12.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.4'
26
+ version: 2.12.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.6'
33
+ version: 1.10.9
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.6'
40
+ version: 1.10.9
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: wasabi
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.2'
47
+ version: 3.5.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.2'
54
+ version: 3.5.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: akami
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.2'
61
+ version: 1.3.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.2'
68
+ version: 1.3.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nori
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.3'
75
+ version: 2.6.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.3'
82
+ version: 2.6.0
83
83
  description: Adaptador para Web Service de Facturación Electrónica Argentina (AFIP)
84
84
  email:
85
85
  - gab.edera@gmail.com
@@ -133,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubyforge_project:
137
- rubygems_version: 2.7.6
136
+ rubygems_version: 3.1.2
138
137
  signing_key:
139
138
  specification_version: 4
140
139
  summary: Adaptador AFIP wsfe.