Class: BrNfe::Servico::Betha::V2::RecepcaoLoteRps

Inherits:
Gateway show all
Defined in:
lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb

Direct Known Subclasses

EnvioLoteRpsSincrono

Instance Attribute Summary

Attributes inherited from Gateway

#codigo_cancelamento, #numero_nfse

Attributes inherited from BrNfe::Servico::Base

#lote_rps, #numero_lote_rps, #operacao

Attributes inherited from Base

#certificate_pkcs12_password, #certificate_pkcs12_path, #certificate_pkcs12_value, #env

Instance Method Summary collapse

Methods inherited from Gateway

#builder, #cabecalho, #canonical_xml_builder, #content_xml, #namespace_identifier, #namespaces, #request, #set_response, #version, #wsdl

Methods inherited from Base

#version

Methods inherited from BrNfe::Servico::Base

#initialize

Methods inherited from Base

#certificate, #certificate=, #certificate_key, #certificate_key=, #certificate_pkcs12, #certificate_pkcs12=, #client_wsdl, #env_namespace, #namespace_identifier, #namespaces, #original_response, #response, #wsdl, #wsdl_encoding

Methods included from Helper::HaveEmitente

#emitente, #emitente=

Methods inherited from ActiveModelBase

#assign_attributes, #default_values, #initialize

Constructor Details

This class inherits a constructor from BrNfe::Servico::Base

Instance Method Details

#certificado_obrigatorio?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb', line 10

def certificado_obrigatorio?
  true
end

#lote_rps_xmlObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb', line 29

def lote_rps_xml
  xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.LoteRps("Id" => "lote#{numero_lote_rps}", versao: "2.02"){
      xml.NumeroLote BrNfe::Helper.only_number(numero_lote_rps).max_size(15)
      xml.CpfCnpj {
        tag_cpf_cnpj(xml, emitente.cnpj)
      }
      # O Ambiente de homologação da Betha não aceita Inscrição Municipal (baita ambiente de homologação)
      xml.InscricaoMunicipal emitente.inscricao_municipal.max_size(15) if !emitente.inscricao_municipal.blank? && env == :production

      xml.QuantidadeRps lote_rps.size
      xml.ListaRps {
        lote_rps.each do |obj_rps|
          xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( xml_rps_assinado(obj_rps).doc.root.to_s)
        end
      }
    }           
  end
end

#method_wsdlObject



14
15
16
# File 'lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb', line 14

def method_wsdl
  :recepcionar_lote_rps
end

#xml_builderObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb', line 18

def xml_builder
  xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.EnviarLoteRpsEnvio(xmlns: "http://www.betha.com.br/e-nota-contribuinte-ws") {
      xml_lote_rps = lote_rps_xml.doc.root

      xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( xml_lote_rps.to_s )
      xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( assinatura_xml(xml_lote_rps.to_s, "#lote#{numero_lote_rps}") )
    }
  end
end