Class: Nfe::Models::Evento

Inherits:
Object
  • Object
show all
Extended by:
Enumerize
Includes:
ActiveModel::Model, Helpers::XmlModel::NfeModel
Defined in:
lib/nfe/models/evento.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::XmlModel::NfeModel

#add_elements, #check_present, included, #parse!, #parse_elements, #present?, #validate_optional_attributes, #validate_required_attributes

Instance Attribute Details

#detEventoObject

Returns the value of attribute detEvento.



16
17
18
# File 'lib/nfe/models/evento.rb', line 16

def detEvento
  @detEvento
end

#signatureObject

Returns the value of attribute signature.



16
17
18
# File 'lib/nfe/models/evento.rb', line 16

def signature
  @signature
end

#ufObject

Returns the value of attribute uf.



16
17
18
# File 'lib/nfe/models/evento.rb', line 16

def uf
  @uf
end

Instance Method Details

#idObject



40
41
42
# File 'lib/nfe/models/evento.rb', line 40

def id
  "ID#{tpEvento}#{chNFe}#{nSeqEvento_f}"
end

#to_xmlObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/nfe/models/evento.rb', line 44

def to_xml
  xml = Builder::XmlMarkup.new

  xml.evento({xmlns: Nfe::Models::NFe.namespace, versao: versao}) do |evento|

    evento.infEvento(Id: id) do |infEvento|
      infEvento.cOrgao Nfe::Helpers::UfHelper.code(uf)

      add_elements infEvento

      infEvento << detEvento.to_xml
    end

    evento.Signature(xmlns: Models::Signature.namespace) do |node|
      node << @signature.value
    end

  end
  xml.target!
end