fdis2 0.1.44 → 0.1.50

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: 1f7821abcc5bf80c46a51ed952ca9bac9bb62f4100af183d1b483277f1313097
4
- data.tar.gz: cafa883502bf620e3457c0912d5db2caaa2a693aa4de8f305b3b8a6a43b36039
3
+ metadata.gz: 1ca7c6a4bb66c017ef3b541dce2bccd51dd83ada5ad15347435df6ddfb81726c
4
+ data.tar.gz: f070f275f1b047bae6e070cc2a7228da0456044fd033398b6eeec3efd998c5a2
5
5
  SHA512:
6
- metadata.gz: 0a8e5e9bf145f072a9ae5248d766c1f042b06eff28f58f16da3418ca9cfd3de1aa5229f7f26c87bd72eee590c42f17b41c4bd38d9c517a699a6f4160802bc2ac
7
- data.tar.gz: ffc7494484d5e95d5e95de9799ecd7c5b7ff08fa4b305b7463627d22310646c56a93214da522b9d59997c585c8541775a6a1456a9523f3935351a776cefbaeed
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]}"
@@ -166,7 +167,7 @@ module Fdis2
166
167
 
167
168
  child_pago_relacionado['ImpSaldoAnt'] = saldo_anterior.round(2).to_s
168
169
  child_pago_relacionado['ImpPagado'] = total.round(2).to_s
169
- child_pago_relacionado['ImpSaldoInsoluto'] = (saldo_anterior - total).round(2).to_s
170
+ child_pago_relacionado['ImpSaldoInsoluto'] = (saldo_anterior - total).round(2).abs.to_s
170
171
  child_pago_relacionado['ObjetoImpDR'] = '02'
171
172
 
172
173
  impuestos_dr = Nokogiri::XML::Node.new "pago20:ImpuestosDR", xml
@@ -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.44"
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.44
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-03-31 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