cfdi40 0.4.7 → 0.4.9
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/Gemfile.lock +1 -1
- data/README_es-MX.md +1 -1
- data/lib/cfdi40/cfdi_relacionado.rb +7 -0
- data/lib/cfdi40/cfdi_relacionados.rb +19 -0
- data/lib/cfdi40/comprobante.rb +28 -2
- data/lib/cfdi40/version.rb +1 -1
- data/lib/cfdi40/xml_loader.rb +12 -1
- data/lib/cfdi40.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c758cb58473d09fb1095b0585af433409faa4db755e4dfb66aa2e6280357ce2
|
|
4
|
+
data.tar.gz: 3b88a0dec21672a62292e4184888e07f1bf7ea7ac102041101385979c671cdc5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 91fdc2bd550adf234514a405aa024f83241a1f45afec56a1b70b5b554cde031f8a0dbbd22d97912e4f38ea7eed9c2ee5d31735c0a86b5f8db880a3e67c88533c
|
|
7
|
+
data.tar.gz: fb7d6e02b0d9207664a045a3e43b6f15ef422007e0d4298d9682076bf3e40d1522c0542f6a1187ef69cb74844f77593b332c19ec25fe51033a908e8a33120cc4
|
data/Gemfile.lock
CHANGED
data/README_es-MX.md
CHANGED
|
@@ -39,7 +39,7 @@ Hasta ahora:
|
|
|
39
39
|
cfdi.receptor.rfc = 'XAXX010101000'
|
|
40
40
|
cfdi.receptor.domicilio_fiscal = '06000'
|
|
41
41
|
cfdi.receptor.regimen_fiscal = '616'
|
|
42
|
-
cfdi.receptor.uso_cfdi = '
|
|
42
|
+
cfdi.receptor.uso_cfdi = 'S01'
|
|
43
43
|
|
|
44
44
|
# Agrega un concepto en pesos,
|
|
45
45
|
# precio final al cliente (neto)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cfdi40
|
|
4
|
+
class CfdiRelacionados < Node
|
|
5
|
+
define_attribute :tipo_relacion, xml_attribute: "TipoRelacion"
|
|
6
|
+
|
|
7
|
+
def add_cfdi(uuid)
|
|
8
|
+
cfdi_relacionado = CfdiRelacionado.new
|
|
9
|
+
cfdi_relacionado.uuid = uuid
|
|
10
|
+
cfdi_relacionado.parent_node = self
|
|
11
|
+
@children_nodes << cfdi_relacionado
|
|
12
|
+
cfdi_relacionado
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def cfdi_relacionados
|
|
16
|
+
@children_nodes
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/cfdi40/comprobante.rb
CHANGED
|
@@ -31,7 +31,7 @@ module Cfdi40
|
|
|
31
31
|
define_attribute :lugar_expedicion, xml_attribute: "LugarExpedicion"
|
|
32
32
|
define_attribute :confirmacion, xml_attribute: "Confirmacion"
|
|
33
33
|
|
|
34
|
-
attr_reader :emisor, :receptor, :conceptos, :private_key, :sat_csd, :errors, :cadena_original
|
|
34
|
+
attr_reader :emisor, :receptor, :conceptos, :private_key, :sat_csd, :errors, :cadena_original, :cfdi_relacionados
|
|
35
35
|
attr_writer :key_data, :key_pass, :namespace_pagos_on_root
|
|
36
36
|
attr_accessor :loaded_xml
|
|
37
37
|
|
|
@@ -46,6 +46,7 @@ module Cfdi40
|
|
|
46
46
|
@receptor.parent_node = self
|
|
47
47
|
@sat_csd = SatCsd.new
|
|
48
48
|
@fecha ||= Time.now
|
|
49
|
+
@cfdi_relacionados = []
|
|
49
50
|
@children_nodes = [@emisor, @receptor, @conceptos]
|
|
50
51
|
@namespace_pagos_on_root = false
|
|
51
52
|
set_defaults
|
|
@@ -209,7 +210,7 @@ module Cfdi40
|
|
|
209
210
|
complemento.pagos.remove_pago(index.to_i)
|
|
210
211
|
end
|
|
211
212
|
|
|
212
|
-
# See test_adding_pago_with_n_docto_relacionados in file test/test_cfdi40_rep.rb
|
|
213
|
+
# See test_adding_pago_with_n_docto_relacionados in file test/test_cfdi40_rep.rb
|
|
213
214
|
def add_splitted_pago(attributes = {})
|
|
214
215
|
raise Error, "CFDi debe ser tipo 'P'" unless tipo_de_comprobante == "P"
|
|
215
216
|
|
|
@@ -217,6 +218,31 @@ module Cfdi40
|
|
|
217
218
|
complemento.add_splitted_pago(attributes)
|
|
218
219
|
end
|
|
219
220
|
|
|
221
|
+
def add_cfdi_relacionado(tipo_relacion, uuid)
|
|
222
|
+
cfdi_relacionados_node = CfdiRelacionados.new
|
|
223
|
+
cfdi_relacionados_node.tipo_relacion = tipo_relacion
|
|
224
|
+
cfdi_relacionados_node.parent_node = self
|
|
225
|
+
cfdi_relacionados_node.add_cfdi(uuid)
|
|
226
|
+
@children_nodes.unshift cfdi_relacionados_node
|
|
227
|
+
@cfdi_relacionados ||= []
|
|
228
|
+
@cfdi_relacionados.unshift cfdi_relacionados_node
|
|
229
|
+
cfdi_relacionados_node
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def cfdi_relacionados_nodes
|
|
233
|
+
@cfdi_relacionados
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def remove_cfdi_relacionado(index)
|
|
237
|
+
return if @cfdi_relacionados.empty?
|
|
238
|
+
|
|
239
|
+
nodo = @cfdi_relacionados[index.to_i]
|
|
240
|
+
return unless nodo
|
|
241
|
+
|
|
242
|
+
delete_child(nodo)
|
|
243
|
+
@cfdi_relacionados.delete_at(index.to_i)
|
|
244
|
+
end
|
|
245
|
+
|
|
220
246
|
def to_s
|
|
221
247
|
to_xml
|
|
222
248
|
end
|
data/lib/cfdi40/version.rb
CHANGED
data/lib/cfdi40/xml_loader.rb
CHANGED
|
@@ -19,6 +19,7 @@ module Cfdi40
|
|
|
19
19
|
load_impuestos
|
|
20
20
|
load_pagos
|
|
21
21
|
load_tfd
|
|
22
|
+
load_cfdi_relacionados
|
|
22
23
|
|
|
23
24
|
@cfdi.lock if readonly?
|
|
24
25
|
@cfdi.loaded_xml = xml_string
|
|
@@ -50,7 +51,7 @@ module Cfdi40
|
|
|
50
51
|
node = xml_doc.xpath("//cfdi:Concepto").first
|
|
51
52
|
return if node.nil?
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
@cfdi.load_concepto_rep(node)
|
|
54
55
|
end
|
|
55
56
|
|
|
56
57
|
def load_emisor
|
|
@@ -88,5 +89,15 @@ module Cfdi40
|
|
|
88
89
|
|
|
89
90
|
@cfdi.load_pagos(pagos_node)
|
|
90
91
|
end
|
|
92
|
+
|
|
93
|
+
def load_cfdi_relacionados
|
|
94
|
+
xml_doc.xpath("//cfdi:CfdiRelacionados").each do |cfdi_rel_node|
|
|
95
|
+
tipo_relacion = cfdi_rel_node.attributes["TipoRelacion"].value
|
|
96
|
+
cfdi_rel_node.xpath("cfdi:CfdiRelacionado").each do |cfdi_node|
|
|
97
|
+
uuid = cfdi_node.attributes["UUID"].value
|
|
98
|
+
@cfdi.add_cfdi_relacionado(tipo_relacion, uuid)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
91
102
|
end
|
|
92
103
|
end
|
data/lib/cfdi40.rb
CHANGED
|
@@ -22,6 +22,8 @@ require_relative "cfdi40/traslado"
|
|
|
22
22
|
require_relative "cfdi40/complemento_concepto"
|
|
23
23
|
require_relative "cfdi40/inst_educativas"
|
|
24
24
|
require_relative "cfdi40/complemento"
|
|
25
|
+
require_relative "cfdi40/cfdi_relacionados"
|
|
26
|
+
require_relative "cfdi40/cfdi_relacionado"
|
|
25
27
|
require_relative "cfdi40/concepto_rep"
|
|
26
28
|
require_relative "cfdi40/pagos"
|
|
27
29
|
require_relative "cfdi40/pago"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cfdi40
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Israel Benítez
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -43,6 +43,8 @@ files:
|
|
|
43
43
|
- Rakefile
|
|
44
44
|
- cfdi40.gemspec
|
|
45
45
|
- lib/cfdi40.rb
|
|
46
|
+
- lib/cfdi40/cfdi_relacionado.rb
|
|
47
|
+
- lib/cfdi40/cfdi_relacionados.rb
|
|
46
48
|
- lib/cfdi40/complemento.rb
|
|
47
49
|
- lib/cfdi40/complemento_concepto.rb
|
|
48
50
|
- lib/cfdi40/comprobante.rb
|