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,558 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
describe BrNfe::Servico::Betha::V1::BuildResponse do
|
|
4
|
+
subject { FactoryGirl.build(:betha_v1_build_response) }
|
|
5
|
+
|
|
6
|
+
describe "#messages" do
|
|
7
|
+
it "deve retornar o resultado da key do hash conforme o atributo nfe_method com _resposta no fim" do
|
|
8
|
+
subject.nfe_method = :algo
|
|
9
|
+
subject.hash = {algo_resposta: {valor_a: 1}}
|
|
10
|
+
subject.messages.must_equal({valor_a: 1})
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#success?" do
|
|
15
|
+
it "deve ser true quanto não tem mensagem de retorno" do
|
|
16
|
+
subject.stubs(:messages).returns({lista_mensagem_retorno: nil})
|
|
17
|
+
subject.success?.must_equal true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "deve ser false quanto tem alguma mensagem de retorno" do
|
|
21
|
+
subject.stubs(:messages).returns({lista_mensagem_retorno: {codigo: 1} })
|
|
22
|
+
subject.success?.must_equal false
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "#error_messages" do
|
|
27
|
+
before do
|
|
28
|
+
subject.nfe_method = :key
|
|
29
|
+
subject.hash = {key_resposta: {
|
|
30
|
+
lista_mensagem_retorno: {mensagem_retorno: {
|
|
31
|
+
codigo: "999",
|
|
32
|
+
mensagem: "A mensagem",
|
|
33
|
+
correcao: "A correcao"
|
|
34
|
+
}}
|
|
35
|
+
}}
|
|
36
|
+
end
|
|
37
|
+
it "se ja tem valor na variavel @error_messages deve retornar o conteudo da variavel" do
|
|
38
|
+
subject.instance_variable_set(:@error_messages, [123])
|
|
39
|
+
subject.error_messages.must_equal([123])
|
|
40
|
+
end
|
|
41
|
+
it "se for success? então deve retornar um valor vazio" do
|
|
42
|
+
subject.stubs(:success?).returns(true)
|
|
43
|
+
subject.error_messages.must_equal([])
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "deve retornar um vetor com um hash com as mensagens quando houver apenas 1 mensagem em um hash" do
|
|
47
|
+
subject.error_messages.size.must_equal 1
|
|
48
|
+
subject.error_messages.class.must_equal Array
|
|
49
|
+
|
|
50
|
+
subject.error_messages[0][:codigo].must_equal '999'
|
|
51
|
+
subject.error_messages[0][:mensagem].must_equal 'A mensagem'
|
|
52
|
+
subject.error_messages[0][:correcao].must_equal 'A correcao'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "deve retornar todas as mensagens quando houver mais que uma" do
|
|
56
|
+
subject.hash = {key_resposta: {
|
|
57
|
+
lista_mensagem_retorno: {mensagem_retorno: [
|
|
58
|
+
{codigo: "111", mensagem: "A mensagem 1", correcao: "A correcao 1"},
|
|
59
|
+
{codigo: "222", mensagem: "A mensagem 2", correcao: "A correcao 2"},
|
|
60
|
+
]}
|
|
61
|
+
}}
|
|
62
|
+
|
|
63
|
+
subject.error_messages[0][:codigo].must_equal '111'
|
|
64
|
+
subject.error_messages[0][:mensagem].must_equal 'A mensagem 1'
|
|
65
|
+
subject.error_messages[0][:correcao].must_equal 'A correcao 1'
|
|
66
|
+
|
|
67
|
+
subject.error_messages[1][:codigo].must_equal '222'
|
|
68
|
+
subject.error_messages[1][:mensagem].must_equal 'A mensagem 2'
|
|
69
|
+
subject.error_messages[1][:correcao].must_equal 'A correcao 2'
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
describe "#response" do
|
|
75
|
+
context "deve instanciar um objeto Response Default" do
|
|
76
|
+
it "com o hash completo" do
|
|
77
|
+
subject.nfe_method = :key
|
|
78
|
+
subject.hash ={ key_resposta: hash_resposta_completa}
|
|
79
|
+
|
|
80
|
+
response = subject.response
|
|
81
|
+
response.success.must_equal false
|
|
82
|
+
response.error_messages.size.must_equal 2
|
|
83
|
+
response.error_messages[0][:codigo].must_equal '111'
|
|
84
|
+
response.error_messages[0][:mensagem].must_equal 'Msg 1'
|
|
85
|
+
response.error_messages[0][:correcao].must_equal 'corr 1'
|
|
86
|
+
response.error_messages[1][:codigo].must_equal '222'
|
|
87
|
+
response.error_messages[1][:mensagem].must_equal 'Msg 2'
|
|
88
|
+
response.error_messages[1][:correcao].must_equal 'corr 2'
|
|
89
|
+
|
|
90
|
+
response.numero_lote.must_equal "333332"
|
|
91
|
+
response.protocolo.must_equal "5566633548"
|
|
92
|
+
response.data_recebimento.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300")
|
|
93
|
+
|
|
94
|
+
response.notas_fiscais.size.must_equal 1
|
|
95
|
+
nota_fiscal = response.notas_fiscais.first
|
|
96
|
+
|
|
97
|
+
nota_fiscal.numero_nf.must_equal "1111"
|
|
98
|
+
nota_fiscal.codigo_verificacao.must_equal "ASDAD"
|
|
99
|
+
nota_fiscal.data_emissao.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300")
|
|
100
|
+
nota_fiscal.rps_numero.must_equal "11111"
|
|
101
|
+
nota_fiscal.rps_serie.must_equal "SN"
|
|
102
|
+
nota_fiscal.rps_tipo.must_equal "1"
|
|
103
|
+
nota_fiscal.rps_situacao.must_be_nil
|
|
104
|
+
nota_fiscal.data_emissao_rps.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300")
|
|
105
|
+
nota_fiscal.competencia.must_equal DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300")
|
|
106
|
+
nota_fiscal.outras_informacoes.must_equal "http://e-gov.betha.com.br/e-nota"
|
|
107
|
+
nota_fiscal.item_lista_servico.must_equal "111"
|
|
108
|
+
nota_fiscal.codigo_cnae.must_equal "6202300"
|
|
109
|
+
nota_fiscal.discriminacao.must_equal "discriminacao"
|
|
110
|
+
nota_fiscal.codigo_municipio.must_equal "4204202"
|
|
111
|
+
nota_fiscal.valor_servicos.must_equal "111"
|
|
112
|
+
nota_fiscal.valor_deducoes.must_equal "0"
|
|
113
|
+
nota_fiscal.valor_pis.must_equal "0.00"
|
|
114
|
+
nota_fiscal.valor_cofins.must_equal "0.00"
|
|
115
|
+
nota_fiscal.valor_inss.must_equal "0.00"
|
|
116
|
+
nota_fiscal.valor_ir.must_equal "0.00"
|
|
117
|
+
nota_fiscal.valor_csll.must_equal "0.00"
|
|
118
|
+
nota_fiscal.iss_retido.must_equal "2"
|
|
119
|
+
nota_fiscal.valor_iss.must_equal "0"
|
|
120
|
+
nota_fiscal.base_calculo.must_equal "111"
|
|
121
|
+
nota_fiscal.aliquota.must_equal "1.0000"
|
|
122
|
+
nota_fiscal.desconto_condicionado.must_equal "desconto_condicionado"
|
|
123
|
+
nota_fiscal.desconto_incondicionado.must_equal "desconto_incondicionado"
|
|
124
|
+
nota_fiscal.orgao_gerador_municipio.must_equal "0"
|
|
125
|
+
nota_fiscal.orgao_gerador_uf.must_equal "SC"
|
|
126
|
+
nota_fiscal.cancelamento_codigo.must_equal "123"
|
|
127
|
+
nota_fiscal.cancelamento_numero_nf.must_equal "123"
|
|
128
|
+
nota_fiscal.cancelamento_cnpj.must_equal "12345678901234"
|
|
129
|
+
nota_fiscal.cancelamento_inscricao_municipal.must_equal "INSCRICAO CANCELAMENTO"
|
|
130
|
+
nota_fiscal.cancelamento_municipio.must_equal "99999999"
|
|
131
|
+
nota_fiscal.cancelamento_sucesso.must_equal true
|
|
132
|
+
nota_fiscal.cancelamento_data_hora.must_equal DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
|
133
|
+
nota_fiscal.nfe_substituidora.must_equal "663322"
|
|
134
|
+
nota_fiscal.codigo_obra.must_equal "3333"
|
|
135
|
+
nota_fiscal.codigo_art.must_equal "4444"
|
|
136
|
+
|
|
137
|
+
#Intermediario
|
|
138
|
+
nota_fiscal.intermediario.razao_social.must_equal "RAZAO_SOCIAL INTERMEDIARIO"
|
|
139
|
+
nota_fiscal.intermediario.cpf_cnpj.must_equal "cpf intermediario"
|
|
140
|
+
nota_fiscal.intermediario.inscricao_municipal.must_equal "inscricao_municipal intermediario"
|
|
141
|
+
|
|
142
|
+
# Emitente / prestador
|
|
143
|
+
nota_fiscal.emitente.cnpj.must_equal "18113831000135"
|
|
144
|
+
nota_fiscal.emitente.inscricao_municipal.must_equal "inscricao_municipal prestador"
|
|
145
|
+
nota_fiscal.emitente.razao_social.must_equal "EMPRESA NACIONAL LTDA - ME"
|
|
146
|
+
nota_fiscal.emitente.nome_fantasia.must_equal "EMPRESA NACIONAL"
|
|
147
|
+
nota_fiscal.emitente.telefone.must_equal "123456"
|
|
148
|
+
nota_fiscal.emitente.email.must_equal "email@prestador"
|
|
149
|
+
nota_fiscal.emitente.regime_especial_tributacao.must_be_nil
|
|
150
|
+
nota_fiscal.emitente.optante_simples_nacional.must_equal "emitente optante_simples_nacional"
|
|
151
|
+
nota_fiscal.emitente.incentivo_fiscal.must_be_nil
|
|
152
|
+
nota_fiscal.emitente.natureza_operacao.must_equal "1"
|
|
153
|
+
|
|
154
|
+
# Destinatario / Tomador
|
|
155
|
+
nota_fiscal.destinatario.cpf_cnpj.must_equal "12345678901"
|
|
156
|
+
nota_fiscal.destinatario.inscricao_estadual.must_equal "tomador inscricao_estadual"
|
|
157
|
+
nota_fiscal.destinatario.inscricao_municipal.must_equal "tomador inscricao_municipal"
|
|
158
|
+
nota_fiscal.destinatario.razao_social.must_equal "TOMADOR SERVICO"
|
|
159
|
+
nota_fiscal.destinatario.telefone.must_equal "336644557"
|
|
160
|
+
nota_fiscal.destinatario.email.must_equal "mail@prestador.com"
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "com o hash parcial e mais de uma nota" do
|
|
164
|
+
subject.nfe_method = :key
|
|
165
|
+
subject.hash ={ key_resposta: hash_resposta_parcial}
|
|
166
|
+
|
|
167
|
+
response = subject.response
|
|
168
|
+
response.success.must_equal true
|
|
169
|
+
response.error_messages.size.must_equal 0
|
|
170
|
+
|
|
171
|
+
response.numero_lote.must_be_nil
|
|
172
|
+
response.protocolo.must_be_nil
|
|
173
|
+
response.data_recebimento.must_be_nil
|
|
174
|
+
|
|
175
|
+
response.notas_fiscais.size.must_equal 2
|
|
176
|
+
nota_fiscal_1 = response.notas_fiscais.first
|
|
177
|
+
nota_fiscal_2 = response.notas_fiscais.last
|
|
178
|
+
|
|
179
|
+
nota_fiscal_1.numero_nf.must_equal "1111"
|
|
180
|
+
nota_fiscal_1.codigo_verificacao.must_equal "ASDAD"
|
|
181
|
+
nota_fiscal_1.data_emissao.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300")
|
|
182
|
+
nota_fiscal_1.rps_numero.must_equal "11111"
|
|
183
|
+
nota_fiscal_1.rps_serie.must_equal "SN"
|
|
184
|
+
nota_fiscal_1.rps_tipo.must_equal "1"
|
|
185
|
+
nota_fiscal_1.rps_situacao.must_be_nil
|
|
186
|
+
nota_fiscal_1.data_emissao_rps.must_equal DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300")
|
|
187
|
+
nota_fiscal_1.competencia.must_equal DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300")
|
|
188
|
+
nota_fiscal_1.outras_informacoes.must_equal "http://e-gov.betha.com.br/e-nota"
|
|
189
|
+
nota_fiscal_1.item_lista_servico.must_equal "111"
|
|
190
|
+
nota_fiscal_1.codigo_cnae.must_equal "6202300"
|
|
191
|
+
nota_fiscal_1.discriminacao.must_equal "discriminacao"
|
|
192
|
+
nota_fiscal_1.codigo_municipio.must_equal "4204202"
|
|
193
|
+
nota_fiscal_1.valor_servicos.must_equal "111"
|
|
194
|
+
nota_fiscal_1.valor_deducoes.must_equal "0"
|
|
195
|
+
nota_fiscal_1.valor_pis.must_equal "0.00"
|
|
196
|
+
nota_fiscal_1.valor_cofins.must_equal "0.00"
|
|
197
|
+
nota_fiscal_1.valor_inss.must_equal "0.00"
|
|
198
|
+
nota_fiscal_1.valor_ir.must_equal "0.00"
|
|
199
|
+
nota_fiscal_1.valor_csll.must_equal "0.00"
|
|
200
|
+
nota_fiscal_1.iss_retido.must_equal "2"
|
|
201
|
+
nota_fiscal_1.valor_iss.must_equal "0"
|
|
202
|
+
nota_fiscal_1.base_calculo.must_equal "111"
|
|
203
|
+
nota_fiscal_1.aliquota.must_equal "1.0000"
|
|
204
|
+
nota_fiscal_1.desconto_condicionado.must_equal "desconto_condicionado"
|
|
205
|
+
nota_fiscal_1.desconto_incondicionado.must_equal "desconto_incondicionado"
|
|
206
|
+
nota_fiscal_1.orgao_gerador_municipio.must_equal "0"
|
|
207
|
+
nota_fiscal_1.orgao_gerador_uf.must_equal "SC"
|
|
208
|
+
nota_fiscal_1.cancelamento_codigo.must_equal "123"
|
|
209
|
+
nota_fiscal_1.cancelamento_numero_nf.must_equal "123"
|
|
210
|
+
nota_fiscal_1.cancelamento_cnpj.must_equal "12345678901234"
|
|
211
|
+
nota_fiscal_1.cancelamento_inscricao_municipal.must_equal "INSCRICAO CANCELAMENTO"
|
|
212
|
+
nota_fiscal_1.cancelamento_municipio.must_equal "99999999"
|
|
213
|
+
nota_fiscal_1.cancelamento_sucesso.must_equal true
|
|
214
|
+
nota_fiscal_1.cancelamento_data_hora.must_equal DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
|
215
|
+
nota_fiscal_1.nfe_substituidora.must_equal "663322"
|
|
216
|
+
nota_fiscal_1.codigo_obra.must_equal "3333"
|
|
217
|
+
nota_fiscal_1.codigo_art.must_equal "4444"
|
|
218
|
+
|
|
219
|
+
nota_fiscal_2.numero_nf.must_equal "NOTA2 numero_nf"
|
|
220
|
+
nota_fiscal_2.codigo_verificacao.must_equal "NOTA2 codigo_verificacao"
|
|
221
|
+
nota_fiscal_2.data_emissao.must_equal "NOTA2 data_emissao"
|
|
222
|
+
nota_fiscal_2.rps_numero.must_equal "NOTA2 rps_numero"
|
|
223
|
+
nota_fiscal_2.rps_serie.must_equal "NOTA2 rps_serie"
|
|
224
|
+
nota_fiscal_2.rps_tipo.must_equal "NOTA2 rps_tipo"
|
|
225
|
+
nota_fiscal_2.data_emissao_rps.must_equal "NOTA2 data_emissao_rps"
|
|
226
|
+
nota_fiscal_2.competencia.must_equal "NOTA2 competencia"
|
|
227
|
+
nota_fiscal_2.outras_informacoes.must_equal "NOTA2 outras_informacoes"
|
|
228
|
+
nota_fiscal_2.item_lista_servico.must_equal "NOTA2 item_lista_servico"
|
|
229
|
+
nota_fiscal_2.discriminacao.must_equal "NOTA2 discriminacao"
|
|
230
|
+
nota_fiscal_2.codigo_municipio.must_equal "NOTA2 codigo_municipio"
|
|
231
|
+
nota_fiscal_2.valor_servicos.must_equal "NOTA2 valor_servicos"
|
|
232
|
+
nota_fiscal_2.base_calculo.must_equal "NOTA2 base_calculo"
|
|
233
|
+
nota_fiscal_2.aliquota.must_equal "NOTA2 aliquota"
|
|
234
|
+
nota_fiscal_2.codigo_cnae.must_be_nil
|
|
235
|
+
nota_fiscal_2.valor_deducoes.must_be_nil
|
|
236
|
+
nota_fiscal_2.valor_pis.must_be_nil
|
|
237
|
+
nota_fiscal_2.valor_cofins.must_be_nil
|
|
238
|
+
nota_fiscal_2.valor_inss.must_be_nil
|
|
239
|
+
nota_fiscal_2.valor_ir.must_be_nil
|
|
240
|
+
nota_fiscal_2.valor_csll.must_be_nil
|
|
241
|
+
nota_fiscal_2.iss_retido.must_be_nil
|
|
242
|
+
nota_fiscal_2.valor_iss.must_be_nil
|
|
243
|
+
nota_fiscal_2.desconto_condicionado.must_be_nil
|
|
244
|
+
nota_fiscal_2.desconto_incondicionado.must_be_nil
|
|
245
|
+
nota_fiscal_2.orgao_gerador_municipio.must_be_nil
|
|
246
|
+
nota_fiscal_2.orgao_gerador_uf.must_be_nil
|
|
247
|
+
nota_fiscal_2.cancelamento_codigo.must_be_nil
|
|
248
|
+
nota_fiscal_2.cancelamento_numero_nf.must_be_nil
|
|
249
|
+
nota_fiscal_2.cancelamento_cnpj.must_be_nil
|
|
250
|
+
nota_fiscal_2.cancelamento_inscricao_municipal.must_be_nil
|
|
251
|
+
nota_fiscal_2.cancelamento_municipio.must_be_nil
|
|
252
|
+
nota_fiscal_2.cancelamento_sucesso.must_be_nil
|
|
253
|
+
nota_fiscal_2.cancelamento_data_hora.must_be_nil
|
|
254
|
+
nota_fiscal_2.nfe_substituidora.must_be_nil
|
|
255
|
+
nota_fiscal_2.codigo_obra.must_be_nil
|
|
256
|
+
nota_fiscal_2.codigo_art.must_be_nil
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def hash_resposta_completa
|
|
264
|
+
{
|
|
265
|
+
protocolo: "5566633548",
|
|
266
|
+
data_recebimento: DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300"),
|
|
267
|
+
numero_lote: '333332',
|
|
268
|
+
lista_nfse: {
|
|
269
|
+
compl_nfse: {
|
|
270
|
+
nfse: {
|
|
271
|
+
inf_nfse: {
|
|
272
|
+
numero: "1111",
|
|
273
|
+
codigo_verificacao: "ASDAD",
|
|
274
|
+
data_emissao: DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300"),
|
|
275
|
+
identificacao_rps: {
|
|
276
|
+
numero: "11111",
|
|
277
|
+
serie: "SN",
|
|
278
|
+
tipo: "1"
|
|
279
|
+
},
|
|
280
|
+
data_emissao_rps: DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300"),
|
|
281
|
+
natureza_operacao: "1",
|
|
282
|
+
optante_simples_nacional: "emitente optante_simples_nacional",
|
|
283
|
+
competencia: DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300"),
|
|
284
|
+
outras_informacoes: "http://e-gov.betha.com.br/e-nota",
|
|
285
|
+
servico: {
|
|
286
|
+
valores: {
|
|
287
|
+
valor_servicos: "111",
|
|
288
|
+
valor_deducoes: "0",
|
|
289
|
+
valor_pis: "0.00",
|
|
290
|
+
valor_cofins: "0.00",
|
|
291
|
+
valor_inss: "0.00",
|
|
292
|
+
valor_ir: "0.00",
|
|
293
|
+
valor_csll: "0.00",
|
|
294
|
+
iss_retido: "2",
|
|
295
|
+
valor_iss: "0",
|
|
296
|
+
base_calculo: "111",
|
|
297
|
+
aliquota: "1.0000",
|
|
298
|
+
desconto_condicionado: "desconto_condicionado",
|
|
299
|
+
desconto_incondicionado: "desconto_incondicionado"
|
|
300
|
+
},
|
|
301
|
+
item_lista_servico: "111",
|
|
302
|
+
codigo_cnae: "6202300",
|
|
303
|
+
discriminacao: "discriminacao",
|
|
304
|
+
codigo_municipio: "4204202"
|
|
305
|
+
},
|
|
306
|
+
intermediario_servico: {
|
|
307
|
+
razao_social: "razao_social intermediario",
|
|
308
|
+
cpf_cnpj: {cpf: 'cpf intermediario'},
|
|
309
|
+
inscricao_municipal: "inscricao_municipal intermediario"
|
|
310
|
+
|
|
311
|
+
},
|
|
312
|
+
prestador_servico: {
|
|
313
|
+
identificacao_prestador: {
|
|
314
|
+
cnpj: "18113831000135",
|
|
315
|
+
inscricao_municipal: "inscricao_municipal prestador",
|
|
316
|
+
},
|
|
317
|
+
razao_social: "EMPRESA NACIONAL LTDA - ME",
|
|
318
|
+
nome_fantasia: "EMPRESA NACIONAL",
|
|
319
|
+
endereco: {
|
|
320
|
+
endereco: "RUA PRESTADOR",
|
|
321
|
+
numero: "111",
|
|
322
|
+
complemento: "COMPLEMENTO PRESTADOR",
|
|
323
|
+
bairro: "BAIRRO PRESTADOR",
|
|
324
|
+
codigo_municipio: "4204202",
|
|
325
|
+
uf: "SC",
|
|
326
|
+
cep: "89805675"
|
|
327
|
+
},
|
|
328
|
+
contato: {
|
|
329
|
+
telefone: "123456",
|
|
330
|
+
email: "email@prestador",
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
tomador_servico: {
|
|
334
|
+
identificacao_tomador: {
|
|
335
|
+
cpf_cnpj: {
|
|
336
|
+
cpf: "12345678901",
|
|
337
|
+
},
|
|
338
|
+
inscricao_estadual: "tomador inscricao_estadual",
|
|
339
|
+
inscricao_municipal: "tomador inscricao_municipal"
|
|
340
|
+
},
|
|
341
|
+
razao_social: "TOMADOR SERVIcO",
|
|
342
|
+
endereco: {
|
|
343
|
+
endereco: "RUA TOMADOR",
|
|
344
|
+
numero: "99999",
|
|
345
|
+
complemento: "COMPLEMENTO TOMADOR",
|
|
346
|
+
bairro: "BAIRRO TOMADOR",
|
|
347
|
+
codigo_municipio: "4204202",
|
|
348
|
+
uf: "SC",
|
|
349
|
+
cep: "89805675"
|
|
350
|
+
},
|
|
351
|
+
contato: {
|
|
352
|
+
telefone: "336644557",
|
|
353
|
+
email: "mail@prestador.com"
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
orgao_gerador: {
|
|
357
|
+
codigo_municipio: "0",
|
|
358
|
+
uf: "SC"
|
|
359
|
+
},
|
|
360
|
+
construcao_civil: {
|
|
361
|
+
codigo_obra: '3333',
|
|
362
|
+
art: '4444'
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
nfse_cancelamento: {
|
|
367
|
+
confirmacao: {
|
|
368
|
+
pedido: {
|
|
369
|
+
inf_pedido_cancelamento: {
|
|
370
|
+
codigo_cancelamento: '123',
|
|
371
|
+
identificacao_nfse: {
|
|
372
|
+
numero: '123',
|
|
373
|
+
cnpj: '12345678901234',
|
|
374
|
+
inscricao_municipal: 'INSCRICAO CANCELAMENTO',
|
|
375
|
+
codigo_municipio: '99999999'
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
signature: nil
|
|
379
|
+
},
|
|
380
|
+
inf_confirmacao_cancelamento: {
|
|
381
|
+
sucesso: true,
|
|
382
|
+
data_hora: DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
nfse_substituicao: {
|
|
387
|
+
substituicao_nfse: {
|
|
388
|
+
nfse_substituidora: '663322'
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
lista_mensagem_retorno: {
|
|
394
|
+
mensagem_retorno: [
|
|
395
|
+
{codigo: '111', mensagem: 'Msg 1', correcao: 'corr 1'},
|
|
396
|
+
{codigo: '222', mensagem: 'Msg 2', correcao: 'corr 2'}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
def hash_resposta_parcial
|
|
403
|
+
{
|
|
404
|
+
lista_nfse: {
|
|
405
|
+
compl_nfse: [
|
|
406
|
+
{
|
|
407
|
+
nfse: {
|
|
408
|
+
inf_nfse: {
|
|
409
|
+
numero: "1111",
|
|
410
|
+
codigo_verificacao: "ASDAD",
|
|
411
|
+
data_emissao: DateTime.parse("Fri, 04 Sep 2015 09:56:22 -0300"),
|
|
412
|
+
identificacao_rps: {
|
|
413
|
+
numero: "11111",
|
|
414
|
+
serie: "SN",
|
|
415
|
+
tipo: "1"
|
|
416
|
+
},
|
|
417
|
+
data_emissao_rps: DateTime.parse("Fri, 04 Sep 2015 09:56:17 -0300"),
|
|
418
|
+
natureza_operacao: "1",
|
|
419
|
+
optante_simples_nacional: "1",
|
|
420
|
+
competencia: DateTime.parse("Tue, 01 Sep 2015 00:00:00 -0300"),
|
|
421
|
+
outras_informacoes: "http://e-gov.betha.com.br/e-nota",
|
|
422
|
+
servico: {
|
|
423
|
+
valores: {
|
|
424
|
+
valor_servicos: "111",
|
|
425
|
+
valor_deducoes: "0",
|
|
426
|
+
valor_pis: "0.00",
|
|
427
|
+
valor_cofins: "0.00",
|
|
428
|
+
valor_inss: "0.00",
|
|
429
|
+
valor_ir: "0.00",
|
|
430
|
+
valor_csll: "0.00",
|
|
431
|
+
iss_retido: "2",
|
|
432
|
+
valor_iss: "0",
|
|
433
|
+
base_calculo: "111",
|
|
434
|
+
aliquota: "1.0000",
|
|
435
|
+
desconto_condicionado: "desconto_condicionado",
|
|
436
|
+
desconto_incondicionado: "desconto_incondicionado"
|
|
437
|
+
},
|
|
438
|
+
item_lista_servico: "111",
|
|
439
|
+
codigo_cnae: "6202300",
|
|
440
|
+
discriminacao: "discriminacao",
|
|
441
|
+
codigo_municipio: "4204202"
|
|
442
|
+
},
|
|
443
|
+
prestador_servico: {
|
|
444
|
+
identificacao_prestador: {
|
|
445
|
+
cnpj: "18113831000135"
|
|
446
|
+
},
|
|
447
|
+
razao_social: "EMPRESA NACIONAL LTDA - ME",
|
|
448
|
+
nome_fantasia: "EMPRESA NACIONAL",
|
|
449
|
+
endereco: {
|
|
450
|
+
endereco: "RUA PRESTADOR",
|
|
451
|
+
numero: "111",
|
|
452
|
+
complemento: "COMPLEMENTO PRESTADOR",
|
|
453
|
+
bairro: "BAIRRO PRESTADOR",
|
|
454
|
+
codigo_municipio: "4204202",
|
|
455
|
+
uf: "SC",
|
|
456
|
+
cep: "89805675"
|
|
457
|
+
},
|
|
458
|
+
contato: {
|
|
459
|
+
email: "email@prestador",
|
|
460
|
+
telefone: "123456"
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
tomador_servico: {
|
|
464
|
+
identificacao_tomador: {
|
|
465
|
+
cpf_cnpj: {
|
|
466
|
+
cnpj: "12345678901234"
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
razao_social: "TOMADOR SERVIÇO",
|
|
470
|
+
endereco: {
|
|
471
|
+
endereco: "RUA TOMADOR",
|
|
472
|
+
numero: "99999",
|
|
473
|
+
complemento: "COMPLEMENTO TOMADOR",
|
|
474
|
+
bairro: "BAIRRO TOMADOR",
|
|
475
|
+
codigo_municipio: "4204202",
|
|
476
|
+
uf: "SC",
|
|
477
|
+
cep: "89805675"
|
|
478
|
+
},
|
|
479
|
+
contato: {
|
|
480
|
+
telefone: "336644557",
|
|
481
|
+
email: "mail@prestador.com"
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
orgao_gerador: {
|
|
485
|
+
codigo_municipio: "0",
|
|
486
|
+
uf: "SC"
|
|
487
|
+
},
|
|
488
|
+
construcao_civil: {
|
|
489
|
+
codigo_obra: '3333',
|
|
490
|
+
art: '4444'
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
nfse_cancelamento: {
|
|
495
|
+
confirmacao: {
|
|
496
|
+
pedido: {
|
|
497
|
+
inf_pedido_cancelamento: {
|
|
498
|
+
codigo_cancelamento: '123',
|
|
499
|
+
identificacao_nfse: {
|
|
500
|
+
numero: '123',
|
|
501
|
+
cnpj: '12345678901234',
|
|
502
|
+
inscricao_municipal: 'INSCRICAO CANCELAMENTO',
|
|
503
|
+
codigo_municipio: '99999999'
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
signature: nil
|
|
507
|
+
},
|
|
508
|
+
inf_confirmacao_cancelamento: {
|
|
509
|
+
sucesso: true,
|
|
510
|
+
data_hora: DateTime.parse("Fri, 05 Sep 2015 09:56:17 -0300")
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
},
|
|
514
|
+
nfse_substituicao: {
|
|
515
|
+
substituicao_nfse: {
|
|
516
|
+
nfse_substituidora: '663322'
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
nfse: {
|
|
522
|
+
inf_nfse: {
|
|
523
|
+
numero: "NOTA2 numero_nf",
|
|
524
|
+
codigo_verificacao: "NOTA2 codigo_verificacao",
|
|
525
|
+
data_emissao: "NOTA2 data_emissao",
|
|
526
|
+
identificacao_rps: {
|
|
527
|
+
numero: "NOTA2 rps_numero",
|
|
528
|
+
serie: "NOTA2 rps_serie",
|
|
529
|
+
tipo: "NOTA2 rps_tipo"
|
|
530
|
+
},
|
|
531
|
+
data_emissao_rps: "NOTA2 data_emissao_rps",
|
|
532
|
+
natureza_operacao: "NOTA2 natureza_operacao",
|
|
533
|
+
optante_simples_nacional: "NOTA2 optante_simples_nacional",
|
|
534
|
+
competencia: "NOTA2 competencia",
|
|
535
|
+
outras_informacoes: "NOTA2 outras_informacoes",
|
|
536
|
+
servico: {
|
|
537
|
+
valores: {
|
|
538
|
+
valor_servicos: "NOTA2 valor_servicos",
|
|
539
|
+
base_calculo: "NOTA2 base_calculo",
|
|
540
|
+
aliquota: "NOTA2 aliquota"
|
|
541
|
+
},
|
|
542
|
+
item_lista_servico: "NOTA2 item_lista_servico",
|
|
543
|
+
discriminacao: "NOTA2 discriminacao",
|
|
544
|
+
codigo_municipio: "NOTA2 codigo_municipio"
|
|
545
|
+
},
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
nfse_cancelamento: {
|
|
549
|
+
confirmacao: nil
|
|
550
|
+
},
|
|
551
|
+
nfse_substituicao: nil
|
|
552
|
+
}
|
|
553
|
+
]
|
|
554
|
+
},
|
|
555
|
+
lista_mensagem_retorno: nil
|
|
556
|
+
}
|
|
557
|
+
end
|
|
558
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
describe BrNfe::Servico::Betha::V1::CancelamentoNfs do
|
|
4
|
+
subject { FactoryGirl.build(:servico_betha_cancelamento_nfs, emitente: emitente) }
|
|
5
|
+
let(:emitente) { FactoryGirl.build(:emitente) }
|
|
6
|
+
|
|
7
|
+
describe "superclass" do
|
|
8
|
+
it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::Gateway }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "#wsdl" do
|
|
12
|
+
context "for env production" do
|
|
13
|
+
it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/cancelarNfseV02?wsdl' }
|
|
14
|
+
end
|
|
15
|
+
context "for env test" do
|
|
16
|
+
before do
|
|
17
|
+
subject.env = :test
|
|
18
|
+
end
|
|
19
|
+
it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/cancelarNfseV02?wsdl' }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "#method_wsdl" do
|
|
24
|
+
it { subject.method_wsdl.must_equal :cancelar_nfse }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
describe "#xml_inf_pedido_cancelamento" do
|
|
29
|
+
it "estrutura" do
|
|
30
|
+
xml = subject.send(:xml_inf_pedido_cancelamento).doc
|
|
31
|
+
|
|
32
|
+
xml.xpath('InfPedidoCancelamento/CodigoCancelamento').first.text.must_equal subject.codigo_cancelamento
|
|
33
|
+
|
|
34
|
+
xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/Numero').first.text.must_equal subject.numero_nfse
|
|
35
|
+
|
|
36
|
+
xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/Cnpj').first.text.must_equal emitente.cnpj
|
|
37
|
+
xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
|
|
38
|
+
xml.xpath('InfPedidoCancelamento/IdentificacaoNfse/CodigoMunicipio').first.text.must_equal emitente.endereco.codigo_municipio
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
describe "#xml_builder" do
|
|
44
|
+
let(:info_pedido) do
|
|
45
|
+
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
|
46
|
+
xml.InfPedidoCancelamento 'Valor'
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "deve adicionar o valor do xml_inf_pedido_cancelamento e assinar o xml" do
|
|
51
|
+
subject.stubs(:xml_inf_pedido_cancelamento).returns(info_pedido)
|
|
52
|
+
subject.expects(:assinatura_xml).with(info_pedido.doc.root.to_s).returns("<Signature>Val</Signature>")
|
|
53
|
+
xml = subject.xml_builder
|
|
54
|
+
xml = Nokogiri::XML xml
|
|
55
|
+
|
|
56
|
+
xml.xpath('Pedido/InfPedidoCancelamento').first.text.must_equal 'Valor'
|
|
57
|
+
xml.xpath('Pedido/Signature').first.text.must_equal 'Val'
|
|
58
|
+
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
describe BrNfe::Servico::Betha::V1::ConsultaLoteRps do
|
|
4
|
+
subject { FactoryGirl.build(:servico_betha_consulta_lote_rps, emitente: emitente) }
|
|
5
|
+
let(:emitente) { FactoryGirl.build(:emitente) }
|
|
6
|
+
|
|
7
|
+
describe "superclass" do
|
|
8
|
+
it { subject.class.superclass.must_equal BrNfe::Servico::Betha::V1::Gateway }
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "#wsdl" do
|
|
12
|
+
context "for env production" do
|
|
13
|
+
it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-ws/consultarLoteRps?wsdl' }
|
|
14
|
+
end
|
|
15
|
+
context "for env test" do
|
|
16
|
+
before do
|
|
17
|
+
subject.env = :test
|
|
18
|
+
end
|
|
19
|
+
it { subject.wsdl.must_equal 'http://e-gov.betha.com.br/e-nota-contribuinte-test-ws/consultarLoteRps?wsdl' }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe "#method_wsdl" do
|
|
24
|
+
it { subject.method_wsdl.must_equal :consultar_lote_rps }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
describe "#xml_builder" do
|
|
29
|
+
it "deve adicionar o valor do xml_inf_pedido_cancelamento e assinar o xml" do
|
|
30
|
+
subject.protocolo = '6654898765131'
|
|
31
|
+
|
|
32
|
+
xml = subject.xml_builder.to_s
|
|
33
|
+
xml = Nokogiri::XML xml
|
|
34
|
+
|
|
35
|
+
xml.xpath('Temp/Prestador/Cnpj').first.text.must_equal emitente.cnpj
|
|
36
|
+
xml.xpath('Temp/Prestador/InscricaoMunicipal').first.text.must_equal emitente.inscricao_municipal
|
|
37
|
+
xml.xpath('Temp/Protocolo').first.text.must_equal '6654898765131'
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|