fdis 0.1.9 → 0.1.11

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
2
  SHA256:
3
- metadata.gz: da265a50596053c4c14e1aed4af136a5371cba9de53a1dfc4908c442704bc603
4
- data.tar.gz: de8b901323cf697b0837d238218cd16d49eee187fded0ec31e0fbf11462b2f03
3
+ metadata.gz: 0b2fb454bc57115bd0fa4c7f95315b0122aae72c070659e7b63a8776206cd736
4
+ data.tar.gz: f65497acb24b633ac32028a31d15515e6336990119c531c011556aab3d9d91d8
5
5
  SHA512:
6
- metadata.gz: 5358051748c057cefc87940f0216847809417064a4040efc8781a20873fcef137a38e156727b3c7e692e819dc218cb7e7f86affc6e8812d9a20eb14f74fdf1d7
7
- data.tar.gz: acc4308862cd5f24e2be8d57acd6409bc64d7340e1ee6dfa5e578ff62e2c384a6960aaf07c469e80446fadcd1e054d52801c02052786e798e4036b0c35798fbf
6
+ metadata.gz: c0c6ac3db69281e33487b97d141d9aff787791d71f624dd432d360a93c532acd363a5a357f77ee3edf426bbc8dc0446cee3c1ad373a39ea03ae1407477a7076b
7
+ data.tar.gz: d12dc995ba1f94ebefa64bca2195fcfc45bde93142b51ecab1a9b31cf02c4f0175de0dfbb273e80fa6dc263d9c9ab15c86d9c7dc7893f3bc12777a0aa20765ff
@@ -156,6 +156,35 @@ module Fdis
156
156
  child_pago_relacionado['ImpSaldoInsoluto'] = (saldo_anterior - monto).round(2).to_s
157
157
  saldo_anterior -= monto
158
158
 
159
+ if iva_id == 16 or iva_id == 8
160
+ child_pago_relacionado['ObjetoImpDR'] = '02'
161
+
162
+ impuestos_dr = Nokogiri::XML::Node.new "pago20:ImpuestosDR", xml
163
+ traslados_dr = Nokogiri::XML::Node.new "pago20:TrasladosDR", xml
164
+ traslado = Nokogiri::XML::Node.new "pago20:TrasladoDR", xml
165
+ traslado['TipoFactorDR'] = 'Tasa'
166
+ traslado['ImpuestoDR'] = '002'
167
+
168
+ if iva_id == 16
169
+ traslado['TasaOCuotaDR'] = '0.160000'
170
+ t_subtotal = monto / 1.16
171
+ t_tax = monto - t_subtotal
172
+ else
173
+ traslado['TasaOCuotaDR'] = '0.080000'
174
+ t_subtotal = monto / 1.08
175
+ t_tax = monto - t_subtotal
176
+ end
177
+
178
+ traslado['BaseDR'] = t_subtotal.round(4).to_s #subtotal
179
+ traslado['ImporteDR'] = t_tax.round(4).to_s # tax
180
+
181
+ traslados_dr.add_child(traslado)
182
+ impuestos_dr.add_child(traslados_dr)
183
+ child_pago_relacionado.add_child(impuestos_dr)
184
+ else
185
+ child_pago_relacionado['ObjetoImpDR'] = '01'
186
+ end
187
+
159
188
  child_pago.add_child(child_pago_relacionado)
160
189
  end
161
190
 
@@ -180,7 +209,7 @@ module Fdis
180
209
  File.delete("#{key_pem_url}")
181
210
 
182
211
  puts '------ Fdis: comprobante de pago antes de timbre -------'
183
- puts xml.to_xml
212
+ p xml.to_xml
184
213
  base64_xml = Base64.encode64(xml.to_xml)
185
214
 
186
215
  # haciendo llamada a API
@@ -202,8 +231,15 @@ module Fdis
202
231
  json_response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
203
232
  http.request(request)
204
233
  end
205
- puts "-- #{json_response.code} --"
206
- puts "-- #{json_response.message} --"
234
+
235
+ puts "---- Fdis: request"
236
+ puts "-- body: #{request.body} --"
237
+
238
+ puts "---- Fdis: Respuesta"
239
+ puts "-- Codigo: #{json_response.code} --"
240
+ puts "-- Mensaje: #{json_response.message} --"
241
+ puts "-- Body: "
242
+ p json_response.body
207
243
  # puts "-- Body --"
208
244
  # puts json_response.body
209
245
  # puts '---'
@@ -213,8 +249,7 @@ module Fdis
213
249
  when Net::HTTPSuccess, Net::HTTPRedirection
214
250
  if response['success'] == true
215
251
  decoded_xml = Nokogiri::XML(Base64.decode64(response['base64XmlFile']))
216
- # timbre = decoded_xml.at_xpath("//cfdi:Complemento").children[1]
217
- timbre = decoded_xml.at_xpath("//tfd:TimbreFiscalDigital")
252
+ timbre = decoded_xml.at_xpath("//cfdi:Complemento").children[0]
218
253
  response = {
219
254
  status: 200,
220
255
  message_error: '',
@@ -787,7 +822,8 @@ module Fdis
787
822
  puts "---- Fdis: Respuesta"
788
823
  puts "-- Codigo: #{json_response.code} --"
789
824
  puts "-- Mensaje: #{json_response.message} --"
790
- puts "-- Body: #{json_response.body} --"
825
+ puts "-- Body: "
826
+ p json_response.body
791
827
 
792
828
  response = JSON.parse(json_response.body)
793
829
 
@@ -795,8 +831,7 @@ module Fdis
795
831
  when Net::HTTPSuccess, Net::HTTPRedirection
796
832
  if response['success'] == true
797
833
  decoded_xml = Nokogiri::XML(Base64.decode64(response['base64XmlFile']))
798
- # timbre = decoded_xml.at_xpath("//cfdi:Complemento").children[1]
799
- timbre = decoded_xml.at_xpath("//tfd:TimbreFiscalDigital")
834
+ timbre = decoded_xml.at_xpath("//cfdi:Complemento").children[0]
800
835
  response = {
801
836
  status: 200,
802
837
  message_error: '',
data/lib/fdis/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fdis
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fdis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angel Padilla
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2022-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler