Class: FE::Document::Reference

Inherits:
Element
  • 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"
}.freeze
DOCUMENT_TYPES =
{
  "01"=> "Factura Electronica",
  "02"=> "Nota de débito",
  "03"=> "Nota de crédito",
  "04"=> "Tiquete Electrónico",
  "05"=> "Nota de despacho",
  "06"=> "Contrato",
  "07"=> "Procedimiento",
  "08"=> "Factura Electrónica de compra",
  "09"=> "Factura Electronica de exportación",
  "10"=> "Sustituye factura rechazada por el Ministerio de Hacienda",
  "11"=> "Sustituye factura rechazada por el Receptor del comprobante",
  "12"=> "Sustituye Factura de exportación",
  "13"=> "Facturación mes vencido",
  "99"=> "Otros"

}.freeze

Instance Attribute Summary collapse

Attributes inherited from Element

#document, #version

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Reference

Returns a new instance of Reference.



43
44
45
46
47
48
49
# File 'lib/facturacr/document/reference.rb', line 43

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.



6
7
8
# File 'lib/facturacr/document/reference.rb', line 6

def code
  @code
end

#dateObject

Returns the value of attribute date.



6
7
8
# File 'lib/facturacr/document/reference.rb', line 6

def date
  @date
end

#document_typeObject

Returns the value of attribute document_type.



6
7
8
# File 'lib/facturacr/document/reference.rb', line 6

def document_type
  @document_type
end

#numberObject

Returns the value of attribute number.



6
7
8
# File 'lib/facturacr/document/reference.rb', line 6

def number
  @number
end

#reasonObject

Returns the value of attribute reason.



6
7
8
# File 'lib/facturacr/document/reference.rb', line 6

def reason
  @reason
end

Instance Method Details

#build_xml(node, document) ⇒ Object

Raises:



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/facturacr/document/reference.rb', line 51

def build_xml(node, document)
  raise FE::Error.new("reference invalid",class: self.class, messages: errors.messages) unless valid?
  node = Nokogiri::XML::Builder.new if node.nil?
  node.InformacionReferencia do |xml|
    xml.TipoDoc @document_type
    xml.Numero @number if @number.present?
    xml.FechaEmision @date.xmlschema
    xml.Codigo @code if @code.present?
    xml.Razon @reason if @reason.present?
  end
end