fdis2 0.1.5 → 0.1.34
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/README.md +4 -4
- data/lib/{fdis2 → fdis}/config.rb +1 -1
- data/lib/{fdis2 → fdis}/facturacion.rb +41 -56
- data/lib/fdis/version.rb +3 -0
- data/lib/{fdis2.rb → fdis.rb} +4 -4
- metadata +7 -7
- data/lib/fdis2/version.rb +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98156d327de044116f8ecd1635cb108d647d4a7f21ef24a794f959e5f192dde5
|
|
4
|
+
data.tar.gz: 790237815643c6f4d69ede647f5a7d1932b476f4368dea0083ae65c2300fef58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d18820ba0ae74963e58f01c9964b4e66c6f2ef26c0e9c9c33c69de929eaca216e2d03467a2038810be0dd59ec9b863c5d0b4fe2f4bdbcab9d2cbe02f6a8c3e5
|
|
7
|
+
data.tar.gz: 80491a426bbcdb6ba76cbef09953dcb4e363cfca478c830accc6a16f4c727ea0f73c7d0a11634802e2d5902bd86450155401e3e5a767c17106463ccd23362d7c
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Fdis 0.1.
|
|
1
|
+
# Fdis 0.1.34
|
|
2
2
|
|
|
3
|
-
This is a ruby library that helps to interact with the the mexican billing system (SAT).
|
|
3
|
+
This is a ruby library that helps to interact with the Smarted Web API and the mexican billing system (SAT).
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
@@ -8,7 +8,7 @@ This is a ruby library that helps to interact with the the mexican billing syste
|
|
|
8
8
|
Add this line to your application's Gemfile:
|
|
9
9
|
|
|
10
10
|
```ruby
|
|
11
|
-
gem '
|
|
11
|
+
gem 'fdis'
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
And then execute:
|
|
@@ -37,7 +37,7 @@ Initialize a new object with your config arguments
|
|
|
37
37
|
production = (Boolean) # environment, optional, default is -false-
|
|
38
38
|
|
|
39
39
|
# The object
|
|
40
|
-
obj =
|
|
40
|
+
obj = Fdis::Facturacion.new(production_token, development_token, rfc, razon_social, regimen, path_to_key, key_passphrase, path_to_cer, production)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
## Development
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
module
|
|
2
|
+
module Fdis
|
|
3
3
|
class Facturacion < Config
|
|
4
4
|
|
|
5
5
|
def comp_pago(params={})
|
|
@@ -30,17 +30,16 @@ module Fdis2
|
|
|
30
30
|
# ]
|
|
31
31
|
# }
|
|
32
32
|
|
|
33
|
-
puts "----- Fdis
|
|
34
|
-
puts "--- Fdis
|
|
35
|
-
puts "--- Fdis
|
|
36
|
-
puts "--- Fdis
|
|
37
|
-
puts "--- Fdis: Line items: "
|
|
33
|
+
puts "----- Fdis::Facturacion::com_pago"
|
|
34
|
+
puts "--- Fdis:: Total venta: #{params[:total]}"
|
|
35
|
+
puts "--- Fdis:: Monto de pago a procesar: #{params[:monto_pago]}"
|
|
36
|
+
puts "--- Fdis:: Line items: "
|
|
38
37
|
params[:line_items].each do |line|
|
|
39
38
|
puts "-- #{line[:monto]}"
|
|
40
39
|
end
|
|
41
40
|
lines_total = params[:line_items].inject(0) {|sum, x| sum + x[:monto].to_f}
|
|
42
41
|
|
|
43
|
-
puts "--- Fdis
|
|
42
|
+
puts "--- Fdis::Suma de line_items: #{lines_total}"
|
|
44
43
|
|
|
45
44
|
if (lines_total > params[:total].to_f)
|
|
46
45
|
raise 'Error Fdis - la suma de los complementos de pago es mayor al total de la venta'
|
|
@@ -118,7 +117,7 @@ module Fdis2
|
|
|
118
117
|
|
|
119
118
|
|
|
120
119
|
# totales
|
|
121
|
-
total = params[:monto_pago].to_f
|
|
120
|
+
total = params[:monto_pago].to_f
|
|
122
121
|
iva_id = params.fetch(:tasa_iva, 16)
|
|
123
122
|
|
|
124
123
|
pago_totales = xml.at_xpath("//pago20:Totales")
|
|
@@ -163,11 +162,11 @@ module Fdis2
|
|
|
163
162
|
child_pago_relacionado['Folio'] = params[:folio]
|
|
164
163
|
child_pago_relacionado['EquivalenciaDR'] = "1"
|
|
165
164
|
|
|
166
|
-
saldo_anterior = params[:saldo_anterior].to_f
|
|
165
|
+
saldo_anterior = params[:saldo_anterior].to_f
|
|
167
166
|
|
|
168
167
|
child_pago_relacionado['ImpSaldoAnt'] = saldo_anterior.round(2).to_s
|
|
169
168
|
child_pago_relacionado['ImpPagado'] = total.round(2).to_s
|
|
170
|
-
child_pago_relacionado['ImpSaldoInsoluto'] = (saldo_anterior - total).round(2).
|
|
169
|
+
child_pago_relacionado['ImpSaldoInsoluto'] = (saldo_anterior - total).round(2).to_s
|
|
171
170
|
child_pago_relacionado['ObjetoImpDR'] = '02'
|
|
172
171
|
|
|
173
172
|
impuestos_dr = Nokogiri::XML::Node.new "pago20:ImpuestosDR", xml
|
|
@@ -181,13 +180,13 @@ module Fdis2
|
|
|
181
180
|
traslado['TipoFactorDR'] = 'Tasa'
|
|
182
181
|
traslado['ImpuestoDR'] = '002'
|
|
183
182
|
|
|
184
|
-
traslado['BaseDR'] = subtotal.round(
|
|
185
|
-
traslado['ImporteDR'] = iva.round(
|
|
183
|
+
traslado['BaseDR'] = subtotal.round(4).to_s #subtotal
|
|
184
|
+
traslado['ImporteDR'] = iva.round(4).to_s # tax
|
|
186
185
|
|
|
187
|
-
traslado_p['BaseP'] = subtotal.round(
|
|
186
|
+
traslado_p['BaseP'] = subtotal.round(4).to_s
|
|
188
187
|
traslado_p['ImpuestoP'] = '002'
|
|
189
188
|
traslado_p['TipoFactorP'] = 'Tasa'
|
|
190
|
-
traslado_p['ImporteP'] = iva.round(
|
|
189
|
+
traslado_p['ImporteP'] = iva.round(4).to_s # tax
|
|
191
190
|
|
|
192
191
|
if iva_id == 16
|
|
193
192
|
traslado['TasaOCuotaDR'] = '0.160000'
|
|
@@ -236,7 +235,7 @@ module Fdis2
|
|
|
236
235
|
base64_xml = Base64.encode64(xml.to_xml)
|
|
237
236
|
|
|
238
237
|
# haciendo llamada a API
|
|
239
|
-
uri = URI("#{
|
|
238
|
+
uri = URI("#{Fdis::UrlPro}/Timbrar40")
|
|
240
239
|
request = Net::HTTP::Post.new(uri)
|
|
241
240
|
# request.basic_auth(token, "")
|
|
242
241
|
request.content_type = "application/json"
|
|
@@ -331,7 +330,7 @@ module Fdis2
|
|
|
331
330
|
# }
|
|
332
331
|
|
|
333
332
|
|
|
334
|
-
uri = URI(
|
|
333
|
+
uri = URI(Fdis::UrlCancel)
|
|
335
334
|
request = Net::HTTP::Post.new(uri)
|
|
336
335
|
request.content_type = "application/json"
|
|
337
336
|
|
|
@@ -428,7 +427,7 @@ module Fdis2
|
|
|
428
427
|
# descripcion: 'Servicio mano de obra',
|
|
429
428
|
# valor_unitario: 100.00,
|
|
430
429
|
# descuento: 0.00,
|
|
431
|
-
#
|
|
430
|
+
# tax_included: true,
|
|
432
431
|
# retencion_iva: 0, 6, 16
|
|
433
432
|
# # Optional parameters
|
|
434
433
|
# },
|
|
@@ -469,14 +468,8 @@ module Fdis2
|
|
|
469
468
|
comprobante['Serie'] = params.fetch(:series, 'FA').to_s
|
|
470
469
|
comprobante['Folio'] = params.fetch(:folio).to_s
|
|
471
470
|
comprobante['Fecha'] = time.to_s
|
|
472
|
-
comprobante['MetodoPago'] = params.fetch(:metodo_pago, 'PUE')
|
|
473
471
|
comprobante['FormaPago'] = params.fetch(:forma_pago, '01')
|
|
474
|
-
|
|
475
|
-
if comprobante['MetodoPago'] == 'PPD'
|
|
476
|
-
comprobante['FormaPago'] = '99'
|
|
477
|
-
end
|
|
478
|
-
|
|
479
|
-
|
|
472
|
+
comprobante['MetodoPago'] = params.fetch(:metodo_pago, 'PUE')
|
|
480
473
|
comprobante['LugarExpedicion'] = params.fetch(:cp, '47180')
|
|
481
474
|
comprobante['NoCertificado'] = @serial
|
|
482
475
|
comprobante['Certificado'] = @cadena
|
|
@@ -520,10 +513,9 @@ module Fdis2
|
|
|
520
513
|
suma_iva = 0.00
|
|
521
514
|
suma_ret = 0.00
|
|
522
515
|
|
|
523
|
-
|
|
524
|
-
line_items.each do |line|
|
|
525
|
-
iva_id = line.fetch(:tax, 16.0)
|
|
516
|
+
iva_id = params.fetch(:tasa_iva, 16)
|
|
526
517
|
|
|
518
|
+
line_items.each do |line|
|
|
527
519
|
ret_iva = line.fetch(:retencion_iva, 0)
|
|
528
520
|
|
|
529
521
|
cantidad = line[:cantidad].to_f
|
|
@@ -540,23 +532,17 @@ module Fdis2
|
|
|
540
532
|
|
|
541
533
|
total_acumulator = cantidad * line[:valor_unitario].to_f
|
|
542
534
|
|
|
543
|
-
if iva_id
|
|
544
|
-
|
|
545
|
-
valor_unitario = (line[:valor_unitario].to_f) / tax_factor
|
|
535
|
+
if iva_id == 16
|
|
536
|
+
valor_unitario = (line[:valor_unitario].to_f) / 1.16
|
|
546
537
|
else
|
|
547
538
|
valor_unitario = line[:valor_unitario].to_f
|
|
548
539
|
end
|
|
549
540
|
|
|
550
|
-
|
|
551
|
-
# valor_unitario = (line[:valor_unitario].to_f) / 1.16
|
|
552
|
-
# else
|
|
553
|
-
# valor_unitario = line[:valor_unitario].to_f
|
|
554
|
-
# end
|
|
541
|
+
total_line = cantidad * valor_unitario
|
|
555
542
|
|
|
556
|
-
|
|
557
|
-
importe_iva = total_acumulator - subtotal_line
|
|
543
|
+
importe_iva = total_acumulator - total_line
|
|
558
544
|
|
|
559
|
-
subtotal +=
|
|
545
|
+
subtotal += total_line
|
|
560
546
|
suma_iva += importe_iva
|
|
561
547
|
suma_total += total_acumulator
|
|
562
548
|
|
|
@@ -564,7 +550,7 @@ module Fdis2
|
|
|
564
550
|
## calculando retencion de IVA en caso de tener
|
|
565
551
|
if ret_iva > 0
|
|
566
552
|
if ret_iva == 6
|
|
567
|
-
importe_ret_linea = (
|
|
553
|
+
importe_ret_linea = (total_line * 1.06) - total_line
|
|
568
554
|
elsif ret_iva == 16
|
|
569
555
|
importe_ret_linea = importe_iva
|
|
570
556
|
end
|
|
@@ -584,7 +570,7 @@ module Fdis2
|
|
|
584
570
|
child_concepto['Descripcion'] = line[:descripcion].to_s
|
|
585
571
|
child_concepto['Cantidad'] = cantidad.to_s
|
|
586
572
|
child_concepto['ValorUnitario'] = valor_unitario.round(4).to_s
|
|
587
|
-
child_concepto['Importe'] =
|
|
573
|
+
child_concepto['Importe'] = total_line.round(4).to_s
|
|
588
574
|
child_concepto['ObjetoImp'] = '02'
|
|
589
575
|
|
|
590
576
|
|
|
@@ -598,15 +584,14 @@ module Fdis2
|
|
|
598
584
|
child_traslado = Nokogiri::XML::Node.new "cfdi:Traslado", xml
|
|
599
585
|
child_traslado['Impuesto'] = '002'
|
|
600
586
|
child_traslado['TipoFactor'] = "Tasa"
|
|
601
|
-
child_traslado['Base'] =
|
|
587
|
+
child_traslado['Base'] = total_line.round(4).to_s
|
|
602
588
|
|
|
603
|
-
if iva_id
|
|
604
|
-
tasa_cuota = (iva_id / 100).round(6)
|
|
605
|
-
child_traslado['Importe'] = importe_iva.round(4).to_s
|
|
606
|
-
child_traslado['TasaOCuota'] = tasa_cuota.to_s
|
|
607
|
-
else
|
|
589
|
+
if iva_id == 0
|
|
608
590
|
child_traslado['Importe'] = "0.00"
|
|
609
591
|
child_traslado['TasaOCuota'] = '0.000000'
|
|
592
|
+
else
|
|
593
|
+
child_traslado['Importe'] = importe_iva.round(4).to_s
|
|
594
|
+
child_traslado['TasaOCuota'] = '0.160000'
|
|
610
595
|
end
|
|
611
596
|
|
|
612
597
|
|
|
@@ -620,7 +605,7 @@ module Fdis2
|
|
|
620
605
|
if ret_iva > 0
|
|
621
606
|
child_retenciones = Nokogiri::XML::Node.new "cfdi:Retenciones", xml
|
|
622
607
|
child_retencion = Nokogiri::XML::Node.new "cfdi:Retencion", xml
|
|
623
|
-
child_retencion['Base'] =
|
|
608
|
+
child_retencion['Base'] = total_line.round(4).to_s
|
|
624
609
|
child_retencion['Impuesto'] = '002'
|
|
625
610
|
child_retencion['TipoFactor'] = "Tasa"
|
|
626
611
|
|
|
@@ -649,13 +634,13 @@ module Fdis2
|
|
|
649
634
|
comprobante['SubTotal'] = subtotal.round(2).to_s
|
|
650
635
|
|
|
651
636
|
|
|
652
|
-
##
|
|
637
|
+
## Poblanco cfdi:Impuestos
|
|
653
638
|
impuestos['TotalImpuestosRetenidos'] = suma_ret.round(2).to_s if suma_ret > 0
|
|
654
639
|
|
|
655
|
-
if
|
|
656
|
-
impuestos['TotalImpuestosTrasladados'] = suma_iva.round(2).to_s
|
|
657
|
-
else
|
|
640
|
+
if iva_id == 0
|
|
658
641
|
impuestos['TotalImpuestosTrasladados'] = "0.00"
|
|
642
|
+
else
|
|
643
|
+
impuestos['TotalImpuestosTrasladados'] = suma_iva.round(2).to_s
|
|
659
644
|
end
|
|
660
645
|
|
|
661
646
|
|
|
@@ -681,12 +666,12 @@ module Fdis2
|
|
|
681
666
|
traslado_child['TipoFactor'] = 'Tasa'
|
|
682
667
|
traslado_child['Base'] = subtotal.round(2)
|
|
683
668
|
|
|
684
|
-
if
|
|
685
|
-
traslado_child['Importe'] = suma_iva.round(2).to_s
|
|
686
|
-
traslado_child['TasaOCuota'] = '0.160000'
|
|
687
|
-
else
|
|
669
|
+
if iva_id == 0
|
|
688
670
|
traslado_child['Importe'] = "0.00"
|
|
689
671
|
traslado_child['TasaOCuota'] = '0.000000'
|
|
672
|
+
else
|
|
673
|
+
traslado_child['Importe'] = suma_iva.round(2).to_s
|
|
674
|
+
traslado_child['TasaOCuota'] = '0.160000'
|
|
690
675
|
end
|
|
691
676
|
|
|
692
677
|
traslados.add_child(traslado_child)
|
|
@@ -717,7 +702,7 @@ module Fdis2
|
|
|
717
702
|
base64_xml = Base64.encode64(xml.to_xml)
|
|
718
703
|
|
|
719
704
|
# haciendo llamada a API
|
|
720
|
-
uri = URI("#{
|
|
705
|
+
uri = URI("#{Fdis::UrlPro}/Timbrar40")
|
|
721
706
|
request = Net::HTTP::Post.new(uri)
|
|
722
707
|
request.content_type = "application/json"
|
|
723
708
|
request.body = JSON.dump({
|
data/lib/fdis/version.rb
ADDED
data/lib/{fdis2.rb → fdis.rb}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require "
|
|
2
|
-
require "
|
|
3
|
-
require "
|
|
1
|
+
require "fdis/version"
|
|
2
|
+
require "fdis/config"
|
|
3
|
+
require "fdis/facturacion"
|
|
4
4
|
|
|
5
5
|
require 'openssl'
|
|
6
6
|
require 'net/http'
|
|
@@ -12,6 +12,6 @@ require 'fileutils'
|
|
|
12
12
|
# External gems
|
|
13
13
|
require 'nokogiri'
|
|
14
14
|
|
|
15
|
-
module
|
|
15
|
+
module Fdis
|
|
16
16
|
|
|
17
17
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fdis2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.34
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Angel Padilla
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-03-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -113,10 +113,10 @@ files:
|
|
|
113
113
|
- lib/cadena/valesdedespensa.xslt
|
|
114
114
|
- lib/cadena/vehiculousado.xslt
|
|
115
115
|
- lib/cadena/ventavehiculos11.xslt
|
|
116
|
-
- lib/
|
|
117
|
-
- lib/
|
|
118
|
-
- lib/
|
|
119
|
-
- lib/
|
|
116
|
+
- lib/fdis.rb
|
|
117
|
+
- lib/fdis/config.rb
|
|
118
|
+
- lib/fdis/facturacion.rb
|
|
119
|
+
- lib/fdis/version.rb
|
|
120
120
|
homepage: https://github.com/angelpadilla/fdis2
|
|
121
121
|
licenses:
|
|
122
122
|
- MIT
|
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: '0'
|
|
139
139
|
requirements: []
|
|
140
|
-
rubygems_version: 3.
|
|
140
|
+
rubygems_version: 3.4.6
|
|
141
141
|
signing_key:
|
|
142
142
|
specification_version: 4
|
|
143
143
|
summary: Gem used to fetch the CFDIS Web API
|
data/lib/fdis2/version.rb
DELETED