fdis2 0.1.45 → 0.1.50

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3247c783050777dc9542023795a03249592ca1ad5f31b0416b1ea8e954fd4961
4
- data.tar.gz: 543e17b91798e50dbd39023606487eb1090a3f827b61eca0a4891b376945ebae
3
+ metadata.gz: 1ca7c6a4bb66c017ef3b541dce2bccd51dd83ada5ad15347435df6ddfb81726c
4
+ data.tar.gz: f070f275f1b047bae6e070cc2a7228da0456044fd033398b6eeec3efd998c5a2
5
5
  SHA512:
6
- metadata.gz: a58a06fbd2b5e8ccc7ba086508f9a42d5a11c93e783ec93bf85521a162fb369db9dd3ea9c52381e44282a3fb388fcc0985f714fad0a52909f0491f7619b4cee7
7
- data.tar.gz: 38dbffb1a1ffcafa401664cf7233b12f0871e52c0f3d6872ea71017252d20ee541b32caa8ccb84ed0668db34c6a41c2a3a0aeb5b5bf1bbcb2ae880aef19a3e0d
6
+ metadata.gz: 6828fa63d3e5b074795a2d17143a261c9cf70708c2f805faf088a0c24d0547a30fec12997a48e0bfb8144c81dd75d9567167dd3703c2b5fdd3c701d49b0c82b5
7
+ data.tar.gz: ac33941064d4efc597c0c8aceaeb6f551ec21c3e14d34d85633669aaab3b8d61bde70df4913a411a8cbd6ea525e65b15db152dd25c38e80e6d4a6db99192cb08
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Fdis 0.1.34
1
+ # Fdis 0.1.5
2
2
 
3
- This is a ruby library that helps to interact with the Smarted Web API and the mexican billing system (SAT).
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 'fdis'
11
+ gem 'fdis2'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -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
- # tax_included: true,
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
- iva_id = params.fetch(:tasa_iva, 16)
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 == 16
542
- valor_unitario = (line[:valor_unitario].to_f) / 1.16
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
- total_line = cantidad * valor_unitario
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
- importe_iva = total_acumulator - total_line
556
+ subtotal_line = cantidad * valor_unitario
557
+ importe_iva = total_acumulator - subtotal_line
550
558
 
551
- subtotal += total_line
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 = (total_line * 1.06) - total_line
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'] = total_line.round(4).to_s
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'] = total_line.round(4).to_s
601
+ child_traslado['Base'] = subtotal_line.round(4).to_s
594
602
 
595
- if iva_id == 0
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'] = total_line.round(4).to_s
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
- ## Poblanco cfdi:Impuestos
652
+ ## Poblando cfdi:Impuestos
644
653
  impuestos['TotalImpuestosRetenidos'] = suma_ret.round(2).to_s if suma_ret > 0
645
654
 
646
- if iva_id == 0
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 iva_id == 0
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
@@ -1,3 +1,3 @@
1
1
  module Fdis2
2
- VERSION = "0.1.45"
2
+ VERSION = "0.1.50"
3
3
  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.45
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-04-01 00:00:00.000000000 Z
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.0.1
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