Class: Nfe::Models::InfNFe

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, Helpers::XmlModel::NfeModel
Defined in:
lib/nfe/models/infNFe.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

Constructor Details

#initializeInfNFe

Returns a new instance of InfNFe.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/nfe/models/infNFe.rb', line 35

def initialize
  @ide = Ide.new
  @emit = Emitter::Emit.new
  @avulsa = Avulsa.new
  @dest = Recipient::Dest.new
  @retirada = EntregaRetirada.new
  @entrega = EntregaRetirada.new
  @det = []
  @total = Total.new
  @transp = Transport::Transp.new
  @cobr = Bill::Cobr.new
  @infAdic = Information::InfAdic.new
  @exporta = Exporta.new
  @compra = Compra.new
  @cana = Cane::Cana.new
end

Instance Attribute Details

#signatureObject

Returns the value of attribute signature.



23
24
25
# File 'lib/nfe/models/infNFe.rb', line 23

def signature
  @signature
end

Instance Method Details

#idObject



52
53
54
# File 'lib/nfe/models/infNFe.rb', line 52

def id
  "NFe#{nfe_key.key}"
end

#keyObject



56
57
58
# File 'lib/nfe/models/infNFe.rb', line 56

def key
  nfe_key.key
end

#to_xmlObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/nfe/models/infNFe.rb', line 60

def to_xml
  xml = Builder::XmlMarkup.new

  add_elements xml, :ide, :emit, :avulsa, :dest, :retirada, :entrega

  @det.each do |det|
    xml.det(nItem: det.nItem) { |node| node << det.to_xml }
  end

  add_elements xml, :total, :transp, :cobr, :infAdic, :exporta, :compra,
    :cana

  xml.target!
end