Class: FE::Document::Reference

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/facturacr/document/reference.rb

Constant Summary collapse

REFERENCE_CODES =
{
  "01" => "Anula Documento de referencia",
  "02" => "Corrige texto documento de referencia",
  "03" => "Corrige monto",
  "04" => "Referencia a otro documento",
  "05" => "Sustituye comprobante provisional por contingencia",
  "99" => "Otros"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Reference

Returns a new instance of Reference.



25
26
27
28
29
30
31
# File 'lib/facturacr/document/reference.rb', line 25

def initialize(args={})
  @document_type = args[:document_type]
  @number = args[:number]
  @date = args[:date]
  @code = args[:code]
  @reason = args[:reason]
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



8
9
10
# File 'lib/facturacr/document/reference.rb', line 8

def code
  @code
end

#dateObject

Returns the value of attribute date.



8
9
10
# File 'lib/facturacr/document/reference.rb', line 8

def date
  @date
end

#document_typeObject

Returns the value of attribute document_type.



8
9
10
# File 'lib/facturacr/document/reference.rb', line 8

def document_type
  @document_type
end

#numberObject

Returns the value of attribute number.



8
9
10
# File 'lib/facturacr/document/reference.rb', line 8

def number
  @number
end

#reasonObject

Returns the value of attribute reason.



8
9
10
# File 'lib/facturacr/document/reference.rb', line 8

def reason
  @reason
end

Instance Method Details

#build_xml(node) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/facturacr/document/reference.rb', line 33

def build_xml(node)
  raise "Reference Invalid: #{errors.messages}" unless valid?
  node = Nokogiri::XML::Builder.new if node.nil?
  node.InformacionReferencia do |xml|
    xml.TipoDoc @document_type
    xml.Numero @number
    xml.FechaEmision @date.xmlschema
    xml.Codigo @code
    xml.Razon @reason
  end
end