fdis 0.1.27 → 0.1.29
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/lib/fdis/facturacion.rb +55 -60
- data/lib/fdis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c641c9a4d5fc07779b78954f3a0273b3ddc574e525e6f99f9558d85cabd01ab
|
4
|
+
data.tar.gz: 8f334a86f08e8f0aa3fd1255cdd69dc07aec6b20bbf6b11f044c5c2fc1a62656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e098e8909c0b26879ad70d9866436e27751ebdac0a2f80b87cd1ce87822d3b314db9cae98460f1cfd6dd1357aef34764d7ff9bee239dbe28813a5d1901a9da9b
|
7
|
+
data.tar.gz: 0da4a652c4eb1c762b0d241fafc97ef7c08634e395c014eefc473359a042c4cfd6e9391698d6eea0d0fd5d0eadc4e089f6b936ec91bb0d0c92c698d7b91967bc
|
data/lib/fdis/facturacion.rb
CHANGED
@@ -12,7 +12,7 @@ module Fdis
|
|
12
12
|
# receptor_rfc: 'XAXX010101000',
|
13
13
|
# receptor_cp: '47180',
|
14
14
|
# receptor_regimen: '616',
|
15
|
-
#
|
15
|
+
# tasa_iva: 0, 16, se toma tasa iva de factura madre
|
16
16
|
# forma_pago: '01',
|
17
17
|
# total: 100.00,
|
18
18
|
# monto_pago: 50.0,
|
@@ -117,7 +117,7 @@ module Fdis
|
|
117
117
|
|
118
118
|
# totales
|
119
119
|
total = params[:monto_pago].to_f
|
120
|
-
iva_id = params.fetch(:
|
120
|
+
iva_id = params.fetch(:tasa_iva, 16)
|
121
121
|
|
122
122
|
pago_totales = xml.at_xpath("//pago20:Totales")
|
123
123
|
pago_totales['MontoTotalPagos'] = total.round(2).to_s # total
|
@@ -132,12 +132,6 @@ module Fdis
|
|
132
132
|
pago_totales['TotalTrasladosBaseIVA0'] = subtotal.round(2).to_s # subtotal
|
133
133
|
pago_totales['TotalTrasladosImpuestoIVA0'] = iva.round(2).to_s # iva
|
134
134
|
|
135
|
-
elsif iva_id == 8
|
136
|
-
subtotal = total / 1.08
|
137
|
-
iva = total - subtotal
|
138
|
-
|
139
|
-
pago_totales['TotalTrasladosBaseIVA8'] = subtotal.round(2).to_s # subtotal
|
140
|
-
pago_totales['TotalTrasladosImpuestoIVA8'] = iva.round(2).to_s # iva
|
141
135
|
else
|
142
136
|
subtotal = total / 1.16
|
143
137
|
iva = total - subtotal
|
@@ -173,7 +167,7 @@ module Fdis
|
|
173
167
|
child_pago_relacionado['ImpPagado'] = total.round(2).to_s
|
174
168
|
child_pago_relacionado['ImpSaldoInsoluto'] = (saldo_anterior - total).round(2).to_s
|
175
169
|
|
176
|
-
if iva_id == 16
|
170
|
+
if iva_id == 16
|
177
171
|
child_pago_relacionado['ObjetoImpDR'] = '02'
|
178
172
|
|
179
173
|
impuestos_dr = Nokogiri::XML::Node.new "pago20:ImpuestosDR", xml
|
@@ -185,19 +179,11 @@ module Fdis
|
|
185
179
|
traslado_p = Nokogiri::XML::Node.new "pago20:TrasladoP", xml
|
186
180
|
|
187
181
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# t_tax = total - t_subtotal
|
192
|
-
|
193
|
-
traslado_p['TasaOCuotaP'] = '0.160000'
|
194
|
-
else
|
195
|
-
traslado['TasaOCuotaDR'] = '0.080000'
|
196
|
-
# t_subtotal = total / 1.08
|
197
|
-
# t_tax = total - t_subtotal
|
182
|
+
traslado['TasaOCuotaDR'] = '0.160000'
|
183
|
+
# t_subtotal = total / 1.16
|
184
|
+
# t_tax = total - t_subtotal
|
198
185
|
|
199
|
-
|
200
|
-
end
|
186
|
+
traslado_p['TasaOCuotaP'] = '0.160000'
|
201
187
|
|
202
188
|
traslado['TipoFactorDR'] = 'Tasa'
|
203
189
|
traslado['ImpuestoDR'] = '002'
|
@@ -205,7 +191,6 @@ module Fdis
|
|
205
191
|
traslado['BaseDR'] = subtotal.round(4).to_s #subtotal
|
206
192
|
traslado['ImporteDR'] = iva.round(4).to_s # tax
|
207
193
|
|
208
|
-
|
209
194
|
|
210
195
|
traslado_p['BaseP'] = subtotal.round(4).to_s
|
211
196
|
traslado_p['ImpuestoP'] = '002'
|
@@ -213,7 +198,6 @@ module Fdis
|
|
213
198
|
traslado_p['ImporteP'] = iva.round(4).to_s # tax
|
214
199
|
|
215
200
|
|
216
|
-
|
217
201
|
traslados_dr.add_child(traslado)
|
218
202
|
impuestos_dr.add_child(traslados_dr)
|
219
203
|
child_pago_relacionado.add_child(impuestos_dr)
|
@@ -433,6 +417,7 @@ module Fdis
|
|
433
417
|
# receptor_rfc: '',
|
434
418
|
# receptor_regimen: '',
|
435
419
|
# uso_cfdi: 'G03',
|
420
|
+
# tasa_iva: 0, 16,
|
436
421
|
# time: "%Y-%m-%dT%H:%M:%S",
|
437
422
|
# line_items: [
|
438
423
|
# {
|
@@ -502,7 +487,7 @@ module Fdis
|
|
502
487
|
receptor['Rfc'] = params.fetch(:receptor_rfc, '')
|
503
488
|
receptor['Nombre'] = params.fetch(:receptor_razon, '')
|
504
489
|
receptor['DomicilioFiscalReceptor'] = params.fetch(:receptor_cp, '47180')
|
505
|
-
if params[:
|
490
|
+
if params[:receptor_rfc] == 'XAXX010101000'
|
506
491
|
receptor['UsoCFDI'] = 'S01'
|
507
492
|
receptor['RegimenFiscalReceptor'] = '616'
|
508
493
|
else
|
@@ -530,34 +515,35 @@ module Fdis
|
|
530
515
|
suma_iva = 0.00
|
531
516
|
suma_ret = 0.00
|
532
517
|
|
518
|
+
iva_id = params.fetch(:tasa_iva, 16)
|
519
|
+
|
533
520
|
line_items.each do |line|
|
534
521
|
ret_iva = line.fetch(:retencion_iva, 0)
|
535
|
-
puts ret_iva
|
536
|
-
|
537
|
-
|
538
|
-
## revisando si la linea tiene iva 0
|
539
|
-
if line[:tax_included] == true
|
540
|
-
# if line[:tipo_impuesto] == '004'
|
541
|
-
# valor_unitario = (line[:valor_unitario].to_f)
|
542
|
-
# else
|
543
|
-
# end
|
544
|
-
valor_unitario = ((line[:valor_unitario]).to_f) / 1.16
|
545
|
-
else
|
546
|
-
valor_unitario = (line[:valor_unitario].to_f)
|
547
|
-
end
|
548
522
|
|
549
523
|
cantidad = line[:cantidad].to_f
|
550
|
-
|
524
|
+
|
525
|
+
|
551
526
|
|
552
527
|
# if line[:tipo_impuesto] == '004'
|
553
528
|
# total_acumulator = cantidad * valor_unitario
|
554
529
|
# else
|
555
530
|
# total_acumulator = cantidad * valor_unitario * 1.16
|
556
531
|
# end
|
532
|
+
|
533
|
+
## TODO: ajustar todo a facturacion con iva cero
|
557
534
|
|
558
|
-
total_acumulator = cantidad * valor_unitario
|
535
|
+
total_acumulator = cantidad * line[:valor_unitario].to_f
|
536
|
+
|
537
|
+
if iva_id == 16
|
538
|
+
valor_unitario = (line[:valor_unitario].to_f) / 1.16
|
539
|
+
else
|
540
|
+
valor_unitario = line[:valor_unitario].to_f
|
541
|
+
end
|
542
|
+
|
543
|
+
total_line = cantidad * valor_unitario
|
559
544
|
|
560
545
|
importe_iva = total_acumulator - total_line
|
546
|
+
|
561
547
|
subtotal += total_line
|
562
548
|
suma_iva += importe_iva
|
563
549
|
suma_total += total_acumulator
|
@@ -595,20 +581,24 @@ module Fdis
|
|
595
581
|
|
596
582
|
## Creando cfdi:Traslados para cada linea
|
597
583
|
child_traslados = Nokogiri::XML::Node.new "cfdi:Traslados", xml
|
584
|
+
|
585
|
+
|
598
586
|
child_traslado = Nokogiri::XML::Node.new "cfdi:Traslado", xml
|
599
|
-
child_traslado['Base'] = total_line.round(4).to_s
|
600
|
-
child_traslado['Importe'] = importe_iva.round(4).to_s
|
601
587
|
child_traslado['Impuesto'] = '002'
|
602
|
-
child_traslado['TasaOCuota'] = '0.160000'
|
603
588
|
child_traslado['TipoFactor'] = "Tasa"
|
604
589
|
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
590
|
+
if iva_id == 0
|
591
|
+
child_traslado['Base'] = "1"
|
592
|
+
child_traslado['Importe'] = "0.00"
|
593
|
+
child_traslado['TasaOCuota'] = '0.000000'
|
594
|
+
else
|
595
|
+
child_traslado['Base'] = total_line.round(4).to_s
|
596
|
+
child_traslado['Importe'] = importe_iva.round(4).to_s
|
597
|
+
child_traslado['TasaOCuota'] = '0.160000'
|
598
|
+
end
|
609
599
|
|
610
600
|
|
611
|
-
#
|
601
|
+
# Mezclando todo lo anterios
|
612
602
|
child_traslados.add_child(child_traslado)
|
613
603
|
child_impuestos.add_child(child_traslados)
|
614
604
|
child_concepto.add_child(child_impuestos)
|
@@ -649,7 +639,13 @@ module Fdis
|
|
649
639
|
|
650
640
|
## Poblanco cfdi:Impuestos
|
651
641
|
impuestos['TotalImpuestosRetenidos'] = suma_ret.round(2).to_s if suma_ret > 0
|
652
|
-
|
642
|
+
|
643
|
+
if iva_id == 0
|
644
|
+
impuestos['TotalImpuestosTrasladados'] = "0.00"
|
645
|
+
else
|
646
|
+
impuestos['TotalImpuestosTrasladados'] = suma_iva.round(2).to_s
|
647
|
+
end
|
648
|
+
|
653
649
|
|
654
650
|
## filling default retencion info
|
655
651
|
if suma_ret > 0
|
@@ -669,22 +665,21 @@ module Fdis
|
|
669
665
|
|
670
666
|
## filling traslado info
|
671
667
|
traslado_child = Nokogiri::XML::Node.new "cfdi:Traslado", xml
|
672
|
-
traslado_child['Base'] = subtotal.round(2)
|
673
668
|
traslado_child['Impuesto'] = '002'
|
674
|
-
traslado_child['Importe'] = suma_iva.round(2).to_s
|
675
669
|
traslado_child['TipoFactor'] = 'Tasa'
|
676
|
-
traslado_child['TasaOCuota'] = '0.160000'
|
677
|
-
traslados.add_child(traslado_child)
|
678
|
-
impuestos.add_child(traslados)
|
679
|
-
|
680
|
-
|
681
670
|
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
671
|
+
if iva_id == 0
|
672
|
+
traslado_child['Base'] = "1"
|
673
|
+
traslado_child['Importe'] = "0.00"
|
674
|
+
traslado_child['TasaOCuota'] = '0.000000'
|
675
|
+
else
|
676
|
+
traslado_child['Base'] = subtotal.round(2)
|
677
|
+
traslado_child['Importe'] = suma_iva.round(2).to_s
|
678
|
+
traslado_child['TasaOCuota'] = '0.160000'
|
679
|
+
end
|
687
680
|
|
681
|
+
traslados.add_child(traslado_child)
|
682
|
+
impuestos.add_child(traslados)
|
688
683
|
|
689
684
|
|
690
685
|
path = File.join(File.dirname(__FILE__), *%w[.. tmp])
|
data/lib/fdis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fdis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angel Padilla
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|