Class: Facturapi::Helpers::Dte

Inherits:
Object
  • Object
show all
Defined in:
lib/facturapi/helpers/dte.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Dte

Returns a new instance of Dte.



6
7
8
9
10
11
# File 'lib/facturapi/helpers/dte.rb', line 6

def initialize(params = {})
  @encabezado = params[:encabezado]
  self.detalle = params[:detalle]
  self.dsc_rcg_global = params[:dsc_rcg_global]
  self.referencia = params[:referencia]
end

Instance Attribute Details

#detalleObject

Returns the value of attribute detalle.



4
5
6
# File 'lib/facturapi/helpers/dte.rb', line 4

def detalle
  @detalle
end

#dsc_rcg_globalObject

Returns the value of attribute dsc_rcg_global.



4
5
6
# File 'lib/facturapi/helpers/dte.rb', line 4

def dsc_rcg_global
  @dsc_rcg_global
end

#encabezadoObject

Returns the value of attribute encabezado.



4
5
6
# File 'lib/facturapi/helpers/dte.rb', line 4

def encabezado
  @encabezado
end

#referenciaObject

Returns the value of attribute referencia.



4
5
6
# File 'lib/facturapi/helpers/dte.rb', line 4

def referencia
  @referencia
end

Instance Method Details

#as_nodeObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/facturapi/helpers/dte.rb', line 43

def as_node
  doc = XML::Document.new
  doc.root = create_node('DTE', version: '1.0') do |dte|
    dte << create_node('Documento', 'ID' => 'F100T39') do |documento|
      documento << encabezado.as_node
      detalle.each { |d| documento << d.as_node }
      dsc_rcg_global.each { |d| documento << d.as_node }
      referencia.each { |r| documento << r.as_node }
    end
  end
  doc
end