br_nfe 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +169 -0
- data/LICENSE +20 -0
- data/README.markdown +6 -0
- data/Rakefile +13 -0
- data/br_nfe.gemspec +28 -0
- data/lib/br_nfe/active_model_base.rb +62 -0
- data/lib/br_nfe/base.rb +168 -0
- data/lib/br_nfe/condicao_pagamento.rb +26 -0
- data/lib/br_nfe/destinatario.rb +26 -0
- data/lib/br_nfe/emitente.rb +40 -0
- data/lib/br_nfe/endereco.rb +44 -0
- data/lib/br_nfe/helper/cpf_cnpj.rb +60 -0
- data/lib/br_nfe/helper/have_address.rb +29 -0
- data/lib/br_nfe/helper/have_condicao_pagamento.rb +24 -0
- data/lib/br_nfe/helper/have_destinatario.rb +18 -0
- data/lib/br_nfe/helper/have_emitente.rb +20 -0
- data/lib/br_nfe/helper/have_intermediario.rb +24 -0
- data/lib/br_nfe/helper/have_rps.rb +27 -0
- data/lib/br_nfe/helper/string_methods.rb +21 -0
- data/lib/br_nfe/seed.rb +195 -0
- data/lib/br_nfe/servico/base.rb +35 -0
- data/lib/br_nfe/servico/betha/base.rb +74 -0
- data/lib/br_nfe/servico/betha/v1/build_response.rb +219 -0
- data/lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb +52 -0
- data/lib/br_nfe/servico/betha/v1/consulta_lote_rps.rb +31 -0
- data/lib/br_nfe/servico/betha/v1/consulta_nfs_por_rps.rb +34 -0
- data/lib/br_nfe/servico/betha/v1/consulta_nfse.rb +50 -0
- data/lib/br_nfe/servico/betha/v1/consulta_situacao_lote_rps.rb +18 -0
- data/lib/br_nfe/servico/betha/v1/gateway.rb +115 -0
- data/lib/br_nfe/servico/betha/v1/recepcao_lote_rps.rb +89 -0
- data/lib/br_nfe/servico/betha/v2/cancelamento_nfs.rb +25 -0
- data/lib/br_nfe/servico/betha/v2/consulta_lote_rps.rb +27 -0
- data/lib/br_nfe/servico/betha/v2/consulta_nfse_por_rps.rb +27 -0
- data/lib/br_nfe/servico/betha/v2/envio_lote_rps_sincrono.rb +26 -0
- data/lib/br_nfe/servico/betha/v2/gateway.rb +198 -0
- data/lib/br_nfe/servico/betha/v2/gera_nfse.rb +25 -0
- data/lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb +47 -0
- data/lib/br_nfe/servico/betha/v2/response.rb +23 -0
- data/lib/br_nfe/servico/betha/v2/substituicao_nfse.rb +39 -0
- data/lib/br_nfe/servico/intermediario.rb +17 -0
- data/lib/br_nfe/servico/response/default.rb +34 -0
- data/lib/br_nfe/servico/response/nota_fiscal.rb +73 -0
- data/lib/br_nfe/servico/rps.rb +103 -0
- data/lib/br_nfe/version.rb +8 -0
- data/lib/br_nfe.rb +146 -0
- data/test/br_nfe/base_test.rb +274 -0
- data/test/br_nfe/condicao_pagamento_test.rb +23 -0
- data/test/br_nfe/destinatario_test.rb +26 -0
- data/test/br_nfe/emitente_test.rb +26 -0
- data/test/br_nfe/endereco_test.rb +50 -0
- data/test/br_nfe/helper/have_address_test.rb +62 -0
- data/test/br_nfe/helper/have_condicao_pagamento_test.rb +71 -0
- data/test/br_nfe/helper/have_destinatario_test.rb +64 -0
- data/test/br_nfe/helper/have_emitente_test.rb +63 -0
- data/test/br_nfe/helper/have_intermediario_test.rb +77 -0
- data/test/br_nfe/helper/have_rps_test.rb +59 -0
- data/test/br_nfe/servico/base_test.rb +23 -0
- data/test/br_nfe/servico/betha/base_test.rb +106 -0
- data/test/br_nfe/servico/betha/v1/build_response_test.rb +558 -0
- data/test/br_nfe/servico/betha/v1/cancelamento_nfs_test.rb +62 -0
- data/test/br_nfe/servico/betha/v1/consulta_lote_rps_test.rb +42 -0
- data/test/br_nfe/servico/betha/v1/consulta_nfs_por_rps_test.rb +68 -0
- data/test/br_nfe/servico/betha/v1/consulta_nfse_test.rb +57 -0
- data/test/br_nfe/servico/betha/v1/consulta_situacao_lote_rps_test.rb +27 -0
- data/test/br_nfe/servico/betha/v1/gateway_test.rb +174 -0
- data/test/br_nfe/servico/betha/v1/recepcao_lote_rps_test.rb +235 -0
- data/test/br_nfe/servico/response/default_test.rb +54 -0
- data/test/br_nfe/servico/response/nota_fiscal_test.rb +41 -0
- data/test/br_nfe/servico/rps_test.rb +214 -0
- data/test/certificado.rb +12 -0
- data/test/factories/base.rb +5 -0
- data/test/factories/condicao_pagamento.rb +10 -0
- data/test/factories/destinatario.rb +11 -0
- data/test/factories/emitente.rb +15 -0
- data/test/factories/endereco.rb +12 -0
- data/test/factories/servico/base.rb +5 -0
- data/test/factories/servico/betha/base.rb +5 -0
- data/test/factories/servico/betha/v1/build_response.rb +6 -0
- data/test/factories/servico/betha/v1/cancelamento_nfs.rb +7 -0
- data/test/factories/servico/betha/v1/consulta_lote_rps.rb +6 -0
- data/test/factories/servico/betha/v1/consulta_nfs_por_rps.rb +6 -0
- data/test/factories/servico/betha/v1/consulta_nfse.rb +8 -0
- data/test/factories/servico/betha/v1/consulta_situacao_lote_rps.rb +6 -0
- data/test/factories/servico/betha/v1/gateway.rb +5 -0
- data/test/factories/servico/betha/v1/recepcao_lote_rps.rb +6 -0
- data/test/factories/servico/intermediario.rb +7 -0
- data/test/factories/servico/response/default.rb +10 -0
- data/test/factories/servico/response/nota_fiscal.rb +47 -0
- data/test/factories/servico/rps.rb +44 -0
- data/test/test_helper.rb +39 -0
- metadata +263 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V1
|
|
5
|
+
class CancelamentoNfs < BrNfe::Servico::Betha::V1::Gateway
|
|
6
|
+
def wsdl
|
|
7
|
+
"http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/cancelarNfseV02?wsdl"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def method_wsdl
|
|
11
|
+
:cancelar_nfse
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def certificado_obrigatorio?
|
|
15
|
+
true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
attr_accessor :numero_nfse
|
|
19
|
+
attr_accessor :codigo_cancelamento
|
|
20
|
+
|
|
21
|
+
validates :numero_nfse, :codigo_cancelamento, presence: true
|
|
22
|
+
|
|
23
|
+
def xml_builder
|
|
24
|
+
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
|
25
|
+
xml.Pedido {
|
|
26
|
+
inf_pedido_cancelamento = xml_inf_pedido_cancelamento.doc.root
|
|
27
|
+
xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( canonicalize(inf_pedido_cancelamento) )
|
|
28
|
+
xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( assinatura_xml(inf_pedido_cancelamento.to_s) )
|
|
29
|
+
}
|
|
30
|
+
end.doc
|
|
31
|
+
|
|
32
|
+
canonicalize(xml.root())
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def xml_inf_pedido_cancelamento
|
|
36
|
+
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
|
37
|
+
xml.InfPedidoCancelamento{
|
|
38
|
+
xml.IdentificacaoNfse{
|
|
39
|
+
xml.Numero BrNfe::Helper.only_number(numero_nfse).max_size(15)
|
|
40
|
+
tag_cpf_cnpj(xml, emitente.cnpj)
|
|
41
|
+
xml.InscricaoMunicipal "#{emitente.inscricao_municipal}".max_size(15) if !emitente.inscricao_municipal.blank? && env == :production
|
|
42
|
+
xml.CodigoMunicipio "#{emitente.endereco.codigo_municipio}".max_size(7)
|
|
43
|
+
}
|
|
44
|
+
xml.CodigoCancelamento "#{codigo_cancelamento}".max_size(4)
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V1
|
|
5
|
+
class ConsultaLoteRps < BrNfe::Servico::Betha::V1::Gateway
|
|
6
|
+
|
|
7
|
+
def wsdl
|
|
8
|
+
"http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/consultarLoteRps?wsdl"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
attr_accessor :protocolo
|
|
12
|
+
|
|
13
|
+
validates :protocolo, presence: true
|
|
14
|
+
|
|
15
|
+
def method_wsdl
|
|
16
|
+
:consultar_lote_rps
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def xml_builder
|
|
20
|
+
Nokogiri::XML::Builder.new do |xml|
|
|
21
|
+
xml.Temp {
|
|
22
|
+
tag_prestador(xml)
|
|
23
|
+
xml.Protocolo "#{protocolo}".max_size(50)
|
|
24
|
+
}
|
|
25
|
+
end.doc.root
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V1
|
|
5
|
+
class ConsultaNfsPorRps < BrNfe::Servico::Betha::V1::Gateway
|
|
6
|
+
include BrNfe::Helper::HaveRps
|
|
7
|
+
|
|
8
|
+
validate :validar_rps # metodo definido no module BrNfe::Helper::HaveRps
|
|
9
|
+
|
|
10
|
+
def wsdl
|
|
11
|
+
"http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/consultarNfsePorRps?wsdl"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def method_wsdl
|
|
15
|
+
:consultar_nfse_por_rps
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def xml_builder
|
|
19
|
+
Nokogiri::XML::Builder.new do |xml|
|
|
20
|
+
xml.Temp {
|
|
21
|
+
tag_identificacao_rps(xml, rps)
|
|
22
|
+
tag_prestador(xml)
|
|
23
|
+
}
|
|
24
|
+
end.doc.root
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def set_response(resp)
|
|
28
|
+
@response = BrNfe::Servico::Betha::V1::BuildResponse.new(hash: resp.hash[:envelope][:body][:consultar_nfse_por_rps_envio_response], nfe_method: :consultar_nfse_rps).response
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V1
|
|
5
|
+
class ConsultaNfse < BrNfe::Servico::Betha::V1::Gateway
|
|
6
|
+
|
|
7
|
+
def wsdl
|
|
8
|
+
"http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/consultarNfse?wsdl"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
attr_accessor :numero_nfse
|
|
12
|
+
attr_accessor :data_inicial
|
|
13
|
+
attr_accessor :data_final
|
|
14
|
+
|
|
15
|
+
validates :data_inicial, :data_final, presence: true
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def data_inicial
|
|
19
|
+
value_date(@data_inicial)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def data_final
|
|
23
|
+
value_date(@data_final)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def method_wsdl
|
|
28
|
+
:consultar_nfse
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def xml_builder
|
|
32
|
+
Nokogiri::XML::Builder.new do |xml|
|
|
33
|
+
xml.Temp {
|
|
34
|
+
|
|
35
|
+
tag_prestador(xml)
|
|
36
|
+
|
|
37
|
+
xml.NumeroNfse BrNfe::Helper.only_number(numero_nfse).max_size(15) if !numero_nfse.blank?
|
|
38
|
+
xml.PeriodoEmissao {
|
|
39
|
+
xml.DataInicial data_inicial
|
|
40
|
+
xml.DataFinal data_final
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
end.doc.root
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V1
|
|
5
|
+
class ConsultaSituacaoLoteRps < BrNfe::Servico::Betha::V1::ConsultaLoteRps
|
|
6
|
+
|
|
7
|
+
def wsdl
|
|
8
|
+
"http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/consultarSituacaoLoteRps?wsdl"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def method_wsdl
|
|
12
|
+
:consultar_situacao_lote_rps
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V1
|
|
5
|
+
class Gateway < BrNfe::Servico::Betha::Base
|
|
6
|
+
def namespaces
|
|
7
|
+
{"xmlns:ns1" => "http://www.betha.com.br/e-nota-contribuinte-ws"}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def namespace_identifier
|
|
11
|
+
:ns1
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def version
|
|
15
|
+
:v1
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def request
|
|
19
|
+
set_response(
|
|
20
|
+
client_wsdl.call("#{method_wsdl}_envio".to_sym,
|
|
21
|
+
message: "#{content_xml}",
|
|
22
|
+
attributes: {'xmlns:ns1' => 'http://www.betha.com.br/e-nota-contribuinte-ws'}
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
rescue Savon::SOAPFault => error
|
|
26
|
+
return @response = BrNfe::Servico::Response::Default.new(success: false, error_messages: [error.message])
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def set_response(resp)
|
|
30
|
+
method_response = (method_wsdl.to_s + "_envio_response").to_sym
|
|
31
|
+
@response = BrNfe::Servico::Betha::V1::BuildResponse.new(hash: resp.hash[:envelope][:body][method_response], nfe_method: method_wsdl).response
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def content_xml
|
|
35
|
+
canonicalize(xml_builder).gsub('<Temp>','').gsub('</Temp>','')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def tag_dados_servico(xml, rps)
|
|
41
|
+
xml.Servico {
|
|
42
|
+
xml.ItemListaServico BrNfe::Helper.only_number(rps.item_lista_servico).rjust(4,'0').max_size(4)
|
|
43
|
+
xml.CodigoCnae BrNfe::Helper.only_number(rps.codigo_cnae).max_size(7) unless rps.codigo_cnae.blank?
|
|
44
|
+
xml.CodigoTributacaoMunicipio rps.codigo_tributacao_municipio unless rps.codigo_tributacao_municipio.blank?
|
|
45
|
+
xml.Discriminacao "#{rps.discriminacao}".max_size(2_000).remove_accents
|
|
46
|
+
xml.CodigoMunicipio "#{rps.codigo_municipio}".max_size(7)
|
|
47
|
+
|
|
48
|
+
xml.Valores {
|
|
49
|
+
xml.ValorServicos value_monetary(rps.valor_servicos, 4) # Valores obrigatórios
|
|
50
|
+
xml.IssRetido value_true_false(rps.iss_retido?) # Valores obrigatórios
|
|
51
|
+
xml.BaseCalculo value_monetary(rps.base_calculo, 4) # Valores obrigatórios
|
|
52
|
+
xml.ValorDeducoes value_monetary(rps.valor_deducoes, 4) unless rps.valor_deducoes.blank?
|
|
53
|
+
xml.ValorPis value_monetary(rps.valor_pis, 4) unless rps.valor_pis.blank?
|
|
54
|
+
xml.ValorCofins value_monetary(rps.valor_cofins, 4) unless rps.valor_cofins.blank?
|
|
55
|
+
xml.ValorInss value_monetary(rps.valor_inss, 4) unless rps.valor_inss.blank?
|
|
56
|
+
xml.ValorIr value_monetary(rps.valor_ir, 4) unless rps.valor_ir.blank?
|
|
57
|
+
xml.ValorCsll value_monetary(rps.valor_csll, 4) unless rps.valor_csll.blank?
|
|
58
|
+
xml.ValorIss value_monetary(rps.valor_iss, 4) unless rps.valor_iss.blank?
|
|
59
|
+
xml.OutrasRetencoes value_monetary(rps.outras_retencoes, 4) unless rps.outras_retencoes.blank?
|
|
60
|
+
xml.Aliquota value_monetary(rps.aliquota, 4) unless rps.aliquota.blank?
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def tag_prestador(xml)
|
|
66
|
+
xml.Prestador {
|
|
67
|
+
tag_cpf_cnpj(xml, emitente.cnpj)
|
|
68
|
+
xml.InscricaoMunicipal "#{emitente.inscricao_municipal}".max_size(15) if !emitente.inscricao_municipal.blank? && env == :production
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def tag_intermediario_servico(xml, intermediario)
|
|
73
|
+
return unless intermediario
|
|
74
|
+
xml.IntermediarioServico{
|
|
75
|
+
xml.RazaoSocial "#{intermediario.razao_social}".max_size(115)
|
|
76
|
+
xml.CpfCnpj{
|
|
77
|
+
tag_cpf_cnpj(xml, intermediario.cpf_cnpj)
|
|
78
|
+
}
|
|
79
|
+
xml.InscricaoMunicipal "#{intermediario.inscricao_municipal}".max_size(15) unless intermediario.inscricao_municipal.blank?
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def tag_condicao_pagamento(xml, rps)
|
|
84
|
+
return unless rps.condicao_pagamento
|
|
85
|
+
xml.CondicaoPagamento{
|
|
86
|
+
xml.Condicao rps.condicao_pagamento.condicao
|
|
87
|
+
if rps.condicao_pagamento.parcelas.size > 0
|
|
88
|
+
xml.QtdParcela rps.condicao_pagamento.parcelas.size
|
|
89
|
+
rps.condicao_pagamento.parcelas.each_with_index do |parcela, i|
|
|
90
|
+
#
|
|
91
|
+
# Aqui há uma ressalva:
|
|
92
|
+
# Na documentação diz que a DataVencimento deve ser do tipo DateTime
|
|
93
|
+
# Porém não é nem do tipo DateTime e nem do tipo Date, mas sim uma String
|
|
94
|
+
# no formato DD/MM/YYYY <- by bethagambis.com
|
|
95
|
+
#
|
|
96
|
+
vencimento = get_date(parcela[:vencimento])
|
|
97
|
+
xml.Parcelas{
|
|
98
|
+
xml.Parcela i+1
|
|
99
|
+
xml.DataVencimento "#{vencimento.day.to_s.rjust(2, '0')}/#{vencimento.month.to_s.rjust(2, '0')}/#{vencimento.year}" if vencimento
|
|
100
|
+
xml.Valor value_monetary(parcela[:valor], 4)
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
}
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def get_date(value)
|
|
108
|
+
Date.parse(value.to_s)
|
|
109
|
+
rescue
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V1
|
|
5
|
+
class RecepcaoLoteRps < BrNfe::Servico::Betha::V1::Gateway
|
|
6
|
+
def wsdl
|
|
7
|
+
"http://e-gov.betha.com.br/e-nota-contribuinte-#{'test-' if env == :test}ws/recepcionarLoteRps?wsdl"
|
|
8
|
+
end
|
|
9
|
+
def method_wsdl
|
|
10
|
+
:enviar_lote_rps
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def certificado_obrigatorio?
|
|
14
|
+
true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
validates :numero_lote_rps, presence: true
|
|
18
|
+
validate :validar_lote_rps
|
|
19
|
+
|
|
20
|
+
def xml_builder
|
|
21
|
+
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
|
22
|
+
xml.Temp {
|
|
23
|
+
xml_lote_rps = lote_rps_xml.doc.root
|
|
24
|
+
xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( xml_lote_rps.to_s )
|
|
25
|
+
xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( assinatura_xml(xml_lote_rps.to_s, "#lote#{numero_lote_rps}") )
|
|
26
|
+
}
|
|
27
|
+
end.doc
|
|
28
|
+
|
|
29
|
+
canonicalize(xml.root())
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def lote_rps_xml
|
|
33
|
+
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
|
34
|
+
xml.LoteRps("Id" => "lote#{numero_lote_rps}"){
|
|
35
|
+
xml.NumeroLote BrNfe::Helper.only_number(numero_lote_rps).max_size(15)
|
|
36
|
+
tag_cpf_cnpj(xml, emitente.cnpj)
|
|
37
|
+
|
|
38
|
+
xml.InscricaoMunicipal "#{emitente.inscricao_municipal}".max_size(15) if env == :production
|
|
39
|
+
|
|
40
|
+
xml.QuantidadeRps lote_rps.size
|
|
41
|
+
xml.ListaRps {
|
|
42
|
+
xml.Rps do |xml_rps|
|
|
43
|
+
lote_rps.each do |rps|
|
|
44
|
+
xml_informacao_rps = xml_inf_rps(rps).doc.root
|
|
45
|
+
xml_rps.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( xml_informacao_rps.to_s )
|
|
46
|
+
xml_rps.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( assinatura_xml( xml_informacao_rps.to_s, "#rps#{rps.numero}" ) )
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def xml_inf_rps(rps)
|
|
55
|
+
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
|
56
|
+
xml.InfRps('Id' => "rps#{rps.numero}") {
|
|
57
|
+
|
|
58
|
+
tag_identificacao_rps(xml, rps)
|
|
59
|
+
|
|
60
|
+
xml.DataEmissao value_date_time(rps.data_emissao)
|
|
61
|
+
xml.NaturezaOperacao "#{emitente.natureza_operacao}".max_size(2)
|
|
62
|
+
xml.RegimeEspecialTributacao "#{emitente.regime_especial_tributacao}".max_size(2) unless emitente.regime_especial_tributacao.blank? # Código de identificação do regime especial de tributação: (1)Microempresa municipal, (2)Estimativa, (3)Sociedade de profissionais, (4)Cooperativa, (5)Microempresário Individual (MEI), (6)Microempresário e Empresa de Pequeno Porte (ME EPP) ,
|
|
63
|
+
xml.OptanteSimplesNacional value_true_false(emitente.optante_simples_nacional?) # (1)sim ----- (2)não -----
|
|
64
|
+
xml.IncentivadorCultural value_true_false(emitente.incentivo_fiscal?) # (1)sim ----- (2)não -----
|
|
65
|
+
xml.Status "#{rps.status}".max_size(1)
|
|
66
|
+
|
|
67
|
+
tag_rps_substituido(xml, rps)
|
|
68
|
+
|
|
69
|
+
tag_dados_servico(xml, rps)
|
|
70
|
+
|
|
71
|
+
tag_prestador(xml)
|
|
72
|
+
|
|
73
|
+
tag_dados_tomador(xml, rps.destinatario)
|
|
74
|
+
|
|
75
|
+
tag_intermediario_servico(xml, rps.intermediario)
|
|
76
|
+
|
|
77
|
+
tag_dados_construcao_civil(xml, rps)
|
|
78
|
+
|
|
79
|
+
xml.OutrasInformacoes "#{rps.outras_informacoes}".max_size(255) unless rps.outras_informacoes.blank?
|
|
80
|
+
|
|
81
|
+
tag_condicao_pagamento(xml, rps)
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V2
|
|
5
|
+
class CancelamentoNfs < BrNfe::Servico::Betha::V2::Gateway
|
|
6
|
+
def method_wsdl
|
|
7
|
+
:cancelar_nfse
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def xml_builder
|
|
11
|
+
xml = Nokogiri::XML::Builder.new do |xml|
|
|
12
|
+
xml.CancelarNfseEnvio(xmlns: "http://www.betha.com.br/e-nota-contribuinte-ws") {
|
|
13
|
+
xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( xml_pedido_cancelamento_assinado.doc.root.to_s )
|
|
14
|
+
}
|
|
15
|
+
end.doc.root
|
|
16
|
+
|
|
17
|
+
canonicalize xml
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V2
|
|
5
|
+
class ConsultaLoteRps < BrNfe::Servico::Betha::V2::Gateway
|
|
6
|
+
|
|
7
|
+
attr_accessor :protocolo
|
|
8
|
+
|
|
9
|
+
def method_wsdl
|
|
10
|
+
:consultar_lote_rps
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def xml_builder
|
|
14
|
+
xml = Nokogiri::XML::Builder.new do |xml|
|
|
15
|
+
xml.ConsultarLoteRpsEnvio(xmlns: "http://www.betha.com.br/e-nota-contribuinte-ws") {
|
|
16
|
+
tag_prestador(xml)
|
|
17
|
+
xml.Protocolo "#{protocolo}".max_size(50)
|
|
18
|
+
}
|
|
19
|
+
end.doc.root
|
|
20
|
+
|
|
21
|
+
canonicalize xml
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V2
|
|
5
|
+
class ConsultaNfsePorRps < BrNfe::Servico::Betha::V2::Gateway
|
|
6
|
+
include BrNfe::Helper::HaveRps
|
|
7
|
+
|
|
8
|
+
def method_wsdl
|
|
9
|
+
:consultar_nfse_por_rps
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def xml_builder
|
|
13
|
+
xml = Nokogiri::XML::Builder.new do |xml|
|
|
14
|
+
xml.ConsultarNfseRpsEnvio(xmlns: "http://www.betha.com.br/e-nota-contribuinte-ws") {
|
|
15
|
+
tag_identificacao_rps(xml, rps)
|
|
16
|
+
|
|
17
|
+
tag_prestador(xml)
|
|
18
|
+
}
|
|
19
|
+
end.doc.root
|
|
20
|
+
|
|
21
|
+
canonicalize xml
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module BrNfe
|
|
2
|
+
module Servico
|
|
3
|
+
module Betha
|
|
4
|
+
module V2
|
|
5
|
+
class EnvioLoteRpsSincrono < BrNfe::Servico::Betha::V2::RecepcaoLoteRps
|
|
6
|
+
def method_wsdl
|
|
7
|
+
:recepcionar_lote_rps_sincrono
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def xml_builder
|
|
11
|
+
xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
|
|
12
|
+
xml.EnviarLoteRpsSincronoEnvio(xmlns: "http://www.betha.com.br/e-nota-contribuinte-ws") {
|
|
13
|
+
xml_lote_rps = lote_rps_xml.doc.root
|
|
14
|
+
|
|
15
|
+
xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( xml_lote_rps.to_s )
|
|
16
|
+
xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse( assinatura_xml(xml_lote_rps.to_s, "#lote#{numero_lote_rps}") )
|
|
17
|
+
}
|
|
18
|
+
end.doc.root
|
|
19
|
+
|
|
20
|
+
canonicalize xml
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|