Class: FE::Document::Exoneration

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

Constant Summary collapse

DOCUMENT_TYPES =
{
  "01" => "Compras Autorizadas",
  "02" => "Ventas exentas a diplomáticos",
  "03" => "Autorizado por Ley especial",
  "04" => "Exenciones Dirección General de Hacienda",
  "05" => "Transitorio V",
  "06" => "Transitorio IX",
  "07" => "Transitorio XVII",
  "99" => "Otros"
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Element

#document, #version

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Exoneration

Returns a new instance of Exoneration.



27
28
29
30
31
32
33
34
# File 'lib/facturacr/document/exoneration.rb', line 27

def initialize(args={})
  @document_type = args[:document_type]
  @document_number = args[:document_number]
  @institution = args[:institution]
  @date = args[:date]
  @total_tax = args[:total_tax]
  @percentage = args[:percentage]
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



17
18
19
# File 'lib/facturacr/document/exoneration.rb', line 17

def date
  @date
end

#document_numberObject

Returns the value of attribute document_number.



17
18
19
# File 'lib/facturacr/document/exoneration.rb', line 17

def document_number
  @document_number
end

#document_typeObject

Returns the value of attribute document_type.



17
18
19
# File 'lib/facturacr/document/exoneration.rb', line 17

def document_type
  @document_type
end

#institutionObject

Returns the value of attribute institution.



17
18
19
# File 'lib/facturacr/document/exoneration.rb', line 17

def institution
  @institution
end

#net_totalObject

Returns the value of attribute net_total.



17
18
19
# File 'lib/facturacr/document/exoneration.rb', line 17

def net_total
  @net_total
end

#percentageObject

Returns the value of attribute percentage.



17
18
19
# File 'lib/facturacr/document/exoneration.rb', line 17

def percentage
  @percentage
end

#total_taxObject

Returns the value of attribute total_tax.



17
18
19
# File 'lib/facturacr/document/exoneration.rb', line 17

def total_tax
  @total_tax
end

Instance Method Details

#build_xml(node, document) ⇒ Object

Raises:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/facturacr/document/exoneration.rb', line 36

def build_xml(node, document)
  @document = document
  raise FE::Error.new("invalid exoneration",class: self.class, messages: errors.messages) unless valid?
  node = Nokogiri::XML::Builder.new if node.nil?

  node.Exoneracion do |xml|
    xml.TipoDocumento @document_type
    xml.NumeroDocumento @document_number
    xml.NombreInstitucion @institution
    xml.FechaEmision @date.xmlschema
    xml.PorcentajeExoneracion @percentage
    xml.MontoExoneracion @total_tax
  end
end