class Nfe::Models::InfNFe

Attributes

signature[RW]

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

id() click to toggle source
# File lib/nfe/models/infNFe.rb, line 52
def id
  "NFe#{nfe_key.key}"
end
key() click to toggle source
# File lib/nfe/models/infNFe.rb, line 56
def key
  nfe_key.key
end
to_xml() click to toggle source
# 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

Private Instance Methods

nfe_key() click to toggle source
# File lib/nfe/models/infNFe.rb, line 76
def nfe_key
  Helpers::NfeKey.new(ide.uf, ide.dhEmi, emit.cnpj, ide.serie, ide.nNF,
    ide.cNF)
end