br_nfe 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -1
- data/README.markdown +263 -1
- data/br_nfe.gemspec +14 -5
- data/lib/br_nfe/base.rb +6 -1
- data/lib/br_nfe/helper/cpf_cnpj.rb +0 -5
- data/lib/br_nfe/helper/have_address.rb +1 -5
- data/lib/br_nfe/helper/have_rps.rb +7 -0
- data/lib/br_nfe/servico/betha/base.rb +52 -41
- data/lib/br_nfe/servico/betha/build_response.rb +141 -0
- data/lib/br_nfe/servico/betha/v1/build_response.rb +4 -102
- data/lib/br_nfe/servico/betha/v1/consulta_lote_rps.rb +3 -1
- data/lib/br_nfe/servico/betha/v1/consulta_nfs_por_rps.rb +5 -2
- data/lib/br_nfe/servico/betha/v1/consulta_nfse.rb +2 -1
- data/lib/br_nfe/servico/betha/v1/gateway.rb +66 -56
- data/lib/br_nfe/servico/betha/v1/recepcao_lote_rps.rb +16 -8
- data/lib/br_nfe/servico/betha/v2/build_response.rb +159 -0
- data/lib/br_nfe/servico/betha/v2/cancelamento_nfs.rb +8 -3
- data/lib/br_nfe/servico/betha/v2/consulta_lote_rps.rb +7 -4
- data/lib/br_nfe/servico/betha/v2/consulta_nfse_por_rps.rb +5 -5
- data/lib/br_nfe/servico/betha/v2/envio_lote_rps_sincrono.rb +7 -3
- data/lib/br_nfe/servico/betha/v2/gateway.rb +79 -56
- data/lib/br_nfe/servico/betha/v2/gera_nfse.rb +8 -3
- data/lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb +9 -4
- data/lib/br_nfe/servico/betha/v2/substituicao_nfse.rb +8 -4
- data/lib/br_nfe/servico/response/nota_fiscal.rb +13 -4
- data/lib/br_nfe/servico/rps.rb +2 -2
- data/lib/br_nfe/version.rb +1 -1
- data/lib/br_nfe.rb +2 -1
- data/test/br_nfe/base_test.rb +55 -1
- data/test/br_nfe/destinatario_test.rb +19 -0
- data/test/br_nfe/emitente_test.rb +20 -0
- data/test/br_nfe/endereco_test.rb +9 -0
- data/test/br_nfe/helper/cpf_cnpj_test.rb +61 -0
- data/test/br_nfe/servico/base_test.rb +28 -0
- data/test/br_nfe/servico/betha/base_test.rb +61 -32
- data/test/br_nfe/servico/betha/v1/build_response_test.rb +6 -7
- data/test/br_nfe/servico/betha/v1/cancelamento_nfs_test.rb +6 -0
- data/test/br_nfe/servico/betha/v1/consulta_lote_rps_test.rb +4 -0
- data/test/br_nfe/servico/betha/v1/consulta_nfse_test.rb +17 -0
- data/test/br_nfe/servico/betha/v1/gateway_test.rb +17 -40
- data/test/br_nfe/servico/betha/v1/recepcao_lote_rps_test.rb +12 -2
- data/test/br_nfe/servico/betha/v2/cancelamento_nfs_test.rb +40 -0
- data/test/br_nfe/servico/betha/v2/consulta_lote_rps_test.rb +38 -0
- data/test/br_nfe/servico/betha/v2/consulta_nfse_por_rps_test.rb +36 -0
- data/test/br_nfe/servico/betha/v2/envio_lote_rps_sincrono_test.rb +46 -0
- data/test/br_nfe/servico/betha/v2/gateway_test.rb +372 -0
- data/test/br_nfe/servico/betha/v2/gera_nfse_test.rb +58 -0
- data/test/br_nfe/servico/betha/v2/recepcao_lote_rps_test.rb +103 -0
- data/test/br_nfe/servico/betha/v2/substituicao_nfse_test.rb +80 -0
- data/test/br_nfe/servico/intermediario_test.rb +16 -0
- data/test/br_nfe/servico/rps_test.rb +141 -0
- data/test/factories/servico/betha/v1/gateway.rb +1 -1
- data/test/factories/servico/betha/v2/cancelamento_nfs.rb +7 -0
- data/test/factories/servico/betha/v2/consulta_lote_rps.rb +6 -0
- data/test/factories/servico/betha/v2/consulta_nfse_por_rps.rb +6 -0
- data/test/factories/servico/betha/v2/envio_lote_rps_sincrono.rb +5 -0
- data/test/factories/servico/betha/v2/gateway.rb +5 -0
- data/test/factories/servico/betha/v2/gera_nfse.rb +6 -0
- data/test/factories/servico/betha/v2/recepcao_lote_rps.rb +5 -0
- data/test/factories/servico/betha/v2/substituicao_nfse.rb +8 -0
- metadata +50 -17
- data/Gemfile +0 -15
- data/Rakefile +0 -13
- data/lib/br_nfe/seed.rb +0 -195
- data/lib/br_nfe/servico/betha/v2/response.rb +0 -23
- data/test/certificado.rb +0 -12
- data/test/test_helper.rb +0 -39
@@ -6,6 +6,109 @@ describe BrNfe::Servico::Rps do
|
|
6
6
|
let(:intermediario) { FactoryGirl.build(:intermediario) }
|
7
7
|
let(:condicao_pagamento) { FactoryGirl.build(:condicao_pagamento) }
|
8
8
|
|
9
|
+
describe "validations" do
|
10
|
+
it { must validate_presence_of(:numero) }
|
11
|
+
it { must validate_presence_of(:serie) }
|
12
|
+
it { must validate_presence_of(:tipo) }
|
13
|
+
|
14
|
+
describe "option validar_recepcao_rps" do
|
15
|
+
context "quando for true" do
|
16
|
+
before { subject.validar_recepcao_rps = true }
|
17
|
+
it { must validate_presence_of(:data_emissao) }
|
18
|
+
it { must validate_presence_of(:item_lista_servico) }
|
19
|
+
it { must validate_presence_of(:discriminacao) }
|
20
|
+
it { must validate_presence_of(:codigo_municipio) }
|
21
|
+
it { must validate_presence_of(:valor_servicos) }
|
22
|
+
it { must validate_presence_of(:base_calculo) }
|
23
|
+
|
24
|
+
it { must validate_numericality_of(:valor_servicos) }
|
25
|
+
it { must validate_numericality_of(:valor_deducoes) }
|
26
|
+
it { must validate_numericality_of(:valor_pis) }
|
27
|
+
it { must validate_numericality_of(:valor_cofins) }
|
28
|
+
it { must validate_numericality_of(:valor_inss) }
|
29
|
+
it { must validate_numericality_of(:valor_ir) }
|
30
|
+
it { must validate_numericality_of(:valor_csll) }
|
31
|
+
it { must validate_numericality_of(:outras_retencoes) }
|
32
|
+
it { must validate_numericality_of(:valor_iss) }
|
33
|
+
it { must validate_numericality_of(:aliquota) }
|
34
|
+
it { must validate_numericality_of(:base_calculo) }
|
35
|
+
it { must validate_numericality_of(:desconto_incondicionado) }
|
36
|
+
it { must validate_numericality_of(:desconto_condicionado) }
|
37
|
+
|
38
|
+
it "deve validar o intermediario" do
|
39
|
+
subject.expects(:validar_intermediario)
|
40
|
+
subject.valid?
|
41
|
+
end
|
42
|
+
|
43
|
+
it "deve validar o intermediario" do
|
44
|
+
subject.expects(:validar_destinatario)
|
45
|
+
subject.valid?
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "option iss_retido?" do
|
49
|
+
context "quando for true" do
|
50
|
+
before { subject.stubs(:iss_retido?).returns(true) }
|
51
|
+
it { wont validate_presence_of(:valor_iss) }
|
52
|
+
it { wont validate_presence_of(:aliquota) }
|
53
|
+
end
|
54
|
+
context "quando for false" do
|
55
|
+
before { subject.stubs(:iss_retido?).returns(false) }
|
56
|
+
it { must validate_presence_of(:valor_iss) }
|
57
|
+
it { must validate_presence_of(:aliquota) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "quando for false" do
|
63
|
+
before { subject.validar_recepcao_rps = false }
|
64
|
+
it { wont validate_presence_of(:data_emissao) }
|
65
|
+
it { wont validate_presence_of(:item_lista_servico) }
|
66
|
+
it { wont validate_presence_of(:discriminacao) }
|
67
|
+
it { wont validate_presence_of(:codigo_municipio) }
|
68
|
+
it { wont validate_presence_of(:valor_servicos) }
|
69
|
+
it { wont validate_presence_of(:base_calculo) }
|
70
|
+
|
71
|
+
it { wont validate_numericality_of(:valor_servicos) }
|
72
|
+
it { wont validate_numericality_of(:valor_deducoes) }
|
73
|
+
it { wont validate_numericality_of(:valor_pis) }
|
74
|
+
it { wont validate_numericality_of(:valor_cofins) }
|
75
|
+
it { wont validate_numericality_of(:valor_inss) }
|
76
|
+
it { wont validate_numericality_of(:valor_ir) }
|
77
|
+
it { wont validate_numericality_of(:valor_csll) }
|
78
|
+
it { wont validate_numericality_of(:outras_retencoes) }
|
79
|
+
it { wont validate_numericality_of(:valor_iss) }
|
80
|
+
it { wont validate_numericality_of(:aliquota) }
|
81
|
+
it { wont validate_numericality_of(:base_calculo) }
|
82
|
+
it { wont validate_numericality_of(:desconto_incondicionado) }
|
83
|
+
it { wont validate_numericality_of(:desconto_condicionado) }
|
84
|
+
|
85
|
+
it "deve validar o intermediario" do
|
86
|
+
subject.expects(:validar_intermediario).never
|
87
|
+
subject.valid?
|
88
|
+
end
|
89
|
+
|
90
|
+
it "deve validar o intermediario" do
|
91
|
+
subject.expects(:validar_destinatario).never
|
92
|
+
subject.valid?
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "option iss_retido?" do
|
96
|
+
context "quando for true" do
|
97
|
+
before { subject.stubs(:iss_retido?).returns(true) }
|
98
|
+
it { wont validate_presence_of(:valor_iss) }
|
99
|
+
it { wont validate_presence_of(:aliquota) }
|
100
|
+
end
|
101
|
+
context "quando for false" do
|
102
|
+
before { subject.stubs(:iss_retido?).returns(false) }
|
103
|
+
it { wont validate_presence_of(:valor_iss) }
|
104
|
+
it { wont validate_presence_of(:aliquota) }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
9
112
|
describe "#contem_substituicao?" do
|
10
113
|
before do
|
11
114
|
subject.assign_attributes(numero_substituicao: '1', serie_substituicao: '2', tipo_substituicao: '1')
|
@@ -211,4 +314,42 @@ describe BrNfe::Servico::Rps do
|
|
211
314
|
end
|
212
315
|
end
|
213
316
|
|
317
|
+
describe "#validar_intermediario" do
|
318
|
+
it "se não tiver intermediario deve retornar true" do
|
319
|
+
subject.intermediario = nil
|
320
|
+
subject.send(:validar_intermediario).must_equal true
|
321
|
+
end
|
322
|
+
it "se tiver intermediario e o mesmo for válido, não adiciona as mensagens de erro" do
|
323
|
+
intermediario.stubs(:errors).returns(stub(full_messages: ['msg 1']) )
|
324
|
+
intermediario.expects(:invalid?).returns(false)
|
325
|
+
subject.intermediario = intermediario
|
326
|
+
subject.send(:validar_intermediario).must_be_nil
|
327
|
+
subject.errors.full_messages.must_equal([])
|
328
|
+
end
|
329
|
+
it "se tiver intermediario e o mesmo for inválido, deve adicionar as mensagens de erro" do
|
330
|
+
intermediario.stubs(:errors).returns(stub(full_messages: ['msg 1']) )
|
331
|
+
intermediario.expects(:invalid?).returns(true)
|
332
|
+
subject.intermediario = intermediario
|
333
|
+
subject.send(:validar_intermediario)
|
334
|
+
subject.errors.full_messages.must_equal(['Intermediário: msg 1'])
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
describe "#validar_destinatario" do
|
339
|
+
it "se destinatario for válido, não adiciona as mensagens de erro" do
|
340
|
+
destinatario.stubs(:errors).returns(stub(full_messages: ['msg 1']) )
|
341
|
+
destinatario.expects(:invalid?).returns(false)
|
342
|
+
subject.destinatario = destinatario
|
343
|
+
subject.send(:validar_destinatario).must_be_nil
|
344
|
+
subject.errors.full_messages.must_equal([])
|
345
|
+
end
|
346
|
+
it "se destinatario for inválido, deve adicionar as mensagens de erro" do
|
347
|
+
destinatario.stubs(:errors).returns(stub(full_messages: ['msg 1']) )
|
348
|
+
destinatario.expects(:invalid?).returns(true)
|
349
|
+
subject.destinatario = destinatario
|
350
|
+
subject.send(:validar_destinatario)
|
351
|
+
subject.errors.full_messages.must_equal(['Destinatário: msg 1'])
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
214
355
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :br_nfe_servico_betha_v2_substituicao_nfse, class: BrNfe::Servico::Betha::V2::SubstituicaoNfse do
|
3
|
+
emitente { FactoryGirl.build(:emitente) }
|
4
|
+
rps { FactoryGirl.build(:br_nfe_rps) }
|
5
|
+
numero_nfse '5526'
|
6
|
+
codigo_cancelamento '1'
|
7
|
+
end
|
8
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_nfe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno M. Mergen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '10'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: signer
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.4'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.4'
|
97
97
|
description: Emissão de Notas Fiscais Eletrônicas em Ruby
|
98
98
|
email:
|
99
99
|
- brunomergen@gmail.com
|
@@ -101,11 +101,9 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- Gemfile
|
105
104
|
- Gemfile.lock
|
106
105
|
- LICENSE
|
107
106
|
- README.markdown
|
108
|
-
- Rakefile
|
109
107
|
- br_nfe.gemspec
|
110
108
|
- lib/br_nfe.rb
|
111
109
|
- lib/br_nfe/active_model_base.rb
|
@@ -122,9 +120,9 @@ files:
|
|
122
120
|
- lib/br_nfe/helper/have_intermediario.rb
|
123
121
|
- lib/br_nfe/helper/have_rps.rb
|
124
122
|
- lib/br_nfe/helper/string_methods.rb
|
125
|
-
- lib/br_nfe/seed.rb
|
126
123
|
- lib/br_nfe/servico/base.rb
|
127
124
|
- lib/br_nfe/servico/betha/base.rb
|
125
|
+
- lib/br_nfe/servico/betha/build_response.rb
|
128
126
|
- lib/br_nfe/servico/betha/v1/build_response.rb
|
129
127
|
- lib/br_nfe/servico/betha/v1/cancelamento_nfs.rb
|
130
128
|
- lib/br_nfe/servico/betha/v1/consulta_lote_rps.rb
|
@@ -133,6 +131,7 @@ files:
|
|
133
131
|
- lib/br_nfe/servico/betha/v1/consulta_situacao_lote_rps.rb
|
134
132
|
- lib/br_nfe/servico/betha/v1/gateway.rb
|
135
133
|
- lib/br_nfe/servico/betha/v1/recepcao_lote_rps.rb
|
134
|
+
- lib/br_nfe/servico/betha/v2/build_response.rb
|
136
135
|
- lib/br_nfe/servico/betha/v2/cancelamento_nfs.rb
|
137
136
|
- lib/br_nfe/servico/betha/v2/consulta_lote_rps.rb
|
138
137
|
- lib/br_nfe/servico/betha/v2/consulta_nfse_por_rps.rb
|
@@ -140,7 +139,6 @@ files:
|
|
140
139
|
- lib/br_nfe/servico/betha/v2/gateway.rb
|
141
140
|
- lib/br_nfe/servico/betha/v2/gera_nfse.rb
|
142
141
|
- lib/br_nfe/servico/betha/v2/recepcao_lote_rps.rb
|
143
|
-
- lib/br_nfe/servico/betha/v2/response.rb
|
144
142
|
- lib/br_nfe/servico/betha/v2/substituicao_nfse.rb
|
145
143
|
- lib/br_nfe/servico/intermediario.rb
|
146
144
|
- lib/br_nfe/servico/response/default.rb
|
@@ -152,6 +150,7 @@ files:
|
|
152
150
|
- test/br_nfe/destinatario_test.rb
|
153
151
|
- test/br_nfe/emitente_test.rb
|
154
152
|
- test/br_nfe/endereco_test.rb
|
153
|
+
- test/br_nfe/helper/cpf_cnpj_test.rb
|
155
154
|
- test/br_nfe/helper/have_address_test.rb
|
156
155
|
- test/br_nfe/helper/have_condicao_pagamento_test.rb
|
157
156
|
- test/br_nfe/helper/have_destinatario_test.rb
|
@@ -168,10 +167,18 @@ files:
|
|
168
167
|
- test/br_nfe/servico/betha/v1/consulta_situacao_lote_rps_test.rb
|
169
168
|
- test/br_nfe/servico/betha/v1/gateway_test.rb
|
170
169
|
- test/br_nfe/servico/betha/v1/recepcao_lote_rps_test.rb
|
170
|
+
- test/br_nfe/servico/betha/v2/cancelamento_nfs_test.rb
|
171
|
+
- test/br_nfe/servico/betha/v2/consulta_lote_rps_test.rb
|
172
|
+
- test/br_nfe/servico/betha/v2/consulta_nfse_por_rps_test.rb
|
173
|
+
- test/br_nfe/servico/betha/v2/envio_lote_rps_sincrono_test.rb
|
174
|
+
- test/br_nfe/servico/betha/v2/gateway_test.rb
|
175
|
+
- test/br_nfe/servico/betha/v2/gera_nfse_test.rb
|
176
|
+
- test/br_nfe/servico/betha/v2/recepcao_lote_rps_test.rb
|
177
|
+
- test/br_nfe/servico/betha/v2/substituicao_nfse_test.rb
|
178
|
+
- test/br_nfe/servico/intermediario_test.rb
|
171
179
|
- test/br_nfe/servico/response/default_test.rb
|
172
180
|
- test/br_nfe/servico/response/nota_fiscal_test.rb
|
173
181
|
- test/br_nfe/servico/rps_test.rb
|
174
|
-
- test/certificado.rb
|
175
182
|
- test/factories/base.rb
|
176
183
|
- test/factories/condicao_pagamento.rb
|
177
184
|
- test/factories/destinatario.rb
|
@@ -187,11 +194,18 @@ files:
|
|
187
194
|
- test/factories/servico/betha/v1/consulta_situacao_lote_rps.rb
|
188
195
|
- test/factories/servico/betha/v1/gateway.rb
|
189
196
|
- test/factories/servico/betha/v1/recepcao_lote_rps.rb
|
197
|
+
- test/factories/servico/betha/v2/cancelamento_nfs.rb
|
198
|
+
- test/factories/servico/betha/v2/consulta_lote_rps.rb
|
199
|
+
- test/factories/servico/betha/v2/consulta_nfse_por_rps.rb
|
200
|
+
- test/factories/servico/betha/v2/envio_lote_rps_sincrono.rb
|
201
|
+
- test/factories/servico/betha/v2/gateway.rb
|
202
|
+
- test/factories/servico/betha/v2/gera_nfse.rb
|
203
|
+
- test/factories/servico/betha/v2/recepcao_lote_rps.rb
|
204
|
+
- test/factories/servico/betha/v2/substituicao_nfse.rb
|
190
205
|
- test/factories/servico/intermediario.rb
|
191
206
|
- test/factories/servico/response/default.rb
|
192
207
|
- test/factories/servico/response/nota_fiscal.rb
|
193
208
|
- test/factories/servico/rps.rb
|
194
|
-
- test/test_helper.rb
|
195
209
|
homepage: https://github.com/Brunomm/br_nfe
|
196
210
|
licenses:
|
197
211
|
- BSD
|
@@ -215,13 +229,15 @@ rubyforge_project:
|
|
215
229
|
rubygems_version: 2.4.6
|
216
230
|
signing_key:
|
217
231
|
specification_version: 4
|
218
|
-
summary:
|
232
|
+
summary: BrNfe é uma gem para projetos Ruby on Rails que tem como objetifo facilitar
|
233
|
+
e padronizar a emissão de Notas Fiscais eletrônicas
|
219
234
|
test_files:
|
220
235
|
- test/br_nfe/base_test.rb
|
221
236
|
- test/br_nfe/condicao_pagamento_test.rb
|
222
237
|
- test/br_nfe/destinatario_test.rb
|
223
238
|
- test/br_nfe/emitente_test.rb
|
224
239
|
- test/br_nfe/endereco_test.rb
|
240
|
+
- test/br_nfe/helper/cpf_cnpj_test.rb
|
225
241
|
- test/br_nfe/helper/have_address_test.rb
|
226
242
|
- test/br_nfe/helper/have_condicao_pagamento_test.rb
|
227
243
|
- test/br_nfe/helper/have_destinatario_test.rb
|
@@ -238,6 +254,15 @@ test_files:
|
|
238
254
|
- test/br_nfe/servico/betha/v1/consulta_situacao_lote_rps_test.rb
|
239
255
|
- test/br_nfe/servico/betha/v1/gateway_test.rb
|
240
256
|
- test/br_nfe/servico/betha/v1/recepcao_lote_rps_test.rb
|
257
|
+
- test/br_nfe/servico/betha/v2/cancelamento_nfs_test.rb
|
258
|
+
- test/br_nfe/servico/betha/v2/consulta_lote_rps_test.rb
|
259
|
+
- test/br_nfe/servico/betha/v2/consulta_nfse_por_rps_test.rb
|
260
|
+
- test/br_nfe/servico/betha/v2/envio_lote_rps_sincrono_test.rb
|
261
|
+
- test/br_nfe/servico/betha/v2/gateway_test.rb
|
262
|
+
- test/br_nfe/servico/betha/v2/gera_nfse_test.rb
|
263
|
+
- test/br_nfe/servico/betha/v2/recepcao_lote_rps_test.rb
|
264
|
+
- test/br_nfe/servico/betha/v2/substituicao_nfse_test.rb
|
265
|
+
- test/br_nfe/servico/intermediario_test.rb
|
241
266
|
- test/br_nfe/servico/response/default_test.rb
|
242
267
|
- test/br_nfe/servico/response/nota_fiscal_test.rb
|
243
268
|
- test/br_nfe/servico/rps_test.rb
|
@@ -256,6 +281,14 @@ test_files:
|
|
256
281
|
- test/factories/servico/betha/v1/consulta_situacao_lote_rps.rb
|
257
282
|
- test/factories/servico/betha/v1/gateway.rb
|
258
283
|
- test/factories/servico/betha/v1/recepcao_lote_rps.rb
|
284
|
+
- test/factories/servico/betha/v2/cancelamento_nfs.rb
|
285
|
+
- test/factories/servico/betha/v2/consulta_lote_rps.rb
|
286
|
+
- test/factories/servico/betha/v2/consulta_nfse_por_rps.rb
|
287
|
+
- test/factories/servico/betha/v2/envio_lote_rps_sincrono.rb
|
288
|
+
- test/factories/servico/betha/v2/gateway.rb
|
289
|
+
- test/factories/servico/betha/v2/gera_nfse.rb
|
290
|
+
- test/factories/servico/betha/v2/recepcao_lote_rps.rb
|
291
|
+
- test/factories/servico/betha/v2/substituicao_nfse.rb
|
259
292
|
- test/factories/servico/intermediario.rb
|
260
293
|
- test/factories/servico/response/default.rb
|
261
294
|
- test/factories/servico/response/nota_fiscal.rb
|
data/Gemfile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
group :test do
|
6
|
-
# gem "mocha", :require => false
|
7
|
-
gem "mocha", :require => false
|
8
|
-
gem "factory_girl_rails"
|
9
|
-
gem 'minitest-reporters'
|
10
|
-
gem 'minitest-rails'
|
11
|
-
gem 'minitest-spec-rails'
|
12
|
-
gem 'shoulda-matchers', require: false
|
13
|
-
gem "minitest-matchers_vaccine"
|
14
|
-
gem 'simplecov'
|
15
|
-
end
|
data/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'rake/testtask'
|
2
|
-
|
3
|
-
Rake::TestTask.new do |task|
|
4
|
-
task.libs << %w(test lib)
|
5
|
-
task.pattern = 'test/**/*_test.rb'
|
6
|
-
end
|
7
|
-
|
8
|
-
desc "Open an irb session preloaded with this library"
|
9
|
-
task :console do
|
10
|
-
sh "irb -rubygems -I lib -r br_nfe.rb"
|
11
|
-
end
|
12
|
-
|
13
|
-
task :default => :test
|
data/lib/br_nfe/seed.rb
DELETED
@@ -1,195 +0,0 @@
|
|
1
|
-
module BrNfe
|
2
|
-
class Seed < BrNfe::ActiveModelBase
|
3
|
-
attr_accessor :env
|
4
|
-
attr_accessor :numero_lote
|
5
|
-
attr_accessor :numero_rps
|
6
|
-
|
7
|
-
|
8
|
-
def default_values
|
9
|
-
{env: :test}
|
10
|
-
end
|
11
|
-
|
12
|
-
def emitente
|
13
|
-
BrNfe::Emitente.new({
|
14
|
-
cnpj: '18.113.831/0001-35',
|
15
|
-
inscricao_municipal: '42615-6',
|
16
|
-
razao_social: 'TWOWEB AGENCIA DIGITAL LTDA - ME',
|
17
|
-
nome_fantasia: 'TWOWEB AGENCIA DIGITAL',
|
18
|
-
telefone: '33161107',
|
19
|
-
email: 'mail@mail.com',
|
20
|
-
regime_especial_tributacao: '1',
|
21
|
-
optante_simples_nacional: '2',
|
22
|
-
incentivo_fiscal: '2',
|
23
|
-
natureza_operacao: '1',
|
24
|
-
endereco: {
|
25
|
-
logradouro: 'R AFONSO PENA',
|
26
|
-
numero: '420',
|
27
|
-
complemento: 'D',
|
28
|
-
bairro: 'SAO CRISTOVAO',
|
29
|
-
nome_municipio: 'Chapeco',
|
30
|
-
codigo_municipio: '4204202',
|
31
|
-
uf: 'SC',
|
32
|
-
cep: '89804023',
|
33
|
-
}
|
34
|
-
})
|
35
|
-
end
|
36
|
-
|
37
|
-
def destinatario
|
38
|
-
BrNfe::Destinatario.new({
|
39
|
-
cpf_cnpj: '18.077.391/0001-08',
|
40
|
-
razao_social: 'I9K SOLUCOES TECNOLOGICAS LTDA',
|
41
|
-
nome_fantasia: 'I9K SOLUCOES',
|
42
|
-
telefone: '336644557',
|
43
|
-
email: 'mail@mail.com',
|
44
|
-
endereco: {
|
45
|
-
logradouro: 'R JERUSALEM',
|
46
|
-
numero: '61',
|
47
|
-
complemento: 'E, SALAS 06 E 07',
|
48
|
-
bairro: 'PASSO DOS FORTES',
|
49
|
-
nome_municipio: 'Chapeco',
|
50
|
-
codigo_municipio: '4204202',
|
51
|
-
uf: 'SC',
|
52
|
-
cep: '89805675',
|
53
|
-
}
|
54
|
-
})
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
def recepcao_lote_rps_v1
|
59
|
-
BrNfe::Servico::Betha::V1::RecepcaoLoteRps.new do |recepcao|
|
60
|
-
recepcao.emitente = emitente
|
61
|
-
recepcao.lote_rps = rps
|
62
|
-
recepcao.numero_lote_rps = numero_lote
|
63
|
-
recepcao.env = :test
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
def consulta_lote_rps_v1(protocolo)
|
69
|
-
BrNfe::Servico::Betha::V1::ConsultaLoteRps.new do |obj|
|
70
|
-
obj.env = env
|
71
|
-
obj.emitente = emitente
|
72
|
-
obj.protocolo = protocolo
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def consulta_nfs_por_rps_v1
|
78
|
-
BrNfe::Servico::Betha::V1::ConsultaNfsPorRps.new do |obj|
|
79
|
-
obj.env = env
|
80
|
-
obj.emitente = emitente
|
81
|
-
obj.rps = rps
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def consulta_nfse_v1(params={})
|
86
|
-
BrNfe::Servico::Betha::V1::ConsultaNfse.new do |obj|
|
87
|
-
obj.env = env
|
88
|
-
obj.emitente = emitente
|
89
|
-
obj.numero_nfse = params[:numero_nfse]
|
90
|
-
obj.data_inicial = params[:data_inicial] || Date.today.beginning_of_month
|
91
|
-
obj.data_final = params[:data_final] || Date.today.end_of_month
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def cancelamento_nfs_v1(params = {})
|
96
|
-
BrNfe::Servico::Betha::V1::CancelamentoNfs.new do |c|
|
97
|
-
c.env = :test
|
98
|
-
c.emitente = emitente
|
99
|
-
c.numero_nfse = params[:numero_nfse]
|
100
|
-
codigo_cancelamento = params[:codigo_cancelamento] || '1'
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def recepcao_lote_rps_v2
|
105
|
-
BrNfe::Servico::Betha::V2::RecepcaoLoteRps.new do |recepcao|
|
106
|
-
recepcao.emitente = emitente
|
107
|
-
recepcao.lote_rps = rps
|
108
|
-
recepcao.numero_lote_rps = numero_lote
|
109
|
-
recepcao.env = :test
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def consulta_lote_rps_v2(protocolo)
|
114
|
-
BrNfe::Servico::Betha::V2::ConsultaLoteRps.new do |obj|
|
115
|
-
obj.env = env
|
116
|
-
obj.emitente = emitente
|
117
|
-
obj.protocolo = protocolo
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def consulta_nfs_por_rps_v2
|
122
|
-
BrNfe::Servico::Betha::V2::ConsultaNfsePorRps.new do |obj|
|
123
|
-
obj.env = env
|
124
|
-
obj.emitente = emitente
|
125
|
-
obj.rps = rps
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def envio_lote_rps_sincrono_v2(params={})
|
130
|
-
BrNfe::Servico::Betha::V2::EnvioLoteRpsSincrono.new do |recepcao|
|
131
|
-
recepcao.emitente = emitente
|
132
|
-
recepcao.lote_rps = rps
|
133
|
-
recepcao.numero_lote_rps = numero_lote
|
134
|
-
recepcao.env = :test
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def gera_nfse_v2(params={})
|
139
|
-
BrNfe::Servico::Betha::V2::GeraNfse.new do |recepcao|
|
140
|
-
recepcao.emitente = emitente
|
141
|
-
recepcao.rps = rps
|
142
|
-
recepcao.env = :test
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def substituicao_v2(params={})
|
147
|
-
BrNfe::Servico::Betha::V2::SubstituicaoNfse.new do |recepcao|
|
148
|
-
recepcao.emitente = emitente
|
149
|
-
recepcao.rps = rps
|
150
|
-
recepcao.numero_nfse = params[:numero_nfse]
|
151
|
-
recepcao.codigo_cancelamento = params[:codigo_cancelamento]
|
152
|
-
recepcao.env = :test
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
def rps
|
159
|
-
BrNfe::Servico::Rps.new do |rps|
|
160
|
-
rps.destinatario = destinatario
|
161
|
-
rps.numero = numero_rps
|
162
|
-
rps.serie = 'SN'
|
163
|
-
rps.tipo = '1'
|
164
|
-
rps.data_emissao = DateTime.now
|
165
|
-
rps.status = '1'
|
166
|
-
rps.competencia = Date.today
|
167
|
-
|
168
|
-
rps.valor_servicos = '49.00'
|
169
|
-
rps.valor_deducoes = '0.0'
|
170
|
-
rps.valor_pis = '0.0'
|
171
|
-
rps.valor_cofins = '0.0'
|
172
|
-
rps.valor_inss = '0.0'
|
173
|
-
rps.valor_ir = '0.0'
|
174
|
-
rps.valor_csll = '0.0'
|
175
|
-
rps.outras_retencoes = '0.0'
|
176
|
-
# rps.valor_iss = '0.98'
|
177
|
-
# rps.aliquota = '0.02'
|
178
|
-
rps.base_calculo = '49.00'
|
179
|
-
rps.desconto_incondicionado = '0.0'
|
180
|
-
rps.desconto_condicionado = '0.0'
|
181
|
-
|
182
|
-
rps.iss_retido = '2'
|
183
|
-
rps.responsavel_retencao = ''
|
184
|
-
rps.item_lista_servico = '0107'
|
185
|
-
rps.codigo_tributacao_municipio = '2525'
|
186
|
-
rps.discriminacao = "1 MENSALIDADE PLANO LIGHT. 49,00 \n\n\n\n\nValor Aprox dos Tributos: R$ 6,59 Federal, R$ 0,00 Estadual e R$ 1,62 Municipal \n Fonte: IBPT/FECOMERCIO SC 5oi7eW"
|
187
|
-
rps.exigibilidade_iss = '1'
|
188
|
-
rps.codigo_municipio = '4204202'
|
189
|
-
rps.numero_processo = ''
|
190
|
-
rps.codigo_cnae = '6202300'
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
end
|
195
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module BrNfe
|
2
|
-
module Servico
|
3
|
-
module Betha
|
4
|
-
module V2
|
5
|
-
class Response < BrNfe::ActiveModelBase
|
6
|
-
attr_accessor :xml, :nfe_method
|
7
|
-
|
8
|
-
def messages
|
9
|
-
Nori.new(:convert_tags_to => lambda { |tag| tag.snakecase.to_sym }).parse(xml.to_s)["#{nfe_method.to_s}_resposta".to_sym]
|
10
|
-
end
|
11
|
-
|
12
|
-
def success?
|
13
|
-
raise "Não implementado"
|
14
|
-
end
|
15
|
-
|
16
|
-
def errors
|
17
|
-
raise "Não implementado"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/test/certificado.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Esta classe é utilizada apenas para simular um certificado
|
3
|
-
# E assim não havendo a necessidade de ter um arquivo com um certificado para efetuar os testes
|
4
|
-
#
|
5
|
-
class Certificado
|
6
|
-
def key
|
7
|
-
@key ||= OpenSSL::PKey::RSA.new(2048)
|
8
|
-
end
|
9
|
-
def certificate
|
10
|
-
@certificate ||= OpenSSL::X509::Certificate.new
|
11
|
-
end
|
12
|
-
end
|