cfdi40 0.3.2 → 0.4.0

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: 2b059ddd5e63b0d7cfb314d888c3adf99da0ee6e1d715555a586b94cdecb6213
4
- data.tar.gz: 5f6538b53add3cc98020d612644fa5a420ec629cbb0ab62c878e1b01293945a0
3
+ metadata.gz: 7061dcb4f93f1b7e9506ca717ebd3ed7e770ae953d8a4a35bb4d070f15e31dfe
4
+ data.tar.gz: 773908ae6f3b0b6b88171a293bbdf0a3605eea532e0112c08350eef887358e28
5
5
  SHA512:
6
- metadata.gz: 4928ad092b02eb76e8262f68d00d265dc32686759956491199d5bd7357d6aa6390019eb7073fbabb354ef4a1c58fc761810bc7ef14ac54bd26e14d3e1672bb1a
7
- data.tar.gz: 512ec675667b5b1c768035d70c451c4c255b174ea91bf1dde8b0984298fa5dfff75e29648b6e7fba8b7c1dfc8253155d6edb276bca34d2a2137a8c17da23505f
6
+ metadata.gz: 6c20033c554dd43a92f994af3159a9c024a217691d76a04fddfd61aff1253349963c8dcd5061c50d684be97d1714457f11708afa59d5ce1ae366bcb87e7e3c05
7
+ data.tar.gz: ebefe6e662e9f12a9dc00e0da2e00ecbc3e9b7dc7266733371e75842a909be2d46d950546c9fe72cc647fc33d3d5847667650609b9b09ff4230c32c9c584b2f0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cfdi40 (0.3.1)
4
+ cfdi40 (0.4.0)
5
5
  nokogiri (>= 1.10.10)
6
6
 
7
7
  GEM
data/README_es-MX.md CHANGED
@@ -77,9 +77,7 @@ Hasta ahora:
77
77
  cfdi.receptor.regimen_fiscal = '616'
78
78
  cfdi.receptor.uso_cfdi = 'CP01'
79
79
 
80
- # Agrega un concepto en pesos,
81
- # precio final al cliente (neto)
82
- # causa IVA con tasa de 16% (default)
80
+ # Agrega un pago en pesos
83
81
  cfdi.add_pago(
84
82
  monto: 200.17,
85
83
  uuid: 'e40229b3-5c4b-46fb-9ba8-707df828a5bc',
@@ -191,6 +191,13 @@ module Cfdi40
191
191
  complemento.add_pago(attributes)
192
192
  end
193
193
 
194
+ def remove_pago(index)
195
+ return unless defined?(@complemento)
196
+ return if complemento.pagos.pago_nodes.empty?
197
+
198
+ complemento.pagos.remove_pago(index.to_i)
199
+ end
200
+
194
201
  def to_s
195
202
  to_xml
196
203
  end
@@ -12,7 +12,7 @@ module Cfdi40
12
12
  define_attribute :cantidad, xml_attribute: "Cantidad", default: 1, format: :decimal
13
13
  define_attribute :clave_unidad, xml_attribute: "ClaveUnidad"
14
14
  define_attribute :unidad, xml_attribute: "Unidad"
15
- define_attribute :descripcion, xml_attribute: "Descripcion"
15
+ define_attribute :descripcion, xml_attribute: "Descripcion", no_writer: true
16
16
  define_attribute :valor_unitario, xml_attribute: "ValorUnitario", format: :t_Importe
17
17
  define_attribute :importe, xml_attribute: "Importe", format: :t_Importe
18
18
  define_attribute :descuento, xml_attribute: "Descuento", format: :t_Importe
data/lib/cfdi40/node.rb CHANGED
@@ -33,10 +33,11 @@ module Cfdi40
33
33
  @@element_names ||= {}
34
34
  end
35
35
 
36
- def self.define_attribute(accessor, xml_attribute:, default: nil, format: nil, readonly: false)
36
+ # +no_writer+ option implies that the writer methos must be defined in the child class.
37
+ def self.define_attribute(accessor, xml_attribute:, default: nil, format: nil, readonly: false, no_writer: nil)
37
38
  verify_class_variables
38
39
  define_reader(accessor, format)
39
- define_writer(accessor, readonly, format)
40
+ define_writer(accessor, readonly, format) unless no_writer
40
41
 
41
42
  @@attributes[name][accessor.to_sym] = xml_attribute
42
43
  @@default_values[name][accessor.to_sym] = default if default
@@ -163,6 +164,12 @@ module Cfdi40
163
164
  @children_nodes << child_node
164
165
  end
165
166
 
167
+ def delete_child(child_node)
168
+ raise Error, "child_node must be a Node object" unless child_node.is_a?(Node)
169
+
170
+ @children_nodes.delete(child_node)
171
+ end
172
+
166
173
  # Locks for readonly this node and children
167
174
  def lock
168
175
  @readonly = true
data/lib/cfdi40/pago.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # /cfdi:Comprobante/cfdi:Complemento/pago20:Pagos/pago20:Pago
4
4
  module Cfdi40
5
5
  class Pago < Node
6
- define_attribute :monto, xml_attribute: "Monto", format: :t_Importe
6
+ define_attribute :monto, xml_attribute: "Monto", format: :t_ImporteMXN
7
7
  define_attribute :fecha_pago, xml_attribute: "FechaPago", format: :t_FechaH
8
8
  define_attribute :forma_pago, xml_attribute: "FormaDePagoP"
9
9
  define_attribute :moneda, xml_attribute: "MonedaP", readonly: true, default: "MXN"
data/lib/cfdi40/pagos.rb CHANGED
@@ -27,6 +27,12 @@ module Cfdi40
27
27
  true
28
28
  end
29
29
 
30
+ def remove_pago(index)
31
+ @children_nodes.delete(pago_nodes[index])
32
+ update_totales
33
+ true
34
+ end
35
+
30
36
  def update_totales
31
37
  update_totales_traslado_iva16
32
38
  update_total_monto
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cfdi40
4
- VERSION = "0.3.2"
4
+ VERSION = "0.4.0"
5
5
  end
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.3.2
4
+ version: 0.4.0
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: 2025-10-27 00:00:00.000000000 Z
11
+ date: 2025-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri