Afip 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Afip-0.3.1.gem +0 -0
- data/Afip-0.3.2.gem +0 -0
- data/Gemfile.lock +1 -1
- data/lib/Afip/ctg.rb +220 -0
- data/lib/Afip/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9131a7193a596913a1469c3423c868bfe2b4955
|
4
|
+
data.tar.gz: 9aac8f49398fbc38caa798a5707726b98588c77f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0cd5ed5091148e0b63bbc880bd1f062d06f57f7575266d4159073e34ed4f9473222d8093f6daa13e74a5c7c522f0d81aed809bb1aa44310cbdcdb78c707f9cc
|
7
|
+
data.tar.gz: 0d2e667922e2ad255fb41a36adc14d69986ccfee7f00c7b2afde0549f688cb1232c085793076da61b2f0224f14faa4b881f09d351505bfd9ef577c1edd554a46
|
data/Afip-0.3.1.gem
ADDED
Binary file
|
data/Afip-0.3.2.gem
ADDED
Binary file
|
data/Gemfile.lock
CHANGED
data/lib/Afip/ctg.rb
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
module Afip
|
2
|
+
class CTG
|
3
|
+
attr_reader :client, :base_imp, :total
|
4
|
+
attr_accessor :ctg_num,:cod_especie, :cuit_canjeador,:rccc, :destino, :destinatario, :localidad_origen, :localidad_destino,
|
5
|
+
:cosecha, :peso, :cuit_transportista, :horas, :patente, :km, :cuit_corredor, :remitente_com, :body
|
6
|
+
|
7
|
+
def initialize(attrs = {})
|
8
|
+
Afip::AuthData.fetch("wsctg")
|
9
|
+
@client = Savon.client(
|
10
|
+
ssl_cert_key_file: Afip.pkey,
|
11
|
+
ssl_cert_file: Afip.cert,
|
12
|
+
env_namespace: :soapenv,
|
13
|
+
namespace_identifier: :ctg,
|
14
|
+
log: true,
|
15
|
+
logger: Rails.logger,
|
16
|
+
log_level: :debug,
|
17
|
+
pretty_print_xml: true,
|
18
|
+
encoding: 'UTF-8',
|
19
|
+
ssl_version: :TLSv1,
|
20
|
+
wsdl: Afip.service_url
|
21
|
+
)
|
22
|
+
|
23
|
+
@ctg_num = attrs[:ctg_num]
|
24
|
+
@cod_especie = attrs[:cod_especie]
|
25
|
+
@cuit_canjeador = attrs[:cuit_canjeador]
|
26
|
+
@rccc = attrs[:rccc]
|
27
|
+
@destino = attrs[:destino]
|
28
|
+
@destinatario = attrs[:destinatario]
|
29
|
+
@localidad_origen = attrs[:localidad_origen]
|
30
|
+
@localidad_destino = attrs[:localidad_destino]
|
31
|
+
@cosecha = attrs[:cosecha]
|
32
|
+
@peso = attrs[:peso]
|
33
|
+
@cuit_transportista = attrs[:cuit_transportista]
|
34
|
+
@horas = attrs[:horas]
|
35
|
+
@patente = attrs[:patente]
|
36
|
+
@km = attrs[:km]
|
37
|
+
@cuit_corredor = attrs[:cuit_corredor]
|
38
|
+
@remitente_com = attrs[:remitente_com]
|
39
|
+
@cuit_chofer = attrs[:cuit_chofer]
|
40
|
+
@cant_kilos_carta_porte = attrs[:cant_kilos_carta_porte]
|
41
|
+
@establecimiento = attrs[:establecimiento]
|
42
|
+
@cuit_solicitante = attrs[:cuit_solicitante]
|
43
|
+
@fecha_desde = attrs[:fecha_desde]
|
44
|
+
@fecha_hasta = attrs[:fecha_hasta]
|
45
|
+
|
46
|
+
@body = {"request" =>{"auth" => Afip.auth_hash}}
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.get_especies
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.get_localidades
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def solicitar_ctg_invicial
|
58
|
+
body = setup_ctg
|
59
|
+
|
60
|
+
pp response = client.call(:solicitar_ctg_inicial,message: body)
|
61
|
+
|
62
|
+
setup_response(response.to_hash)
|
63
|
+
|
64
|
+
self.authorized?
|
65
|
+
end
|
66
|
+
|
67
|
+
def setup_ctg
|
68
|
+
|
69
|
+
request = {
|
70
|
+
"datosSolicitarCTGInicial" =>{
|
71
|
+
"cartaPorte" => @ctg_num.to_i, #long
|
72
|
+
"codigoEspecie" => @cod_especie, #int
|
73
|
+
#"cuitCanjeador" => @cuit_canjeador.to_i, #long
|
74
|
+
#"remitenteComercialComoCanjeador" => @rccc,
|
75
|
+
"cuitDestino" => @destino.to_i, #long
|
76
|
+
"cuitDestinatario" => @destinatario.to_i, #long
|
77
|
+
"codigoLocalidadOrigen" => @localidad_origen, #int
|
78
|
+
"codigoLocalidadDestino" => @localidad_destino, #int
|
79
|
+
"codigoCosecha" => @cosecha, #string
|
80
|
+
"pesoNeto" => @peso.to_i, #long
|
81
|
+
#"cuitTransportista" => @cuit_transportista.to_i, #long
|
82
|
+
#"cantHoras" => @horas, #int
|
83
|
+
#"patente" => @patente, #string
|
84
|
+
"kmARecorrer" => @km, #unsignedint
|
85
|
+
#"cuitCorredor" => @cuit_corredor.to_i, #long
|
86
|
+
#"remitenteComercialcomoProductor" => @remitente_com
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
body["request"].merge(request)
|
91
|
+
end
|
92
|
+
|
93
|
+
def authorized?
|
94
|
+
!response.nil?
|
95
|
+
end
|
96
|
+
|
97
|
+
def anular_ctg
|
98
|
+
request = {
|
99
|
+
"datosAnularCTG" =>{
|
100
|
+
"cartaPorte" => "@ctg_num",
|
101
|
+
"ctg" => "#{self.code}"
|
102
|
+
}
|
103
|
+
}
|
104
|
+
body["request"].merge(request)
|
105
|
+
|
106
|
+
response = client.call(:anular_ctg, message: body)
|
107
|
+
end
|
108
|
+
|
109
|
+
def cambiar_destino_detinatario_ctg_rechazado
|
110
|
+
request = {
|
111
|
+
"datosCambiarDestinoDestinatarioCTGRechazado" =>{
|
112
|
+
"cartaPorte" => "@ctg_num",
|
113
|
+
"ctg" => "#{code}",
|
114
|
+
"codigoLocalidadDestino" => @destino,
|
115
|
+
"codigoLocalidadDestinatario" => @destinatario,
|
116
|
+
"kmARecorrer" => @km
|
117
|
+
}
|
118
|
+
}
|
119
|
+
body["request"].merge(request)
|
120
|
+
|
121
|
+
response = client.call(:cambiar_destino_detinatario_ctg_rechazado, message: body)
|
122
|
+
end
|
123
|
+
|
124
|
+
def confirmar_arribo
|
125
|
+
request = {
|
126
|
+
"datosConfirmarArribo" =>{
|
127
|
+
"cartaPorte" => "@ctg_num",
|
128
|
+
"ctg" => "#{self.code}",
|
129
|
+
"cuitTransportista" => @cuit_transportista,
|
130
|
+
"cuitChofer" => @cuit_chofer,
|
131
|
+
"cantKilosCartaPorte" => @cant_kilos_carta_porte
|
132
|
+
}
|
133
|
+
}
|
134
|
+
body["request"].merge(request)
|
135
|
+
|
136
|
+
response = client.call(:confirmar_arribo, message: body)
|
137
|
+
end
|
138
|
+
|
139
|
+
def confirmar_definitivo
|
140
|
+
request = {
|
141
|
+
"datosConfirmarDefinitivo" =>{
|
142
|
+
"cartaPorte" => "@ctg_num",
|
143
|
+
"ctg" => "#{self.code}",
|
144
|
+
"establecimiento" => @establecimiento,
|
145
|
+
"codigoCosecha" => @cosecha,
|
146
|
+
"pesoNeto" => @peso
|
147
|
+
}
|
148
|
+
}
|
149
|
+
body["request"].merge(request)
|
150
|
+
|
151
|
+
response = client.call(:confirmar_definitivo, message: body)
|
152
|
+
end
|
153
|
+
|
154
|
+
def consultar_cosechas
|
155
|
+
response = client.call(:consultar_cosechas, message: body)
|
156
|
+
return response["arrayCosechas"]
|
157
|
+
end
|
158
|
+
|
159
|
+
def consultar_constancia_ctg_pdf
|
160
|
+
request = {
|
161
|
+
"ctg" => "#{code}"
|
162
|
+
}
|
163
|
+
|
164
|
+
body["request"].merge(request)
|
165
|
+
|
166
|
+
response = client.call(:consultar_constancia_ctg_pdf, message: body)
|
167
|
+
end
|
168
|
+
|
169
|
+
def consultar_ctg
|
170
|
+
request = {
|
171
|
+
"consultarCTGDatos" =>{
|
172
|
+
"cartaPorte" => "@ctg_num",
|
173
|
+
"ctg" => "#{self.code}",
|
174
|
+
"patente" => @patente,
|
175
|
+
"cuitSolicitante" => @cuit_solicitante,
|
176
|
+
"cuitDestino" => @destino,
|
177
|
+
"fechaEmisionDesde" => @fecha_desde,
|
178
|
+
"fechaEmisionHsta" => @fecha_hasta,
|
179
|
+
"cuitCorredor" => @cuit_corredor
|
180
|
+
}
|
181
|
+
}
|
182
|
+
body["request"].merge(request)
|
183
|
+
|
184
|
+
response = client.call(:consultar_ctg, message: body)
|
185
|
+
end
|
186
|
+
|
187
|
+
def consultar_ctg_rechazados
|
188
|
+
response = client.call(:consultar_ctg_rechazados, message: body)
|
189
|
+
return response.to_hash["response"]["arrayConsultarCTGRechazados"]
|
190
|
+
end
|
191
|
+
|
192
|
+
def consultar_detalle_ctg
|
193
|
+
request = {
|
194
|
+
"ctg" => "#{code}"
|
195
|
+
}
|
196
|
+
|
197
|
+
body["request"].merge(request)
|
198
|
+
|
199
|
+
response = client.call(:consultar_constancia_ctg_pdf, message: body)
|
200
|
+
return response.to_hash["response"]["consultarDetalleCTGDatos"]
|
201
|
+
end
|
202
|
+
|
203
|
+
def consultar_especies
|
204
|
+
response = client.call(:consultar_especies, message: body)
|
205
|
+
response.body[:consultar_especies_response][:response][:array_especies][:especie].map{|c| [c[:codigo],c[:descripcion]]}
|
206
|
+
end
|
207
|
+
|
208
|
+
def consultar_establecimientos
|
209
|
+
response = client.call(:consultar_establecimientos, message: body)
|
210
|
+
response.body[:consultar_especies_response][:response][:array_establecimientos][:establecimiento].map{|c| [c]}
|
211
|
+
end
|
212
|
+
|
213
|
+
private
|
214
|
+
|
215
|
+
def setup_response(response)
|
216
|
+
# TODO: turn this into an all-purpose Response class
|
217
|
+
pp response
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
data/lib/Afip/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Afip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Facundo A. Díaz Martínez
|
@@ -75,6 +75,8 @@ extra_rdoc_files: []
|
|
75
75
|
files:
|
76
76
|
- ".DS_Store"
|
77
77
|
- ".gitignore"
|
78
|
+
- Afip-0.3.1.gem
|
79
|
+
- Afip-0.3.2.gem
|
78
80
|
- Afip.gemspec
|
79
81
|
- Gemfile
|
80
82
|
- Gemfile.lock
|
@@ -98,6 +100,7 @@ files:
|
|
98
100
|
- lib/Afip/core_ext/float.rb
|
99
101
|
- lib/Afip/core_ext/hash.rb
|
100
102
|
- lib/Afip/core_ext/string.rb
|
103
|
+
- lib/Afip/ctg.rb
|
101
104
|
- lib/Afip/padron.rb
|
102
105
|
- lib/Afip/version.rb
|
103
106
|
- lib/Afip/wsaa.rb
|