Class: Nfse::Envio::Lote

Inherits:
Mustache
  • Object
show all
Defined in:
lib/nfse/lote.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Lote

Returns a new instance of Lote.



9
10
11
12
13
14
15
16
17
18
# File 'lib/nfse/lote.rb', line 9

def initialize(args)
    self.template_path = File.expand_path("../../templates/", __FILE__)
    args = defaults.merge(args)

    @lista_rps = []
    @id = args[:id]
    @numero_lote = args[:numero_lote]
    @cnpj = args[:cnpj]
    @inscricao_municipal = args[:inscricao_municipal]                
end

Instance Attribute Details

#cnpjObject

Returns the value of attribute cnpj.



7
8
9
# File 'lib/nfse/lote.rb', line 7

def cnpj
  @cnpj
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/nfse/lote.rb', line 7

def id
  @id
end

#inscricao_municipalObject

Returns the value of attribute inscricao_municipal.



7
8
9
# File 'lib/nfse/lote.rb', line 7

def inscricao_municipal
  @inscricao_municipal
end

#lista_rpsObject

Returns the value of attribute lista_rps.



7
8
9
# File 'lib/nfse/lote.rb', line 7

def lista_rps
  @lista_rps
end

#numero_loteObject

Returns the value of attribute numero_lote.



7
8
9
# File 'lib/nfse/lote.rb', line 7

def numero_lote
  @numero_lote
end

#quantidadeObject

Returns the value of attribute quantidade.



7
8
9
# File 'lib/nfse/lote.rb', line 7

def quantidade
  @quantidade
end

Instance Method Details

#add_rps(rps) ⇒ Object



28
29
30
# File 'lib/nfse/lote.rb', line 28

def add_rps(rps)
    @lista_rps << rps
end

#assinar_xml(xml_original, certificado) ⇒ Object



38
39
40
41
42
# File 'lib/nfse/lote.rb', line 38

def assinar_xml(xml_original, certificado)
    xml = sign_xml(xml_original, certificado)        
    xml = add_cert_to_xml(xml, certificado, "//ds:Signature/ds:KeyInfo/ds:X509Data/ds:X509Certificate")
    return xml            
end

#defaultsObject



24
25
26
# File 'lib/nfse/lote.rb', line 24

def defaults
    {id: 'assinar'}
end

#render_rpsObject



32
33
34
35
36
# File 'lib/nfse/lote.rb', line 32

def render_rps
    @lista_rps.reduce('') do |xml,obj|
        xml << assinar_xml(obj.render, 'cert.pem').gsub('<?xml version="1.0"?>', '')
    end
end