snoopy_afip 3.0.5 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 46470b6143f16caf2965b39a51acd2a098a38b2e
4
- data.tar.gz: 96a89dd51c7c3000322ab1aeda7a244099d86589
2
+ SHA256:
3
+ metadata.gz: 9db972edf8d732f6395b81d338b287e1a98c5a3498963019aa52527e2db819f6
4
+ data.tar.gz: 5b2cadf326bf6b0bf8e7efd280d9221d7871963dc5629d69f94298eef2b0e226
5
5
  SHA512:
6
- metadata.gz: 70787ef53b826ed11930182aa9c77ae16e0db382765f31fd82f6de804def4996ea53c772572d7709153274327f7abf9c15a3cd6894554253580ede86f208b60d
7
- data.tar.gz: 254918778efc12e82bae5ea229f06e80a5443bcc216bb1ebbb3eb2e8a23a7788de5cd6fb82e71520621c42aee955d770522cc2a6876f40bb95adbe77d2f8213b
6
+ metadata.gz: 559be5ddebeeaa7064b97f76b2187458645a28be9afdd2ccfd6ae8818e26f6b94ac817d53bb2a39ce2ea6f7372fe848c5981220869a3ab5c0f5db808db40d99e
7
+ data.tar.gz: 11cd79757d6cf297a6136a408bfd88eb4b71b5a586446b61570b3ad0830c2e83753739618c6ee5690893291eb6202f228aeae252ddd61ae50943dc5d37eb52bd
@@ -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,
@@ -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)
@@ -17,7 +17,7 @@ module Snoopy
17
17
  # attrs = attrs.deep_symbolize_keys
18
18
  @cuit = attrs[:cuit]
19
19
  @result = nil
20
- @number = nil
20
+ @number = attrs[:number]
21
21
  @errors = {}
22
22
  @concept = attrs[:concept] || Snoopy.default_concept
23
23
  @imp_iva = attrs[:imp_iva] # Monto total de impuestos
@@ -1,3 +1,3 @@
1
1
  module Snoopy
2
- VERSION = "3.0.5"
2
+ VERSION = "4.0.0"
3
3
  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.5
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - g.edera
@@ -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.6.11
136
+ rubygems_version: 3.0.4
138
137
  signing_key:
139
138
  specification_version: 4
140
139
  summary: Adaptador AFIP wsfe.