cfdi40 0.4.6 → 0.4.7

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: e4048e33cf4c2c3afc08006ea141c96431a4d407db2c15c62f16af9ec443e261
4
- data.tar.gz: 3d80d6b98b71753869048cf14eaa8fc8b7a6ead278b9d313ceebb1ea517cf701
3
+ metadata.gz: 3547682f502971438bc3e204ed001742c7695ba0b9f4b359b702c74494442b77
4
+ data.tar.gz: 22b21e8aaee290803d4e5d87e33275cb0e70389f9f5ec8112e1b0753a701d5e0
5
5
  SHA512:
6
- metadata.gz: 266289fcbc480d8a0006b4847c72c18edd52deb6c343304a875cc1fc8335b90d5f16385fdeac70d94179e9efcdba9c4baef77efc1c200e107616f235f44ba2f1
7
- data.tar.gz: 7ea20d0a5949da3af27660205edd3c25086d2f0afe3873031018b795fcb0f3da97bc57e6965b1eb4ebfbcc3cae02c09bd00a76e03a12505ccdde54e41669f302
6
+ metadata.gz: 29fcd6e0b992bbbe6e8372585bd040fea651c945942d18015088d5633a316938b351d3d662cb44cf4de8acafc070ce0beba7e6b889082c7e0fa597fc8e6676cb
7
+ data.tar.gz: b07b1b62bfee3040b54bf1412f8446e92854cbee963b7ef45a4e95ed44e176c4b54de758362fb939db0ff43c43e768feea31c1ca0eea684fd725dc7bcd002172
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cfdi40 (0.4.6)
4
+ cfdi40 (0.4.7)
5
5
  nokogiri (>= 1.10.10)
6
6
 
7
7
  GEM
@@ -162,6 +162,16 @@ module Cfdi40
162
162
  concepto
163
163
  end
164
164
 
165
+ # Load node 'Concepto' (rep) from a Nokogiri::XML::Element
166
+ def load_concepto_rep(ng_node)
167
+ concepto = ConceptoRep.new
168
+ concepto.parent_node = @conceptos
169
+ concepto.load_from_ng_node(ng_node)
170
+ concepto.precio_bruto = concepto.valor_unitario.to_f
171
+ @conceptos.children_nodes << concepto
172
+ concepto
173
+ end
174
+
165
175
  # Load node cfdi:Comprobante/cfdi:Impuestos
166
176
  #
167
177
  # Normally this node is calculated but must be read from the
@@ -10,7 +10,7 @@ module Cfdi40
10
10
  define_element_name 'Concepto'
11
11
  define_attribute :clave_prod_serv, xml_attribute: "ClaveProdServ", default: "84111506"
12
12
  define_attribute :no_identificacion, xml_attribute: "NoIdentificacion"
13
- define_attribute :cantidad, xml_attribute: "Cantidad", default: 1
13
+ define_attribute :cantidad, xml_attribute: "Cantidad", default: 1, format: :integer
14
14
  define_attribute :clave_unidad, xml_attribute: "ClaveUnidad", default: "ACT"
15
15
  define_attribute :unidad, xml_attribute: "Unidad"
16
16
  define_attribute :descripcion, xml_attribute: "Descripcion", no_writer: true, default: "Pago"
data/lib/cfdi40/node.rb CHANGED
@@ -48,6 +48,11 @@ module Cfdi40
48
48
 
49
49
  def self.define_reader(accessor, format)
50
50
  case format.to_s
51
+ when 'integer'
52
+ define_method("#{accessor}".to_sym) do
53
+ value = instance_variable_defined?("@#{accessor}".to_sym) ? instance_variable_get("@#{accessor}".to_sym) : 0
54
+ value.to_i
55
+ end
51
56
  when 't_Importe', 'decimal'
52
57
  define_method("#{accessor}".to_sym) do
53
58
  value = instance_variable_defined?("@#{accessor}".to_sym) ? instance_variable_get("@#{accessor}".to_sym) : 0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cfdi40
4
- VERSION = "0.4.6"
4
+ VERSION = "0.4.7"
5
5
  end
@@ -34,6 +34,8 @@ module Cfdi40
34
34
  end
35
35
 
36
36
  def load_conceptos
37
+ return load_concepto_rep if @cfdi.tipo_de_comprobante == 'P'
38
+
37
39
  n_concepto = 0
38
40
  xml_doc.xpath("//cfdi:Concepto").each do |node|
39
41
  n_concepto += 1
@@ -44,6 +46,13 @@ module Cfdi40
44
46
  end
45
47
  end
46
48
 
49
+ def load_concepto_rep
50
+ node = xml_doc.xpath("//cfdi:Concepto").first
51
+ return if node.nil?
52
+
53
+ concepto = @cfdi.load_concepto_rep(node)
54
+ end
55
+
47
56
  def load_emisor
48
57
  ng_emisor_node = xml_doc.xpath("//cfdi:Emisor").first
49
58
  return if ng_emisor_node.nil?
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.6
4
+ version: 0.4.7
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-03-12 00:00:00.000000000 Z
11
+ date: 2026-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri