module Rnfse::XMLBuilder::SpeedGov10

Public Instance Methods

build_consultar_lote_rps_envio_xml(hash = {}) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 103
def build_consultar_lote_rps_envio_xml(hash = {})
  hash = prepare_hash(hash)
  hash = add_p_namespace(hash, /(Prestador|Protocolo)/)
  inner_xml = ::Gyoku.xml(hash, key_converter: :none)
  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.send('p:ConsultarLoteRpsEnvio'.to_sym, build_parameters_xmlns) do
      xml << inner_xml
    end
  end.doc
end
build_consultar_lote_rps_envio_xmlns() click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 114
def build_consultar_lote_rps_envio_xmlns()
  {
    'xmlns:p' => "http://ws.speedgov.com.br/consultar_lote_rps_envio_v1.xsd",
    'xsi:schemaLocation' => "http://ws.speedgov.com.br/consultar_lote_rps_envio_v1.xsd"
  }
end
build_consultar_nfse_envio_xml(hash = {}) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 41
def build_consultar_nfse_envio_xml(hash = {})
  hash = prepare_hash(hash)
  hash = add_p_namespace(hash, %r{
                                   (Prestador|
                                    NumeroNfse|
                                    DataInicial|
                                    DataFinal|
                                    PeriodoEmissao|
                                    Tomador|
                                    IntermediarioServico)
                                  }x)
  inner_xml = ::Gyoku.xml(hash, key_converter: :none)
  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.send('p:ConsultarNfseEnvio'.to_sym, build_parameters_xmlns) do
      xml << inner_xml
    end
  end.doc
end
build_consultar_nfse_envio_xmlns() click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 60
def build_consultar_nfse_envio_xmlns()
  {
    'xmlns:p' => "http://ws.speedgov.com.br/consultar_nfse_envio_v1.xsd",
    'xsi:schemaLocation' => "http://ws.speedgov.com.br/consultar_nfse_envio_v1.xsd"
  }
end
build_consultar_nfse_rps_envio_xml(hash = {}) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 67
def build_consultar_nfse_rps_envio_xml(hash = {})
  hash = prepare_hash(hash)
  hash = add_p_namespace(hash, /(Prestador|IdentificacaoRps)/)
  inner_xml = ::Gyoku.xml(hash, key_converter: :none)
  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.send('p:ConsultarNfseRpsEnvio'.to_sym, build_parameters_xmlns) do
      xml << inner_xml
    end
  end.doc
end
build_consultar_nfse_rps_envio_xmlns() click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 78
def build_consultar_nfse_rps_envio_xmlns()
  {
    'xmlns:p' => "http://ws.speedgov.com.br/consultar_nfse_rps_envio_v1.xsd",
    'xsi:schemaLocation' => "http://ws.speedgov.com.br/consultar_nfse_rps_envio_v1.xsd"
  }
end
build_consultar_situacao_lote_rps_envio_xml(hash = {}) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 16
def build_consultar_situacao_lote_rps_envio_xml(hash = {})
  hash = prepare_hash(hash)
  hash = add_p_namespace(hash, /(Prestador|Protocolo)/)
  inner_xml = ::Gyoku.xml(hash, key_converter: :none)
  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.send('p:ConsultarSituacaoLoteRpsEnvio'.to_sym, build_parameters_xmlns) do
      xml << inner_xml
    end
  end.doc
end
build_consultar_situacao_lote_rps_envio_xmlns() click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 27
def build_consultar_situacao_lote_rps_envio_xmlns()
  {
    'xmlns:p' => "http://ws.speedgov.com.br/consultar_situacao_lote_rps_envio_v1.xsd",
    'xsi:schemaLocation' => "http://ws.speedgov.com.br/consultar_situacao_lote_rps_envio_v1.xsd"
  }
end
build_header_xml() click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 129
def build_header_xml
  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.cabecalho('versao' => '1',
                  'xmlns:p' => 'http://ws.speedgov.com.br/cabecalho_v1.xsd',
                  'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#',
                  'xmlns:p1' => 'http://ws.speedgov.com.br/tipos_v1.xsd',
                  'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
                  'xsi:schemaLocation' => 'http://ws.speedgov.com.br/cabecalho_v1.xsd') do
      xml.versaoDados('1')
      xml.parent.namespace = xml.parent.namespace_definitions.first
    end
  end.doc
end
build_parameters_xmlns() click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 121
def build_parameters_xmlns
  {
    'xmlns:ds' => "http://www.w3.org/2000/09/xmldsig#",
    'xmlns:p1' => "http://ws.speedgov.com.br/tipos_v1.xsd",
    'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance"
  }.merge(self.send("#{Rnfse::CallChain.caller_method()}ns"))
end
build_recepcionar_lote_rps_xml(hash = {}) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 5
def build_recepcionar_lote_rps_xml(hash = {})
  hash = prepare_hash(hash)
  hash = add_p_namespace(hash, /LoteRps/)
  inner_xml = ::Gyoku.xml(hash, key_converter: :none)
  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
    xml.send('p:EnviarLoteRpsEnvio'.to_sym, build_parameters_xmlns) do
      xml << inner_xml
    end
  end.doc
end
build_recepcionar_lote_rps_xmlns() click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 34
def build_recepcionar_lote_rps_xmlns()
  {
    'xmlns:p' => "http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd",
    'xsi:schemaLocation' => "http://ws.speedgov.com.br/enviar_lote_rps_envio_v1.xsd"
  }
end

Private Instance Methods

add_p1_namespace(hash) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 189
def add_p1_namespace(hash)
  Rnfse::Hash.transform_keys(hash) { |key| "p1:#{key}".to_sym }
end
add_p_namespace(hash, regex) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 183
def add_p_namespace(hash, regex)
  Rnfse::Hash.transform_keys(hash, regex) do |key|
    "p:#{key.to_s.gsub(/^[^:]+:/, '')}"
  end
end
alter_aliquota(hash) click to toggle source

alterar o formato da aliquota de 0 a 1 para 0 a 100

# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 177
def alter_aliquota(hash)
  Rnfse::Hash.transform_values(hash, 'Aliquota') do |val|
    "%.1f" % (val * 100)
  end
end
prepare_hash(hash) click to toggle source
# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 145
def prepare_hash(hash)
  hash = camelize_hash(hash)
  hash = wrap_rps(hash)
  hash = clean_numerics(hash)
  hash = alter_aliquota(hash)
  hash = wrap_cpf_cnpj(hash)
  hash = wrap_data_inicial_data_final(hash)
  hash = fix_booleans(hash)
  hash = add_p1_namespace(hash)
  hash
end
wrap_cpf_cnpj(hash) click to toggle source

encapsula as tags cpf ou cnpj em uma tag cpfcnpj

# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 158
def wrap_cpf_cnpj(hash)
  match = '(IdentificacaoTomador|IntermediarioServico|Tomador)/(Cnpj|Cpf)'
  Rnfse::Hash.replace_key_values(hash, match) do |key, value|
    { :'CpfCnpj' => { key => value } }
  end
end
wrap_data_inicial_data_final(hash) click to toggle source

encapsula as tags data inicial e data final em periodo emissao

# File lib/rnfse/xml_builder/speed_gov_1_0.rb, line 166
def wrap_data_inicial_data_final(hash)
  if hash[:'DataFinal'] and hash[:'DataInicial']
    hash[:'PeriodoEmissao'] = {
      :'DataInicial' => hash.delete(:'DataInicial'),
      :'DataFinal' => hash.delete(:'DataFinal')
    }
  end
  hash
end