fdis2 0.1.45 → 0.1.51

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: c23ad6eef2cbb06c86ce05fc8617eac0d05927bc5d439886c2f6d93a80a2d9e3
4
+ data.tar.gz: ec1773881935d5ead18a189912cbf89a134c3aca18269a968afae7a5d8790a89
5
5
  SHA512:
6
- metadata.gz: a58a06fbd2b5e8ccc7ba086508f9a42d5a11c93e783ec93bf85521a162fb369db9dd3ea9c52381e44282a3fb388fcc0985f714fad0a52909f0491f7619b4cee7
7
- data.tar.gz: 38dbffb1a1ffcafa401664cf7233b12f0871e52c0f3d6872ea71017252d20ee541b32caa8ccb84ed0668db34c6a41c2a3a0aeb5b5bf1bbcb2ae880aef19a3e0d
6
+ metadata.gz: 6eab8ba89cc9575b34e5e58a12e6b6a1e4655abdb1cfe03a545189e0d7138f82a036ff9fa10914118ab971e4b2f119f7f127ffae5b7aa95fc394fbfe9c2dbf50
7
+ data.tar.gz: b67ef6dc3f8b9980d4f150723f966ee654dc35f67d3f8df98bbf4ac40bc2f64412feb1f714a1d9b3bcb0a577f595876893146d49704d46815a3a333323620fe9
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]}"
@@ -415,7 +416,6 @@ module Fdis2
415
416
  # receptor_rfc: '',
416
417
  # receptor_regimen: '',
417
418
  # uso_cfdi: 'G03',
418
- # tasa_iva: 0, 16,
419
419
  # time: "%Y-%m-%dT%H:%M:%S",
420
420
  # line_items: [
421
421
  # {
@@ -427,7 +427,7 @@ module Fdis2
427
427
  # descripcion: 'Servicio mano de obra',
428
428
  # valor_unitario: 100.00,
429
429
  # descuento: 0.00,
430
- # tax_included: true,
430
+ # tax: 16.0 o 0.0,
431
431
  # retencion_iva: 0, 6, 16
432
432
  # # Optional parameters
433
433
  # },
@@ -519,9 +519,10 @@ module Fdis2
519
519
  suma_iva = 0.00
520
520
  suma_ret = 0.00
521
521
 
522
- iva_id = params.fetch(:tasa_iva, 16)
523
-
522
+
524
523
  line_items.each do |line|
524
+ iva_id = line.fetch(:tax, 16.0)
525
+
525
526
  ret_iva = line.fetch(:retencion_iva, 0)
526
527
 
527
528
  cantidad = line[:cantidad].to_f
@@ -538,17 +539,23 @@ module Fdis2
538
539
 
539
540
  total_acumulator = cantidad * line[:valor_unitario].to_f
540
541
 
541
- if iva_id == 16
542
- valor_unitario = (line[:valor_unitario].to_f) / 1.16
542
+ if iva_id > 0
543
+ tax_factor = (iva_id / 100) + 1
544
+ valor_unitario = (line[:valor_unitario].to_f) / tax_factor
543
545
  else
544
546
  valor_unitario = line[:valor_unitario].to_f
545
547
  end
546
548
 
547
- total_line = cantidad * valor_unitario
549
+ # if iva_id == 16
550
+ # valor_unitario = (line[:valor_unitario].to_f) / 1.16
551
+ # else
552
+ # valor_unitario = line[:valor_unitario].to_f
553
+ # end
548
554
 
549
- importe_iva = total_acumulator - total_line
555
+ subtotal_line = cantidad * valor_unitario
556
+ importe_iva = total_acumulator - subtotal_line
550
557
 
551
- subtotal += total_line
558
+ subtotal += subtotal_line
552
559
  suma_iva += importe_iva
553
560
  suma_total += total_acumulator
554
561
 
@@ -556,7 +563,7 @@ module Fdis2
556
563
  ## calculando retencion de IVA en caso de tener
557
564
  if ret_iva > 0
558
565
  if ret_iva == 6
