Class: Cfdi40::Pago
Instance Attribute Summary collapse
-
#folio ⇒ Object
Returns the value of attribute folio.
-
#importe_saldo_anterior ⇒ Object
Returns the value of attribute importe_saldo_anterior.
-
#num_parcialidad ⇒ Object
Returns the value of attribute num_parcialidad.
-
#objeto_impuestos ⇒ Object
Returns the value of attribute objeto_impuestos.
-
#serie ⇒ Object
Returns the value of attribute serie.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Attributes inherited from Node
#children_nodes, #element_name, #parent_node, #readonly, #xml_document, #xml_parent
Instance Method Summary collapse
-
#add_docto_relacionado(attributes = {}) ⇒ Object
Generate docto_relacionado node Data for dcto_relacionado node is obtained from de accessors uuid, serie, folio.
- #add_impuestos_p ⇒ Object
- #docto_relacionados ⇒ Object
- #impuestos_p_node ⇒ Object
- #load_dr(dr_node) ⇒ Object
- #load_impuestos_p(ng_node) ⇒ Object
- #traslados_summary ⇒ Object
Methods inherited from Node
#add_attributes_to, #add_child_node, #add_children_to, #add_namespaces_to, #attibute_is_null?, attributes, #clean_cached_xml, #create_xml_node, #current_namespace, default_values, define_attribute, define_element_name, define_namespace, define_reader, define_writer, #delete_child, element_name, #expanded_element_name, formats, #formatted_value, #initialize, #load_from_ng_node, #lock, namespaces, #set_defaults, verify_class_variables
Constructor Details
This class inherits a constructor from Cfdi40::Node
Instance Attribute Details
#folio ⇒ Object
Returns the value of attribute folio.
12 13 14 |
# File 'lib/cfdi40/pago.rb', line 12 def folio @folio end |
#importe_saldo_anterior ⇒ Object
Returns the value of attribute importe_saldo_anterior.
12 13 14 |
# File 'lib/cfdi40/pago.rb', line 12 def importe_saldo_anterior @importe_saldo_anterior end |
#num_parcialidad ⇒ Object
Returns the value of attribute num_parcialidad.
12 13 14 |
# File 'lib/cfdi40/pago.rb', line 12 def num_parcialidad @num_parcialidad end |
#objeto_impuestos ⇒ Object
Returns the value of attribute objeto_impuestos.
12 13 14 |
# File 'lib/cfdi40/pago.rb', line 12 def objeto_impuestos @objeto_impuestos end |
#serie ⇒ Object
Returns the value of attribute serie.
12 13 14 |
# File 'lib/cfdi40/pago.rb', line 12 def serie @serie end |
#uuid ⇒ Object
Returns the value of attribute uuid.
12 13 14 |
# File 'lib/cfdi40/pago.rb', line 12 def uuid @uuid end |
Instance Method Details
#add_docto_relacionado(attributes = {}) ⇒ Object
Generate docto_relacionado node Data for dcto_relacionado node is obtained from de accessors
uuid, serie, folio
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cfdi40/pago.rb', line 17 def add_docto_relacionado(attributes = {}) docto_relacionado = DoctoRelacionado.new docto_relacionado.parent_node = self docto_relacionado.id_documento = attributes[:uuid] docto_relacionado.serie = attributes[:serie] docto_relacionado.folio = attributes[:folio] docto_relacionado.num_parcialidad = attributes[:num_parcialidad] docto_relacionado.imp_saldo_ant = attributes[:importe_saldo_anterior].round(2) docto_relacionado.imp_pagado = attributes[:imp_pagado] docto_relacionado.calculate! @children_nodes << docto_relacionado end |
#add_impuestos_p ⇒ Object
30 31 32 33 34 |
# File 'lib/cfdi40/pago.rb', line 30 def add_impuestos_p impuestos_p = ImpuestosP.new add_child_node impuestos_p impuestos_p.traslados_p.add_traslado_p_nodes end |
#docto_relacionados ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/cfdi40/pago.rb', line 36 def docto_relacionados return @docto_relacionados if defined?(@docto_relacionados) @docto_relacionados = @children_nodes.select do |child| child.instance_of?(::Cfdi40::DoctoRelacionado) end end |
#impuestos_p_node ⇒ Object
69 70 71 |
# File 'lib/cfdi40/pago.rb', line 69 def impuestos_p_node @children_nodes.select { |child| child.instance_of?(Cfdi40::ImpuestosP) }.first end |
#load_dr(dr_node) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/cfdi40/pago.rb', line 59 def load_dr(dr_node) dr = DoctoRelacionado.new dr.load_from_ng_node(dr_node) dr.parent_node = self @children_nodes << dr imp_dr_node = dr_node.xpath("//pago20:ImpuestosDR", Cfdi40::Pagos::NG_NAMESPACE).first dr.load_impuestos_dr(imp_dr_node) unless imp_dr_node.nil? dr end |
#load_impuestos_p(ng_node) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/cfdi40/pago.rb', line 73 def load_impuestos_p(ng_node) imp_p = ImpuestosP.new imp_p.load_from_ng_node(ng_node) add_child_node imp_p trns_p_node = ng_node.xpath("//pago20:TrasladosP", { "pago20" => "http://www.sat.gob.mx/Pagos20" }).first imp_p.load_traslados_p_node(trns_p_node) imp_p end |
#traslados_summary ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cfdi40/pago.rb', line 45 def traslados_summary return @summary if defined?(@summary) summary = {} docto_relacionados.each do |docto| docto.traslados_summary.each do |key, data| summary[key] ||= { base: 0, importe: 0 } summary[key][:base] += data[:base] summary[key][:importe] += data[:importe] end end @summary = summary end |