Class: BrNfe::Servico::Betha::V1::CancelamentoNfs

Inherits:
Gateway show all
Defined in:
lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb

Instance Attribute Summary collapse

Attributes inherited from BrNfe::Servico::Base

#lote_rps, #numero_lote_rps, #operacao

Attributes inherited from Base

#certificado_password, #certificado_path, #certificado_value, #env

Instance Method Summary collapse

Methods inherited from Gateway

#content_xml, #namespace_identifier, #namespaces, #request, #set_response, #version

Methods inherited from Base

#version

Methods inherited from BrNfe::Servico::Base

#initialize

Methods inherited from Base

#certificado, #certificado=, #client_wsdl, #env_namespace, #namespace_identifier, #namespaces, #original_response, #response, #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 Attribute Details

#codigo_cancelamentoObject

Returns the value of attribute codigo_cancelamento.



19
20
21
# File 'lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb', line 19

def codigo_cancelamento
  @codigo_cancelamento
end

#numero_nfseObject

Returns the value of attribute numero_nfse.



18
19
20
# File 'lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb', line 18

def numero_nfse
  @numero_nfse
end

Instance Method Details

#certificado_obrigatorio?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb', line 14

def certificado_obrigatorio?
	true
end

#method_wsdlObject



10
11
12
# File 'lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb', line 10

def method_wsdl
	:cancelar_nfse
end

#wsdlObject



6
7
8
# File 'lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb', line 6

def wsdl
	"http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/cancelarNfseV02?wsdl"
end

#xml_builderObject



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb', line 23

def xml_builder
	xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
		xml.Pedido {
			inf_pedido_cancelamento = xml_inf_pedido_cancelamento.doc.root
			xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( canonicalize(inf_pedido_cancelamento) )
			xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( assinatura_xml(inf_pedido_cancelamento.to_s) )
		}
	end.doc
	
	canonicalize(xml.root())
end

#xml_inf_pedido_cancelamentoObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb', line 35

def xml_inf_pedido_cancelamento
	Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
		xml.InfPedidoCancelamento{
			xml.IdentificacaoNfse{
				xml.Numero BrNfe::Helper.only_number(numero_nfse).max_size(15)
				tag_cpf_cnpj(xml, emitente.cnpj)
				xml.InscricaoMunicipal "#{emitente.inscricao_municipal}".max_size(15) if !emitente.inscricao_municipal.blank? && env == :production
				xml.CodigoMunicipio    "#{emitente.endereco.codigo_municipio}".max_size(7) 
			}
			xml.CodigoCancelamento "#{codigo_cancelamento}".max_size(4)
		}
	end
end