559
- importe_ret_linea = (total_line * 1.06) - total_line
566
+ importe_ret_linea = (subtotal_line * 1.06) - subtotal_line
560
567
  elsif ret_iva == 16
561
568
  importe_ret_linea = importe_iva
562
569
  end
@@ -576,7 +583,7 @@ module Fdis2
576
583
  child_concepto['Descripcion'] = line[:descripcion].to_s
577
584
  child_concepto['Cantidad'] = cantidad.to_s
578
585
  child_concepto['ValorUnitario'] = valor_unitario.round(4).to_s
579
- child_concepto['Importe'] = total_line.round(4).to_s
586
+ child_concepto['Importe'] = subtotal_line.round(4).to_s
580
587
  child_concepto['ObjetoImp'] = '02'
581
588
 
582
589
 
@@ -590,14 +597,15 @@ module Fdis2
590
597
  child_traslado = Nokogiri::XML::Node.new "cfdi:Traslado", xml
591
598
  child_traslado['Impuesto'] = '002'
592
599
  child_traslado['TipoFactor'] = "Tasa"
593
- child_traslado['Base'] = total_line.round(4).to_s
600
+ child_traslado['Base'] = subtotal_line.round(4).to_s
594
601
 
595
- if iva_id == 0
602
+ if iva_id > 0
603
+ tasa_cuota = (iva_id / 100).round(6)
604
+ child_traslado['Importe'] = importe_iva.round(4).to_s
605
+ child_traslado['TasaOCuota'] = tasa_cuota.to_s
606
+ else
596
607
  child_traslado['Importe'] = "0.00"
597
608
  child_traslado['TasaOCuota'] = '0.000000'
598
- else
599
- child_traslado['Importe'] = importe_iva.round(4).to_s
600
- child_traslado['TasaOCuota'] = '0.160000'
601
609
  end
602
610
 
603
611
 
@@ -611,7 +619,7 @@ module Fdis2
611
619
  if ret_iva > 0
612
620
  child_retenciones = Nokogiri::XML::Node.new "cfdi:Retenciones", xml
613
621
  child_retencion = Nokogiri::XML::Node.new "cfdi:Retencion", xml
614
- child_retencion['Base'] = total_line.round(4).to_s
622
+ child_retencion['Base'] = subtotal_line.round(4).to_s
615
623
  child_retencion['Impuesto'] = '002'
616
624
  child_retencion['TipoFactor'] = "Tasa"
617
625
 
@@ -640,13 +648,13 @@ module Fdis2
640
648
  comprobante['SubTotal'] = subtotal.round(2).to_s
641
649
 
642
650
 
643
- ## Poblanco cfdi:Impuestos
651
+ ## Poblando cfdi:Impuestos
644
652
  impuestos['TotalImpuestosRetenidos'] = suma_ret.round(2).to_s if suma_ret > 0
645
653
 
646
- if iva_id == 0
647
- impuestos['TotalImpuestosTrasladados'] = "0.00"
648
- else
654
+ if suma_iva > 0
649
655
  impuestos['TotalImpuestosTrasladados'] = suma_iva.round(2).to_s
656
+ else
657
+ impuestos['TotalImpuestosTrasladados'] = "0.00"
650
658
  end
651
659
 
652
660
 
@@ -672,12 +680,12 @@ module Fdis2
672
680
  traslado_child['TipoFactor'] = 'Tasa'
673
681
  traslado_child['Base'] = subtotal.round(2)
674
682
 
675
- if iva_id == 0
676
- traslado_child['Importe'] = "0.00"
677
- traslado_child['TasaOCuota'] = '0.000000'
678
- else
683
+ if suma_iva > 0
679
684
  traslado_child['Importe'] = suma_iva.round(2).to_s
680
685
  traslado_child['TasaOCuota'] = '0.160000'
686
+ else
687
+ traslado_child['Importe'] = "0.00"
688
+ traslado_child['TasaOCuota'] = '0.000000'
681
689
  end
682
690
 
683
691
  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.51"
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.51
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: 2024-07-18 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