fdis2 0.1.45 → 0.1.50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/fdis2/facturacion.rb +33 -24
- data/lib/fdis2/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ca7c6a4bb66c017ef3b541dce2bccd51dd83ada5ad15347435df6ddfb81726c
|
4
|
+
data.tar.gz: f070f275f1b047bae6e070cc2a7228da0456044fd033398b6eeec3efd998c5a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6828fa63d3e5b074795a2d17143a261c9cf70708c2f805faf088a0c24d0547a30fec12997a48e0bfb8144c81dd75d9567167dd3703c2b5fdd3c701d49b0c82b5
|
7
|
+
data.tar.gz: ac33941064d4efc597c0c8aceaeb6f551ec21c3e14d34d85633669aaab3b8d61bde70df4913a411a8cbd6ea525e65b15db152dd25c38e80e6d4a6db99192cb08
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Fdis 0.1.
|
1
|
+
# Fdis 0.1.5
|
2
2
|
|
3
|
-
This is a ruby library that helps to interact with the
|
3
|
+
This is a ruby library that helps to interact with the 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 Smarted Web API and the m
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem '
|
11
|
+
gem 'fdis2'
|
12
12
|
```
|
13
13
|
|
14
14
|
And then execute:
|
data/lib/fdis2/facturacion.rb
CHANGED
@@ -33,6 +33,7 @@ module Fdis2
|
|
33
33
|
puts "----- Fdis: Facturacion::com_pago"
|
34
34
|
puts "--- Fdis: Total venta: #{params[:total]}"
|
35
35
|
puts "--- Fdis: Monto de pago a procesar: #{params[:monto_pago]}"
|
36
|
+
puts "--- Fdis: Saldo insoluto anterior: #{params[:saldo_anterior]}"
|
36
37
|
puts "--- Fdis: Line items: "
|
37
38
|
params[:line_items].each do |line|
|
38
39
|
puts "-- #{line[:monto]}"
|
@@ -427,7 +428,7 @@ module Fdis2
|
|
427
428
|
# descripcion: 'Servicio mano de obra',
|
428
429
|
# valor_unitario: 100.00,
|
429
430
|
# descuento: 0.00,
|
430
|
-
#
|
431
|
+
# tax: 16.0 o 0.0,
|
431
432
|
# retencion_iva: 0, 6, 16
|
432
433
|
# # Optional parameters
|
433
434
|
# },
|
@@ -519,9 +520,10 @@ module Fdis2
|
|
519
520
|
suma_iva = 0.00
|
520
521
|
suma_ret = 0.00
|
521
522
|
|
522
|
-
|
523
|
-
|
523
|
+
|
524
524
|
line_items.each do |line|
|
525
|
+
iva_id = line.fetch(:tax, 16.0)
|
526
|
+
|
525
527
|
ret_iva = line.fetch(:retencion_iva, 0)
|
526
528
|
|
527
529
|
cantidad = line[:cantidad].to_f
|
@@ -538,17 +540,23 @@ module Fdis2
|
|
538
540
|
|
539
541
|
total_acumulator = cantidad * line[:valor_unitario].to_f
|
540
542
|
|
541
|
-
if iva_id
|
542
|
-
|
543
|
+
if iva_id > 0
|
544
|
+
tax_factor = (iva_id / 100) + 1
|
545
|
+
valor_unitario = (line[:valor_unitario].to_f) / tax_factor
|
543
546
|
else
|
544
547
|
valor_unitario = line[:valor_unitario].to_f
|
545
548
|
end
|
546
549
|
|
547
|
-
|
550
|
+
# if iva_id == 16
|
551
|
+
# valor_unitario = (line[:valor_unitario].to_f) / 1.16
|
552
|
+
# else
|
553
|
+
# valor_unitario = line[:valor_unitario].to_f
|
554
|
+
# end
|
548
555
|
|
549
|
-
|
556
|
+
subtotal_line = cantidad * valor_unitario
|
557
|
+
importe_iva = total_acumulator - subtotal_line
|
550
558
|
|
551
|
-
subtotal +=
|
559
|
+
subtotal += subtotal_line
|
552
560
|
suma_iva += importe_iva
|
553
561
|
suma_total += total_acumulator
|
554
562
|
|
@@ -556,7 +564,7 @@ module Fdis2
|
|
556
564
|
## calculando retencion de IVA en caso de tener
|
557
565
|
if ret_iva > 0
|
558
566
|
if ret_iva == 6
|
559
|
-
importe_ret_linea = (
|
567
|
+
importe_ret_linea = (subtotal_line * 1.06) - subtotal_line
|
560
568
|
elsif ret_iva == 16
|
561
569
|
importe_ret_linea = importe_iva
|
562
570
|
end
|
@@ -576,7 +584,7 @@ module Fdis2
|
|
576
584
|
child_concepto['Descripcion'] = line[:descripcion].to_s
|
577
585
|
child_concepto['Cantidad'] = cantidad.to_s
|
578
586
|
child_concepto['ValorUnitario'] = valor_unitario.round(4).to_s
|
579
|
-
child_concepto['Importe'] =
|
587
|
+
child_concepto['Importe'] = subtotal_line.round(4).to_s
|
580
588
|
child_concepto['ObjetoImp'] = '02'
|
581
589
|
|
582
590
|
|
@@ -590,14 +598,15 @@ module Fdis2
|
|
590
598
|
child_traslado = Nokogiri::XML::Node.new "cfdi:Traslado", xml
|
591
599
|
child_traslado['Impuesto'] = '002'
|
592
600
|
child_traslado['TipoFactor'] = "Tasa"
|
593
|
-
child_traslado['Base'] =
|
601
|
+
child_traslado['Base'] = subtotal_line.round(4).to_s
|
594
602
|
|
595
|
-
if iva_id
|
603
|
+
if iva_id > 0
|
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
|
596
608
|
child_traslado['Importe'] = "0.00"
|
597
609
|
child_traslado['TasaOCuota'] = '0.000000'
|
598
|
-
else
|
599
|
-
child_traslado['Importe'] = importe_iva.round(4).to_s
|
600
|
-
child_traslado['TasaOCuota'] = '0.160000'
|
601
610
|
end
|
602
611
|
|
603
612
|
|
@@ -611,7 +620,7 @@ module Fdis2
|
|
611
620
|
if ret_iva > 0
|
612
621
|
child_retenciones = Nokogiri::XML::Node.new "cfdi:Retenciones", xml
|
613
622
|
child_retencion = Nokogiri::XML::Node.new "cfdi:Retencion", xml
|
614
|
-
child_retencion['Base'] =
|
623
|
+
child_retencion['Base'] = subtotal_line.round(4).to_s
|
615
624
|
child_retencion['Impuesto'] = '002'
|
616
625
|
child_retencion['TipoFactor'] = "Tasa"
|
617
626
|
|
@@ -640,13 +649,13 @@ module Fdis2
|
|
640
649
|
comprobante['SubTotal'] = subtotal.round(2).to_s
|
641
650
|
|
642
651
|
|
643
|
-
##
|
652
|
+
## Poblando cfdi:Impuestos
|
644
653
|
impuestos['TotalImpuestosRetenidos'] = suma_ret.round(2).to_s if suma_ret > 0
|
645
654
|
|
646
|
-
if
|
647
|
-
impuestos['TotalImpuestosTrasladados'] = "0.00"
|
648
|
-
else
|
655
|
+
if suma_iva > 0
|
649
656
|
impuestos['TotalImpuestosTrasladados'] = suma_iva.round(2).to_s
|
657
|
+
else
|
658
|
+
impuestos['TotalImpuestosTrasladados'] = "0.00"
|
650
659
|
end
|
651
660
|
|
652
661
|
|
@@ -672,12 +681,12 @@ module Fdis2
|
|
672
681
|
traslado_child['TipoFactor'] = 'Tasa'
|
673
682
|
traslado_child['Base'] = subtotal.round(2)
|
674
683
|
|
675
|
-
if
|
676
|
-
traslado_child['Importe'] = "0.00"
|
677
|
-
traslado_child['TasaOCuota'] = '0.000000'
|
678
|
-
else
|
684
|
+
if suma_iva > 0
|
679
685
|
traslado_child['Importe'] = suma_iva.round(2).to_s
|
680
686
|
traslado_child['TasaOCuota'] = '0.160000'
|
687
|
+
else
|
688
|
+
traslado_child['Importe'] = "0.00"
|
689
|
+
traslado_child['TasaOCuota'] = '0.000000'
|
681
690
|
end
|
682
691
|
|
683
692
|
traslados.add_child(traslado_child)
|
data/lib/fdis2/version.rb
CHANGED
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.50
|
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-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -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.1.6
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Gem used to fetch the CFDIS Web API
|