Afip 0.9.9 → 1.0.1
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 +4 -4
- data/Afip.gemspec +1 -1
- data/Gemfile.lock +3 -3
- data/lib/Afip/bill.rb +47 -36
- data/lib/Afip/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e6eee939966afcccee165fb65c07332ce9668eff12981e3ba0277c0e82a944
|
4
|
+
data.tar.gz: 4bd17c1ddd0b19112ac808b683db43a9a6b01f364c6a7462d9019c5dc7165295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd65c2fe40e83342bc0f6b14a94a0593395f46c1791782fac974d2c14d46f638ea1410f6a562c23e18339636005b0f075f22b645d4055925fa5cee9bc5e7319
|
7
|
+
data.tar.gz: 46460c37d62aa86d48f56dc8142a2e1db6d61f94f21d82b23317bf1059a4f25604b9b304cbeb04f27330f7f8eeb7abbd162262c6a9806232e122440fed4829a6
|
data/Afip.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Comunicacion con AFIP}
|
13
13
|
spec.description = %q{Gema para la comunicacion con los Web Services de AFIP.}
|
14
|
-
spec.homepage = "
|
14
|
+
spec.homepage = "http://litecode.com.ar/"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
Afip (0.
|
4
|
+
Afip (1.0.0)
|
5
5
|
httpi
|
6
6
|
savon
|
7
7
|
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
rack
|
19
19
|
socksify
|
20
20
|
mini_portile2 (2.4.0)
|
21
|
-
nokogiri (1.10.
|
21
|
+
nokogiri (1.10.2)
|
22
22
|
mini_portile2 (~> 2.4.0)
|
23
23
|
nori (2.6.0)
|
24
24
|
rack (2.0.6)
|
@@ -45,4 +45,4 @@ DEPENDENCIES
|
|
45
45
|
rake (~> 10.0)
|
46
46
|
|
47
47
|
BUNDLED WITH
|
48
|
-
1.17.
|
48
|
+
1.17.2
|
data/lib/Afip/bill.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
module Afip
|
2
2
|
class Bill
|
3
3
|
attr_reader :cbte_type, :body, :response, :fecha_emision, :total, :client
|
4
|
-
attr_accessor :net, :doc_num, :iva_cond, :documento, :concepto, :moneda,
|
4
|
+
attr_accessor :net, :doc_num, :iva_cond, :documento, :concepto, :moneda, :cbte_type,
|
5
5
|
:due_date, :fch_serv_desde, :fch_serv_hasta, :fch_emision,
|
6
6
|
:ivas, :sale_point, :cant_reg, :no_gravado, :gravado, :exento, :otros_imp, :tributos
|
7
7
|
|
8
8
|
def initialize(attrs={})
|
9
9
|
@client = Bill.set_client
|
10
|
-
@sale_point
|
11
|
-
@body
|
12
|
-
@net
|
10
|
+
@sale_point = attrs[:sale_point]
|
11
|
+
@body = { "Auth" => Afip.auth_hash }
|
12
|
+
@net = attrs[:net] || 0.0
|
13
13
|
@documento = attrs[:documento] || Afip.default_documento
|
14
|
-
@moneda
|
14
|
+
@moneda = attrs[:moneda] || Afip.default_moneda
|
15
15
|
@iva_cond = attrs[:iva_cond]
|
16
16
|
@concepto = attrs[:concepto] || Afip.default_concepto
|
17
|
-
@ivas
|
17
|
+
@ivas = attrs[:ivas] || Array.new # [ 1, 100.00, 10.50 ], [ 2, 100.00, 21.00 ]
|
18
18
|
@fecha_emision = attrs[:fch_emision] || Time.new
|
19
19
|
@fch_serv_hasta = attrs[:fch_serv_hasta]
|
20
20
|
@fch_serv_desde = attrs[:fch_serv_desde]
|
21
21
|
@due_date = attrs[:due_date]
|
22
|
-
@cbte_type =
|
22
|
+
@cbte_type = attrs[:cbte_type]
|
23
23
|
@cant_reg = attrs[:cant_reg] || 1
|
24
24
|
@no_gravado = attrs[:no_gravado] || 0.0
|
25
|
-
@gravado
|
26
|
-
@exento
|
25
|
+
@gravado = attrs[:gravado] || 0.0
|
26
|
+
@exento = attrs[:exento] || 0.0
|
27
27
|
@otros_imp = attrs[:otros_imp] || 0.0
|
28
|
-
@total
|
28
|
+
@total = net.to_f + iva_sum.to_f + exento.to_f + no_gravado.to_f + otros_imp.to_f
|
29
29
|
@tributos = attrs[:tributos] || []
|
30
30
|
end
|
31
31
|
|
@@ -72,12 +72,12 @@ module Afip
|
|
72
72
|
|
73
73
|
def authorize
|
74
74
|
body = setup_bill
|
75
|
-
response = client.call(:fecae_solicitar, message: body)
|
76
|
-
|
75
|
+
pp response = client.call(:fecae_solicitar, message: body)
|
76
|
+
setup_response(response.to_hash)
|
77
77
|
authorized?
|
78
78
|
end
|
79
79
|
|
80
|
-
def setup_bill
|
80
|
+
def setup_bill
|
81
81
|
array_ivas = []
|
82
82
|
ivas.each{ |i|
|
83
83
|
array_ivas << {
|
@@ -90,16 +90,27 @@ module Afip
|
|
90
90
|
}
|
91
91
|
|
92
92
|
array_tributos = []
|
93
|
-
tributos.each{ |t|
|
94
|
-
|
95
|
-
|
96
|
-
"
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
93
|
+
tributos.each{ |t|
|
94
|
+
if t[1].blank?
|
95
|
+
array_tributos << {
|
96
|
+
"Tributo" => {
|
97
|
+
"Id" => t[0],
|
98
|
+
"BaseImp" => t[2].to_f.round(2),
|
99
|
+
"Alic" => t[3].to_f.round(2),
|
100
|
+
"Importe" => t[4].to_f.round(2)
|
101
|
+
}
|
101
102
|
}
|
102
|
-
|
103
|
+
else
|
104
|
+
array_tributos << {
|
105
|
+
"Tributo" => {
|
106
|
+
"Id" => t[0],
|
107
|
+
"Desc" => t[1],
|
108
|
+
"BaseImp" => t[2].to_f.round(2),
|
109
|
+
"Alic" => t[3].to_f.round(2),
|
110
|
+
"Importe" => t[4].to_f.round(2)
|
111
|
+
}
|
112
|
+
}
|
113
|
+
end
|
103
114
|
}
|
104
115
|
|
105
116
|
fecaereq = {
|
@@ -179,32 +190,32 @@ module Afip
|
|
179
190
|
# TODO: turn this into an all-purpose Response class
|
180
191
|
|
181
192
|
result = response[:fecae_solicitar_response][:fecae_solicitar_result]
|
182
|
-
|
183
|
-
if not result[:fe_det_resp] or not result[:fe_cab_resp] then
|
184
|
-
# Si no obtuvo respuesta ni cabecera ni detalle, evito hacer '[]' sobre algo indefinido.
|
193
|
+
|
194
|
+
if not result[:fe_det_resp] or not result[:fe_cab_resp] then
|
195
|
+
# Si no obtuvo respuesta ni cabecera ni detalle, evito hacer '[]' sobre algo indefinido.
|
185
196
|
# Ejemplo: Error con el token-sign de WSAA
|
186
197
|
keys, values = {
|
187
198
|
:errores => result[:errors],
|
188
199
|
:header_result => {:resultado => "X" },
|
189
200
|
:observaciones => nil
|
190
201
|
}.to_a.transpose
|
191
|
-
@response = (defined?(Struct::ResponseMal) ? Struct::ResponseMal : Struct.new("ResponseMal", *keys)).new(*values)
|
202
|
+
@response = (defined?(Struct::ResponseMal) ? Struct::ResponseMal : Struct.new("ResponseMal", *keys)).new(*values)
|
192
203
|
return
|
193
|
-
end
|
194
|
-
|
204
|
+
end
|
205
|
+
|
195
206
|
response_header = result[:fe_cab_resp]
|
196
207
|
response_detail = result[:fe_det_resp][:fecae_det_response]
|
197
208
|
|
198
209
|
request_header = body["FeCAEReq"]["FeCabReq"].underscore_keys.symbolize_keys
|
199
210
|
request_detail = body["FeCAEReq"]["FeDetReq"]["FECAEDetRequest"].underscore_keys.symbolize_keys
|
200
|
-
|
211
|
+
|
201
212
|
# Esto no funciona desde que se soportan múltiples alícuotas de iva simultáneas
|
202
213
|
# FIX ? TO-DO
|
203
214
|
# iva = request_detail.delete(:iva)["AlicIva"].underscore_keys.symbolize_keys
|
204
|
-
# request_detail.merge!(iva)
|
205
|
-
|
215
|
+
# request_detail.merge!(iva)
|
216
|
+
|
206
217
|
if result[:errors] then
|
207
|
-
response_detail.merge!( result[:errors] )
|
218
|
+
response_detail.merge!( result[:errors] )
|
208
219
|
end
|
209
220
|
|
210
221
|
response_hash = {
|
@@ -218,17 +229,17 @@ module Afip
|
|
218
229
|
:moneda => request_detail.delete(:mon_id),
|
219
230
|
:cotizacion => request_detail.delete(:mon_cotiz),
|
220
231
|
:iva_base_imp => request_detail.delete(:base_imp),
|
221
|
-
:doc_num => request_detail.delete(:doc_nro),
|
232
|
+
:doc_num => request_detail.delete(:doc_nro),
|
222
233
|
:observaciones => response_detail.delete(:observaciones),
|
223
|
-
:errores => response_detail.delete(:err)
|
234
|
+
:errores => response_detail.delete(:err)
|
224
235
|
}.merge!(request_header).merge!(request_detail)
|
225
236
|
|
226
237
|
keys, values = response_hash.to_a.transpose
|
227
238
|
@response = (defined?(Struct::Response) ? Struct::Response : Struct.new("Response", *keys)).new(*values)
|
228
239
|
end
|
229
240
|
|
230
|
-
def authorized?
|
241
|
+
def authorized?
|
231
242
|
!response.nil? && response.header_result == "A" && response.detail_result == "A"
|
232
243
|
end
|
233
244
|
end
|
234
|
-
end
|
245
|
+
end
|
data/lib/Afip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Afip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facundo A. Díaz Martínez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -96,7 +96,7 @@ files:
|
|
96
96
|
- lib/Afip/padron.rb
|
97
97
|
- lib/Afip/version.rb
|
98
98
|
- lib/Afip/wsaa.rb
|
99
|
-
homepage:
|
99
|
+
homepage: http://litecode.com.ar/
|
100
100
|
licenses:
|
101
101
|
- MIT
|
102
102
|
metadata:
|
@@ -116,8 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
|
120
|
-
rubygems_version: 2.7.8
|
119
|
+
rubygems_version: 3.0.1
|
121
120
|
signing_key:
|
122
121
|
specification_version: 4
|
123
122
|
summary: Comunicacion con AFIP
|