br_danfe 0.12.1 → 0.13.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 +4 -4
- data/.rubocop.yml +15 -25
- data/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/lib/br_danfe.rb +0 -1
- data/lib/br_danfe/danfe.rb +6 -90
- data/lib/br_danfe/danfe_lib/base.rb +33 -0
- data/lib/br_danfe/danfe_lib/nfce.rb +49 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +37 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +22 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +69 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +20 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +22 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +102 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +25 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +75 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +81 -0
- data/lib/br_danfe/danfe_lib/nfe.rb +83 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +8 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/cst.rb +34 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +96 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +137 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +142 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +55 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +117 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +55 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +35 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +109 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb +103 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +37 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/phone.rb +15 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/plate.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +21 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +58 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +44 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +109 -0
- data/lib/br_danfe/helper.rb +8 -0
- data/lib/br_danfe/version.rb +1 -1
- data/spec/{lib → br_danfe}/cce_lib/barcode_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/correction_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/document_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/footer_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/header_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/nfe_key_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/protocol_spec.rb +0 -0
- data/spec/{features → br_danfe}/cce_spec.rb +0 -0
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/document_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/footer_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/header_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/helper_spec.rb +1 -1
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/key_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/nfce_identification_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/product_list_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/qr_code_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/recipient_spec.rb +7 -7
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/total_list_spec.rb +4 -4
- data/spec/br_danfe/danfe_lib/nfce_spec.rb +57 -0
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cep_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cst_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dest_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/det_body_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/document_spec.rb +1 -1
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dup_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/emit_header_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/helper_spec.rb +13 -87
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/icmstot_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_vol_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/issqn_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/phone_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/plate_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/ticket_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/transp_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/vol_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/xprod_spec.rb +9 -9
- data/spec/{features/danfe_spec.rb → br_danfe/danfe_lib/nfe_spec.rb} +55 -47
- data/spec/br_danfe/danfe_spec.rb +35 -0
- data/spec/{lib → br_danfe}/helper_spec.rb +114 -0
- data/spec/{lib → br_danfe}/logo_config_spec.rb +1 -1
- data/spec/{lib → br_danfe}/logo_options_spec.rb +7 -7
- data/spec/{lib → br_danfe}/uf_spec.rb +0 -0
- data/spec/{lib → br_danfe}/xml_spec.rb +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml +358 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml +358 -0
- data/spec/fixtures/nfce/v4.00/nfce.xml +2 -2
- data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
- metadata +82 -75
- data/lib/br_danfe/danfe_lib/cep.rb +0 -9
- data/lib/br_danfe/danfe_lib/consts.rb +0 -6
- data/lib/br_danfe/danfe_lib/cst.rb +0 -32
- data/lib/br_danfe/danfe_lib/dest.rb +0 -94
- data/lib/br_danfe/danfe_lib/det_body.rb +0 -135
- data/lib/br_danfe/danfe_lib/document.rb +0 -140
- data/lib/br_danfe/danfe_lib/dup.rb +0 -53
- data/lib/br_danfe/danfe_lib/emit_header.rb +0 -115
- data/lib/br_danfe/danfe_lib/helper.rb +0 -61
- data/lib/br_danfe/danfe_lib/icmstot.rb +0 -33
- data/lib/br_danfe/danfe_lib/infadic.rb +0 -107
- data/lib/br_danfe/danfe_lib/infadic_vol.rb +0 -101
- data/lib/br_danfe/danfe_lib/issqn.rb +0 -35
- data/lib/br_danfe/danfe_lib/phone.rb +0 -13
- data/lib/br_danfe/danfe_lib/plate.rb +0 -9
- data/lib/br_danfe/danfe_lib/ticket.rb +0 -19
- data/lib/br_danfe/danfe_lib/transp.rb +0 -56
- data/lib/br_danfe/danfe_lib/vol.rb +0 -42
- data/lib/br_danfe/danfe_lib/xprod.rb +0 -107
- data/lib/br_danfe/danfe_nfce.rb +0 -43
- data/lib/br_danfe/danfe_nfce_lib/document.rb +0 -35
- data/lib/br_danfe/danfe_nfce_lib/footer.rb +0 -20
- data/lib/br_danfe/danfe_nfce_lib/header.rb +0 -67
- data/lib/br_danfe/danfe_nfce_lib/helper.rb +0 -9
- data/lib/br_danfe/danfe_nfce_lib/key.rb +0 -18
- data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +0 -20
- data/lib/br_danfe/danfe_nfce_lib/product_list.rb +0 -100
- data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +0 -23
- data/lib/br_danfe/danfe_nfce_lib/recipient.rb +0 -72
- data/lib/br_danfe/danfe_nfce_lib/total_list.rb +0 -78
- data/spec/features/danfe_nfce_spec.rb +0 -31
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe BrDanfe::DanfeLib::Plate do
|
|
3
|
+
describe BrDanfe::DanfeLib::NfeLib::Plate do
|
|
4
4
|
describe '.format_plate' do
|
|
5
5
|
it 'returns a formated plate' do
|
|
6
6
|
plate = 'ABC1234'
|
|
7
|
-
expect(BrDanfe::DanfeLib::Plate.format(plate)).to eq 'ABC-1234'
|
|
7
|
+
expect(BrDanfe::DanfeLib::NfeLib::Plate.format(plate)).to eq 'ABC-1234'
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
context 'when receive a mercosul plate' do
|
|
11
11
|
it 'returns a formated plate' do
|
|
12
12
|
plate = 'ABC1D23'
|
|
13
|
-
expect(BrDanfe::DanfeLib::Plate.format(plate)).to eq 'ABC-1D23'
|
|
13
|
+
expect(BrDanfe::DanfeLib::NfeLib::Plate.format(plate)).to eq 'ABC-1D23'
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe BrDanfe::DanfeLib::Ticket do
|
|
3
|
+
describe BrDanfe::DanfeLib::NfeLib::Ticket do
|
|
4
4
|
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
|
6
6
|
|
|
7
|
-
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
|
7
|
+
let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
|
|
8
8
|
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
|
9
9
|
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe BrDanfe::DanfeLib::Transp do
|
|
3
|
+
describe BrDanfe::DanfeLib::NfeLib::Transp do
|
|
4
4
|
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
|
6
6
|
|
|
7
|
-
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
|
7
|
+
let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
|
|
8
8
|
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
|
9
9
|
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe BrDanfe::DanfeLib::Vol do
|
|
3
|
+
describe BrDanfe::DanfeLib::NfeLib::Vol do
|
|
4
4
|
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
|
6
6
|
|
|
7
|
-
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
|
7
|
+
let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
|
|
8
8
|
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
|
9
9
|
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe BrDanfe::DanfeLib::Xprod do
|
|
3
|
+
describe BrDanfe::DanfeLib::NfeLib::Xprod do
|
|
4
4
|
describe '#render' do
|
|
5
5
|
context 'when has FCI' do
|
|
6
6
|
let(:xml_fci) do
|
|
@@ -16,7 +16,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
16
16
|
Nokogiri::XML(xml)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml_fci) }
|
|
19
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml_fci) }
|
|
20
20
|
|
|
21
21
|
it 'returns product + FCI' do
|
|
22
22
|
expected = 'MONITOR DE ARCO ELETRICO'
|
|
@@ -66,7 +66,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
66
66
|
Nokogiri::XML(xml)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml) }
|
|
69
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml) }
|
|
70
70
|
|
|
71
71
|
context 'when has vBCSTRet' do
|
|
72
72
|
let(:vBCSTRet) { 50.00 }
|
|
@@ -137,7 +137,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
137
137
|
Nokogiri::XML(xml)
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml_st) }
|
|
140
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml_st) }
|
|
141
141
|
|
|
142
142
|
it 'returns product + ST' do
|
|
143
143
|
expected = 'MONITOR DE ARCO ELETRICO'
|
|
@@ -163,7 +163,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
163
163
|
Nokogiri::XML(xml)
|
|
164
164
|
end
|
|
165
165
|
|
|
166
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml_infAdProd) }
|
|
166
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml_infAdProd) }
|
|
167
167
|
|
|
168
168
|
it 'returns product + infAdProd' do
|
|
169
169
|
expected = 'MONITOR DE ARCO ELETRICO'
|
|
@@ -196,7 +196,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
196
196
|
Nokogiri::XML(xml)
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml_fcp) }
|
|
199
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml_fcp) }
|
|
200
200
|
|
|
201
201
|
it 'returns product + FCP' do
|
|
202
202
|
expected = 'MONITOR DE ARCO ELETRICO'
|
|
@@ -237,7 +237,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
237
237
|
Nokogiri::XML(xml)
|
|
238
238
|
end
|
|
239
239
|
|
|
240
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml_IFC_ST_infAdProd) }
|
|
240
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml_IFC_ST_infAdProd) }
|
|
241
241
|
|
|
242
242
|
it 'returns product + FCI + ST + infAdProd' do
|
|
243
243
|
expected = 'MONITOR DE ARCO ELETRICO'
|
|
@@ -277,7 +277,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
277
277
|
Nokogiri::XML(xml)
|
|
278
278
|
end
|
|
279
279
|
|
|
280
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml_fcp) }
|
|
280
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml_fcp) }
|
|
281
281
|
|
|
282
282
|
it 'returns product + FCP' do
|
|
283
283
|
expected = 'MONITOR DE ARCO ELETRICO'
|
|
@@ -311,7 +311,7 @@ describe BrDanfe::DanfeLib::Xprod do
|
|
|
311
311
|
Nokogiri::XML(xml)
|
|
312
312
|
end
|
|
313
313
|
|
|
314
|
-
subject { BrDanfe::DanfeLib::Xprod.new(xml_fcp) }
|
|
314
|
+
subject { BrDanfe::DanfeLib::NfeLib::Xprod.new(xml_fcp) }
|
|
315
315
|
|
|
316
316
|
it 'returns product + FCP' do
|
|
317
317
|
expected = 'MONITOR DE ARCO ELETRICO'
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe BrDanfe::
|
|
3
|
+
describe BrDanfe::DanfeLib::Nfe do
|
|
4
4
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
|
5
|
+
let(:xml_file) {}
|
|
6
|
+
let(:xml) { BrDanfe::XML.new(xml_file) }
|
|
7
|
+
|
|
8
|
+
subject { described_class.new xml }
|
|
5
9
|
|
|
6
10
|
describe '#render_pdf' do
|
|
7
11
|
let(:base_dir) { './spec/fixtures/nfe/v3.10/' }
|
|
12
|
+
let(:xml_file) { File.read("#{base_dir}nfe_simples_nacional.xml") }
|
|
8
13
|
|
|
9
14
|
it 'renders a Simples Nacional NF-e using CSOSN' do
|
|
10
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
|
11
|
-
|
|
12
15
|
expected = IO.binread("#{base_dir}nfe_simples_nacional.xml.fixture.pdf")
|
|
13
|
-
|
|
14
|
-
expect(danfe.render_pdf).to eq expected
|
|
16
|
+
expect(subject.render_pdf).to eq expected
|
|
15
17
|
end
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
describe '#save_pdf' do
|
|
19
21
|
context 'when danfe has custom options' do
|
|
20
22
|
let(:base_dir) { './spec/fixtures/nfe/v2.00/' }
|
|
23
|
+
let(:xml_file) { File.read("#{base_dir}custom_options.fixture.xml") }
|
|
21
24
|
|
|
22
25
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
|
23
26
|
|
|
24
27
|
it 'render a NF-e with customized options' do
|
|
25
28
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
danfe.save_pdf output_pdf
|
|
30
|
+
subject.options.logo = 'spec/fixtures/logo.png'
|
|
31
|
+
subject.options.logo_dimensions = { width: 100, height: 100 }
|
|
32
|
+
subject.save_pdf output_pdf
|
|
32
33
|
|
|
33
34
|
expect("#{base_dir}custom_options.fixture.pdf").to have_same_content_of file: output_pdf
|
|
34
35
|
end
|
|
@@ -36,109 +37,116 @@ describe BrDanfe::Danfe do
|
|
|
36
37
|
|
|
37
38
|
context "when xml's version is v2.00" do
|
|
38
39
|
let(:base_dir) { './spec/fixtures/nfe/v2.00/' }
|
|
40
|
+
let(:xml_file) { File.read("#{base_dir}nfe_with_ns.xml") }
|
|
39
41
|
|
|
40
42
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
|
41
43
|
|
|
42
44
|
it 'renders a basic NF-e with namespace' do
|
|
43
45
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
44
|
-
|
|
45
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_ns.xml"))
|
|
46
|
-
danfe.save_pdf output_pdf
|
|
46
|
+
subject.save_pdf output_pdf
|
|
47
47
|
|
|
48
48
|
expect("#{base_dir}nfe_with_ns.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
context 'when NF-e does not have namespace' do
|
|
52
|
+
let(:xml_file) { File.read("#{base_dir}nfe_without_ns.xml") }
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
it 'renders another basic NF-e without namespace' do
|
|
55
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
|
56
|
+
subject.save_pdf output_pdf
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
expect("#{base_dir}nfe_without_ns.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
|
59
|
+
end
|
|
58
60
|
end
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
context 'when NF-e items has FCI' do
|
|
63
|
+
let(:xml_file) { File.read("#{base_dir}nfe_with_fci.xml") }
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
it 'renders a NF-e having FCI in its items' do
|
|
66
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
|
67
|
+
subject.save_pdf output_pdf
|
|
65
68
|
|
|
66
|
-
|
|
69
|
+
expect("#{base_dir}nfe_with_fci.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
|
70
|
+
end
|
|
67
71
|
end
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
context 'when NF-e is Simples Nacional with CSOSN' do
|
|
74
|
+
let(:xml_file) { File.read("#{base_dir}nfe_simples_nacional.xml") }
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
it 'renders a Simples Nacional NF-e using CSOSN' do
|
|
77
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
|
78
|
+
subject.save_pdf output_pdf
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
|
81
|
+
end
|
|
76
82
|
end
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
context 'when NF-e has extra volumes' do
|
|
85
|
+
let(:xml_file) { File.read("#{base_dir}nfe_with_extra_volumes.xml") }
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
it 'renders a NF-e with extra volumes' do
|
|
88
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
|
89
|
+
subject.save_pdf output_pdf
|
|
83
90
|
|
|
84
|
-
|
|
91
|
+
expect("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
|
92
|
+
end
|
|
85
93
|
end
|
|
86
94
|
end
|
|
87
95
|
|
|
88
96
|
context "when xml's version is v3.10" do
|
|
89
97
|
let(:base_dir) { './spec/fixtures/nfe/v3.10/' }
|
|
98
|
+
let(:xml_file) { File.read("#{base_dir}nfe_simples_nacional.xml") }
|
|
90
99
|
|
|
91
100
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
|
92
101
|
|
|
93
102
|
it 'renders a Simples Nacional NF-e using CSOSN' do
|
|
94
103
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
95
|
-
|
|
96
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
|
97
|
-
danfe.save_pdf output_pdf
|
|
104
|
+
subject.save_pdf output_pdf
|
|
98
105
|
|
|
99
106
|
expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
|
100
107
|
end
|
|
101
108
|
|
|
102
109
|
context 'when there are more than one page' do
|
|
110
|
+
let(:xml_file) { File.read("#{base_dir}with_three_pages.xml") }
|
|
111
|
+
|
|
103
112
|
it 'renders xml to the pdf' do
|
|
104
113
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
105
|
-
|
|
106
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}with_three_pages.xml"))
|
|
107
|
-
danfe.save_pdf output_pdf
|
|
114
|
+
subject.save_pdf output_pdf
|
|
108
115
|
|
|
109
116
|
expect("#{base_dir}with_three_pages.fixture.pdf").to have_same_content_of file: output_pdf
|
|
110
117
|
end
|
|
111
118
|
end
|
|
112
119
|
|
|
113
120
|
context 'when there is ISSQN' do
|
|
121
|
+
let(:xml_file) { File.read("#{base_dir}with_issqn.xml") }
|
|
122
|
+
|
|
114
123
|
it 'renders xml to the pdf' do
|
|
115
124
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
116
|
-
|
|
117
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}with_issqn.xml"))
|
|
118
|
-
danfe.save_pdf output_pdf
|
|
125
|
+
subject.save_pdf output_pdf
|
|
119
126
|
|
|
120
127
|
expect("#{base_dir}with_issqn.fixture.pdf").to have_same_content_of file: output_pdf
|
|
121
128
|
end
|
|
122
129
|
end
|
|
123
130
|
|
|
124
131
|
context "when there isn't ISSQN" do
|
|
132
|
+
let(:xml_file) { File.read("#{base_dir}without_issqn.xml") }
|
|
133
|
+
|
|
125
134
|
it 'renders xml to the pdf' do
|
|
126
135
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
127
|
-
|
|
128
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}without_issqn.xml"))
|
|
129
|
-
danfe.save_pdf output_pdf
|
|
136
|
+
subject.save_pdf output_pdf
|
|
130
137
|
|
|
131
138
|
expect("#{base_dir}without_issqn.fixture.pdf").to have_same_content_of file: output_pdf
|
|
132
139
|
end
|
|
133
140
|
end
|
|
134
141
|
|
|
135
142
|
context 'when there is footer information' do
|
|
143
|
+
let(:xml_file) { File.read("#{base_dir}with_footer.xml") }
|
|
144
|
+
|
|
136
145
|
it 'renders xml to the pdf' do
|
|
137
146
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
138
147
|
|
|
139
148
|
footer = 'Gerado através do Teste'
|
|
140
|
-
|
|
141
|
-
danfe.save_pdf output_pdf, footer
|
|
149
|
+
subject.save_pdf output_pdf, footer
|
|
142
150
|
|
|
143
151
|
expect("#{base_dir}with_footer.fixture.pdf").to have_same_content_of file: output_pdf
|
|
144
152
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe BrDanfe::Danfe do
|
|
4
|
+
let(:xml) do
|
|
5
|
+
<<-eos
|
|
6
|
+
<nfeProc>
|
|
7
|
+
<NFe>
|
|
8
|
+
<infNFe>
|
|
9
|
+
<ide>
|
|
10
|
+
<mod>#{mod}</mod>
|
|
11
|
+
</ide>
|
|
12
|
+
</infNFe>
|
|
13
|
+
</NFe>
|
|
14
|
+
</nfeProc>
|
|
15
|
+
eos
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
subject { described_class.new(xml) }
|
|
19
|
+
|
|
20
|
+
context 'when the xml document type is NF-e' do
|
|
21
|
+
let(:mod) { 55 }
|
|
22
|
+
|
|
23
|
+
it 'returns a NF-e danfe class' do
|
|
24
|
+
expect(subject.class).to eq BrDanfe::DanfeLib::Nfe
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'when the xml document type is NFC-e' do
|
|
29
|
+
let(:mod) { 65 }
|
|
30
|
+
|
|
31
|
+
it 'returns a NFC-e danfe class' do
|
|
32
|
+
expect(subject.class).to eq BrDanfe::DanfeLib::Nfce
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -1,6 +1,120 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe BrDanfe::Helper do
|
|
4
|
+
describe '.no_fiscal_value?' do
|
|
5
|
+
let(:xml_homologation) do
|
|
6
|
+
xml = <<-eos
|
|
7
|
+
<nfeProc>
|
|
8
|
+
<NFe>
|
|
9
|
+
<infNFe>
|
|
10
|
+
<ide>
|
|
11
|
+
<tpAmb>2</tpAmb>
|
|
12
|
+
</ide>
|
|
13
|
+
</infNFe>
|
|
14
|
+
<protNFe>
|
|
15
|
+
<infProt>
|
|
16
|
+
<dhRecbto>2011-10-29T14:37:09</dhRecbto>
|
|
17
|
+
</infProt>
|
|
18
|
+
</protNFe>
|
|
19
|
+
</NFe>
|
|
20
|
+
</nfeProc>
|
|
21
|
+
eos
|
|
22
|
+
|
|
23
|
+
Nokogiri::XML(xml)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
let(:xml_unauthorized) do
|
|
27
|
+
xml = <<-eos
|
|
28
|
+
<nfeProc>
|
|
29
|
+
<protNFe>
|
|
30
|
+
<infProt></infProt>
|
|
31
|
+
</protNFe>
|
|
32
|
+
</nfeProc>
|
|
33
|
+
eos
|
|
34
|
+
|
|
35
|
+
Nokogiri::XML(xml)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
let(:xml_authorized) do
|
|
39
|
+
xml = <<-eos
|
|
40
|
+
<nfeProc>
|
|
41
|
+
<NFe>
|
|
42
|
+
<infNFe>
|
|
43
|
+
<ide>
|
|
44
|
+
<tpAmb>1</tpAmb>
|
|
45
|
+
</ide>
|
|
46
|
+
</infNFe>
|
|
47
|
+
</NFe>
|
|
48
|
+
<protNFe>
|
|
49
|
+
<infProt>
|
|
50
|
+
<dhRecbto>2011-10-29T14:37:09</dhRecbto>
|
|
51
|
+
</infProt>
|
|
52
|
+
</protNFe>
|
|
53
|
+
</nfeProc>
|
|
54
|
+
eos
|
|
55
|
+
|
|
56
|
+
Nokogiri::XML(xml)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
context 'when XML is unauthorized' do
|
|
60
|
+
it 'returns true' do
|
|
61
|
+
expect(described_class.no_fiscal_value?(xml_unauthorized)).to eq true
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
context 'when XML is in homologation environment' do
|
|
66
|
+
it 'returns true' do
|
|
67
|
+
expect(described_class.no_fiscal_value?(xml_homologation)).to eq true
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context 'when XML is authorized' do
|
|
72
|
+
it 'returns false' do
|
|
73
|
+
expect(described_class.no_fiscal_value?(xml_authorized)).to eq false
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe '.unauthorized?' do
|
|
79
|
+
context 'when XML is unauthorized' do
|
|
80
|
+
let(:xml_unauthorized) do
|
|
81
|
+
xml = <<-eos
|
|
82
|
+
<nfeProc>
|
|
83
|
+
<protNFe>
|
|
84
|
+
<infProt></infProt>
|
|
85
|
+
</protNFe>
|
|
86
|
+
</nfeProc>
|
|
87
|
+
eos
|
|
88
|
+
|
|
89
|
+
Nokogiri::XML(xml)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'returns true' do
|
|
93
|
+
expect(described_class.unauthorized?(xml_unauthorized)).to eq true
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context 'when XML is authorized' do
|
|
98
|
+
let(:xml_authorized) do
|
|
99
|
+
xml = <<-eos
|
|
100
|
+
<nfeProc>
|
|
101
|
+
<protNFe>
|
|
102
|
+
<infProt>
|
|
103
|
+
<dhRecbto>2011-10-29T14:37:09</dhRecbto>
|
|
104
|
+
</infProt>
|
|
105
|
+
</protNFe>
|
|
106
|
+
</nfeProc>
|
|
107
|
+
eos
|
|
108
|
+
|
|
109
|
+
Nokogiri::XML(xml)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it 'returns false' do
|
|
113
|
+
expect(described_class.unauthorized?(xml_authorized)).to eq false
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
4
118
|
describe '.homologation?' do
|
|
5
119
|
context 'when tpAmb is equal to "2"' do
|
|
6
120
|
let(:xml_homologation) do
|