br_danfe 0.16.0 → 0.17.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +20 -8
- data/.github/dependabot.yml +19 -0
- data/.rubocop.yml +24 -11
- data/Gemfile.lock +41 -35
- data/Guardfile +3 -1
- data/bin/_guard-core +29 -0
- data/bin/guard +29 -0
- data/br_danfe.gemspec +7 -6
- data/lib/br_danfe/danfe_lib/nfce.rb +11 -9
- data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +2 -2
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +30 -16
- data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +3 -3
- data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +3 -3
- data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +44 -53
- data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +16 -15
- data/lib/br_danfe/danfe_lib/nfe.rb +11 -9
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -2
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +6 -7
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +2 -1
- data/lib/br_danfe/helper.rb +1 -1
- data/lib/br_danfe/mdfe.rb +1 -1
- data/lib/br_danfe/mdfe_lib/authorization_protocol.rb +1 -1
- data/lib/br_danfe/mdfe_lib/fisco_control.rb +6 -25
- data/lib/br_danfe/mdfe_lib/header.rb +7 -8
- data/lib/br_danfe/mdfe_lib/mdfe_identification.rb +1 -1
- data/lib/br_danfe/mdfe_lib/notes.rb +1 -1
- data/lib/br_danfe/qr_code.rb +1 -2
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb +3 -2
- data/spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb +6 -4
- data/spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfce_lib/recipient_spec.rb +10 -10
- data/spec/br_danfe/danfe_lib/nfce_lib/total_list_spec.rb +12 -12
- data/spec/br_danfe/danfe_lib/nfce_spec.rb +2 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/cst_spec.rb +4 -4
- data/spec/br_danfe/danfe_lib/nfe_lib/dest_spec.rb +178 -178
- data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +274 -274
- data/spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb +77 -77
- data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +23 -23
- data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +55 -37
- data/spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb +34 -34
- data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +19 -19
- data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +237 -237
- data/spec/br_danfe/danfe_lib/nfe_lib/infadic_vol_spec.rb +3 -2
- data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +16 -16
- data/spec/br_danfe/danfe_lib/nfe_lib/ticket_spec.rb +13 -13
- data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +76 -76
- data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +40 -40
- data/spec/br_danfe/danfe_lib/nfe_lib/xprod_spec.rb +118 -118
- data/spec/br_danfe/danfe_spec.rb +2 -2
- data/spec/br_danfe/helper_spec.rb +15 -15
- data/spec/br_danfe/mdfe_lib/document_spec.rb +2 -2
- data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +21 -7
- data/spec/br_danfe/mdfe_lib/header_spec.rb +27 -18
- data/spec/br_danfe/mdfe_lib/notes_spec.rb +5 -5
- data/spec/br_danfe/mdfe_lib/totalizer_spec.rb +1 -1
- data/spec/br_danfe/mdfe_spec.rb +4 -5
- data/spec/br_danfe/qr_code_spec.rb +4 -13
- data/spec/br_danfe/xml_spec.rb +6 -6
- data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
- data/spec/fixtures/nfce/lib/document#render.pdf +12 -23
- data/spec/fixtures/nfce/lib/footer#render-with_additional_information.pdf +0 -0
- data/spec/fixtures/nfce/lib/footer#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-homologation.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-long_name_with_logo.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-long_name_without_logo.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-short_name_with_logo.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-short_name_without_logo.pdf +0 -0
- data/spec/fixtures/nfce/lib/key#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list_with_many_products_and_long_names.xml +2 -2
- data/spec/fixtures/nfce/lib/product_list_with_single_product_and_long_name.xml +1 -1
- data/spec/fixtures/nfce/lib/recipient#render-company.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/multiples_xmls_on_the_same_pdf.pdf +568 -447
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
- data/spec/fixtures/nfe/lib/emit_header#render-nfe_key.pdf +945 -0
- data/spec/spec_helper.rb +1 -1
- metadata +38 -16
data/spec/br_danfe/danfe_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe BrDanfe::Danfe do
|
4
4
|
let(:xml) do
|
5
|
-
|
5
|
+
<<~XML
|
6
6
|
<nfeProc>
|
7
7
|
<NFe>
|
8
8
|
<infNFe>
|
@@ -17,7 +17,7 @@ describe BrDanfe::Danfe do
|
|
17
17
|
</infNFe>
|
18
18
|
</NFe>
|
19
19
|
</nfeProc>
|
20
|
-
|
20
|
+
XML
|
21
21
|
end
|
22
22
|
|
23
23
|
subject { described_class.new(xml) }
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe BrDanfe::Helper do
|
4
4
|
describe '.no_fiscal_value?' do
|
5
5
|
let(:xml_homologation) do
|
6
|
-
xml =
|
6
|
+
xml = <<~XML
|
7
7
|
<nfeProc>
|
8
8
|
<NFe>
|
9
9
|
<infNFe>
|
@@ -18,25 +18,25 @@ describe BrDanfe::Helper do
|
|
18
18
|
</protNFe>
|
19
19
|
</NFe>
|
20
20
|
</nfeProc>
|
21
|
-
|
21
|
+
XML
|
22
22
|
|
23
23
|
Nokogiri::XML(xml)
|
24
24
|
end
|
25
25
|
|
26
26
|
let(:xml_unauthorized) do
|
27
|
-
xml =
|
27
|
+
xml = <<~XML
|
28
28
|
<nfeProc>
|
29
29
|
<protNFe>
|
30
30
|
<infProt></infProt>
|
31
31
|
</protNFe>
|
32
32
|
</nfeProc>
|
33
|
-
|
33
|
+
XML
|
34
34
|
|
35
35
|
Nokogiri::XML(xml)
|
36
36
|
end
|
37
37
|
|
38
38
|
let(:xml_authorized) do
|
39
|
-
xml =
|
39
|
+
xml = <<~XML
|
40
40
|
<nfeProc>
|
41
41
|
<NFe>
|
42
42
|
<infNFe>
|
@@ -51,7 +51,7 @@ describe BrDanfe::Helper do
|
|
51
51
|
</infProt>
|
52
52
|
</protNFe>
|
53
53
|
</nfeProc>
|
54
|
-
|
54
|
+
XML
|
55
55
|
|
56
56
|
Nokogiri::XML(xml)
|
57
57
|
end
|
@@ -78,13 +78,13 @@ describe BrDanfe::Helper do
|
|
78
78
|
describe '.unauthorized?' do
|
79
79
|
context 'when XML is unauthorized' do
|
80
80
|
let(:xml_unauthorized) do
|
81
|
-
xml =
|
81
|
+
xml = <<~XML
|
82
82
|
<nfeProc>
|
83
83
|
<protNFe>
|
84
84
|
<infProt></infProt>
|
85
85
|
</protNFe>
|
86
86
|
</nfeProc>
|
87
|
-
|
87
|
+
XML
|
88
88
|
|
89
89
|
Nokogiri::XML(xml)
|
90
90
|
end
|
@@ -96,7 +96,7 @@ describe BrDanfe::Helper do
|
|
96
96
|
|
97
97
|
context 'when XML is authorized' do
|
98
98
|
let(:xml_authorized) do
|
99
|
-
xml =
|
99
|
+
xml = <<~XML
|
100
100
|
<nfeProc>
|
101
101
|
<protNFe>
|
102
102
|
<infProt>
|
@@ -104,7 +104,7 @@ describe BrDanfe::Helper do
|
|
104
104
|
</infProt>
|
105
105
|
</protNFe>
|
106
106
|
</nfeProc>
|
107
|
-
|
107
|
+
XML
|
108
108
|
|
109
109
|
Nokogiri::XML(xml)
|
110
110
|
end
|
@@ -118,7 +118,7 @@ describe BrDanfe::Helper do
|
|
118
118
|
describe '.homologation?' do
|
119
119
|
context 'when tpAmb is equal to "2"' do
|
120
120
|
let(:xml_homologation) do
|
121
|
-
xml =
|
121
|
+
xml = <<~XML
|
122
122
|
<nfeProc>
|
123
123
|
<NFe>
|
124
124
|
<infNFe>
|
@@ -128,7 +128,7 @@ describe BrDanfe::Helper do
|
|
128
128
|
</infNFe>
|
129
129
|
</NFe>
|
130
130
|
</nfeProc>
|
131
|
-
|
131
|
+
XML
|
132
132
|
|
133
133
|
Nokogiri::XML(xml)
|
134
134
|
end
|
@@ -140,7 +140,7 @@ describe BrDanfe::Helper do
|
|
140
140
|
|
141
141
|
context 'when tpAmb is different to "2"' do
|
142
142
|
let(:xml_production) do
|
143
|
-
xml =
|
143
|
+
xml = <<~XML
|
144
144
|
<nfeProc>
|
145
145
|
<NFe>
|
146
146
|
<infNFe>
|
@@ -150,7 +150,7 @@ describe BrDanfe::Helper do
|
|
150
150
|
</infNFe>
|
151
151
|
</NFe>
|
152
152
|
</nfeProc>
|
153
|
-
|
153
|
+
XML
|
154
154
|
|
155
155
|
Nokogiri::XML(xml)
|
156
156
|
end
|
@@ -214,7 +214,7 @@ describe BrDanfe::Helper do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
describe 'when has timezone' do
|
217
|
-
it'returns the formated string with the timezone' do
|
217
|
+
it 'returns the formated string with the timezone' do
|
218
218
|
expect(described_class.format_datetime('2013-10-18T13:54:04-03:00', with_time_zone: true)).to eql '18/10/2013 13:54:04-03:00'
|
219
219
|
end
|
220
220
|
end
|
@@ -7,13 +7,13 @@ describe BrDanfe::MdfeLib::Document do
|
|
7
7
|
describe '#method_missing' do
|
8
8
|
context 'when prawn has the method' do
|
9
9
|
it 'does not throws an error' do
|
10
|
-
expect
|
10
|
+
expect(subject).to respond_to :text
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'when prawn does not have the method' do
|
15
15
|
it 'throws an error' do
|
16
|
-
expect { subject.
|
16
|
+
expect { subject.non_existent_method }.to raise_error NameError
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -27,13 +27,11 @@ describe BrDanfe::MdfeLib::FiscoControl do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '#generate' do
|
30
|
-
|
30
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
31
31
|
|
32
32
|
it 'generates the title' do
|
33
|
-
title = 'CONTROLE DO FISCO'
|
34
|
-
|
35
33
|
subject.generate
|
36
|
-
expect(pdf_text).to include
|
34
|
+
expect(pdf_text).to include 'CONTROLE DO FISCO'
|
37
35
|
end
|
38
36
|
|
39
37
|
it 'generates the bar code' do
|
@@ -46,10 +44,26 @@ describe BrDanfe::MdfeLib::FiscoControl do
|
|
46
44
|
end
|
47
45
|
|
48
46
|
it 'generates the nfe key' do
|
49
|
-
nfe_key = "Chave de Acesso\n32210717781119000141580010000001211000000003"
|
50
|
-
|
51
47
|
subject.generate
|
52
|
-
expect(pdf_text).to include
|
48
|
+
expect(pdf_text).to include "Chave de Acesso\n32210717781119000141580010000001211000000003"
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when the XML does not have protMDFe tag' do
|
52
|
+
let(:xml_as_string) do
|
53
|
+
<<~XML
|
54
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
55
|
+
<mdfeProc xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00"></mdfeProc>
|
56
|
+
XML
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'does not generate the bar code and the nfe key' do
|
60
|
+
expect(File.exist?(output_pdf)).to be false
|
61
|
+
|
62
|
+
subject.generate
|
63
|
+
pdf.render_file output_pdf
|
64
|
+
|
65
|
+
expect("#{base_dir}fisco_control#without-barcode.pdf").to have_same_content_of file: output_pdf
|
66
|
+
end
|
53
67
|
end
|
54
68
|
end
|
55
69
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::MdfeLib::Header do
|
4
|
+
let(:qr_code_mdfe) do
|
5
|
+
url = 'https://dfe-portal.svrs.rs.gov.br/mdfe/QRCode?chMDFe=32210717781119000141580010000001211000000003&tpAmb=1'
|
6
|
+
"<qrCodMDFe>#{url}</qrCodMDFe>"
|
7
|
+
end
|
4
8
|
let(:xml_as_string) do
|
5
9
|
<<~XML
|
6
10
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -32,19 +36,14 @@ describe BrDanfe::MdfeLib::Header do
|
|
32
36
|
</emit>
|
33
37
|
</infMDFe>
|
34
38
|
<infMDFeSupl>
|
35
|
-
|
39
|
+
#{qr_code_mdfe}
|
36
40
|
</infMDFeSupl>
|
37
41
|
</MDFe>
|
38
42
|
</mdfeProc>
|
39
43
|
XML
|
40
44
|
end
|
41
|
-
|
42
45
|
let(:pdf) { BrDanfe::MdfeLib::Document.new }
|
43
46
|
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
44
|
-
|
45
|
-
let(:base_dir) { './spec/fixtures/mdfe/lib/' }
|
46
|
-
let(:output_pdf) { "#{base_dir}output.pdf" }
|
47
|
-
|
48
47
|
let(:logo_dimensions) { { width: 100, height: 100 } }
|
49
48
|
let(:logo) { 'spec/fixtures/logo.png' }
|
50
49
|
|
@@ -54,9 +53,12 @@ describe BrDanfe::MdfeLib::Header do
|
|
54
53
|
PDF::Inspector::Text.analyze(pdf.render).strings.join("\n")
|
55
54
|
end
|
56
55
|
|
57
|
-
after { File.delete(output_pdf) if File.exist?(output_pdf) }
|
58
|
-
|
59
56
|
describe '#generate' do
|
57
|
+
let(:base_dir) { './spec/fixtures/mdfe/lib/' }
|
58
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
59
|
+
|
60
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
61
|
+
|
60
62
|
it 'generates the emitter informations' do
|
61
63
|
emitter_name = 'VENTURIM AGROCRIATIVA LTDA EPP'
|
62
64
|
emitter_address = "RODOVIA ES 473 KM 13, nº 0\nVENDA NOVA DO IMIGRANTE - ES CEP 29.375-000"
|
@@ -72,15 +74,12 @@ describe BrDanfe::MdfeLib::Header do
|
|
72
74
|
expect(pdf_text).to include emitter_ie
|
73
75
|
end
|
74
76
|
|
75
|
-
it'generates the DAMDFE title' do
|
76
|
-
title = "DAMDFE\n - Documento Auxiliar de Manifesto Eletrônico de Documentos Fiscais"
|
77
|
-
|
77
|
+
it 'generates the DAMDFE title' do
|
78
78
|
subject.generate
|
79
|
-
|
80
|
-
expect(pdf_text).to include title
|
79
|
+
expect(pdf_text).to include "DAMDFE\n - Documento Auxiliar de Manifesto Eletrônico de Documentos Fiscais"
|
81
80
|
end
|
82
81
|
|
83
|
-
it 'generates the
|
82
|
+
it 'generates the QR-code' do
|
84
83
|
expect(File.exist?(output_pdf)).to be false
|
85
84
|
|
86
85
|
subject.generate
|
@@ -89,12 +88,22 @@ describe BrDanfe::MdfeLib::Header do
|
|
89
88
|
expect("#{base_dir}header#render-qr-code.pdf").to have_same_content_of file: output_pdf
|
90
89
|
end
|
91
90
|
|
92
|
-
|
93
|
-
|
91
|
+
context 'if the QR-code URL is not present' do
|
92
|
+
let(:qr_code_mdfe) { '<qrCodMDFe></qrCodMDFe>' }
|
94
93
|
|
95
|
-
|
94
|
+
it 'does not generates the QR-code' do
|
95
|
+
expect(File.exist?(output_pdf)).to be false
|
96
|
+
|
97
|
+
subject.generate
|
98
|
+
pdf.render_file output_pdf
|
99
|
+
|
100
|
+
expect("#{base_dir}header#render-without-qr-code.pdf").to have_same_content_of file: output_pdf
|
101
|
+
end
|
102
|
+
end
|
96
103
|
|
97
|
-
|
104
|
+
it 'generates the company CNPJ' do
|
105
|
+
subject.generate
|
106
|
+
expect(pdf_text).to include "CNPJ: \n17781119000141"
|
98
107
|
end
|
99
108
|
|
100
109
|
describe 'logo' do
|
@@ -22,9 +22,6 @@ describe BrDanfe::MdfeLib::Notes do
|
|
22
22
|
XML
|
23
23
|
end
|
24
24
|
|
25
|
-
let(:base_dir) { './spec/fixtures/mdfe/lib/' }
|
26
|
-
let(:output_pdf) { "#{base_dir}output.pdf" }
|
27
|
-
|
28
25
|
let(:pdf) { BrDanfe::MdfeLib::Document.new }
|
29
26
|
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
30
27
|
|
@@ -37,6 +34,11 @@ describe BrDanfe::MdfeLib::Notes do
|
|
37
34
|
before { pdf.move_cursor_to 345 }
|
38
35
|
|
39
36
|
describe '#generate' do
|
37
|
+
let(:base_dir) { './spec/fixtures/mdfe/lib/' }
|
38
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
39
|
+
|
40
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
41
|
+
|
40
42
|
it 'generates the title' do
|
41
43
|
title = 'Observações'
|
42
44
|
|
@@ -76,8 +78,6 @@ describe BrDanfe::MdfeLib::Notes do
|
|
76
78
|
expect(pdf_text).not_to include taxpayer_information
|
77
79
|
end
|
78
80
|
|
79
|
-
after { File.delete(output_pdf) if File.exist?(output_pdf) }
|
80
|
-
|
81
81
|
it 'creates a new page if aditional information do not fit on first page' do
|
82
82
|
expect(File.exist?(output_pdf)).to be false
|
83
83
|
|
data/spec/br_danfe/mdfe_spec.rb
CHANGED
@@ -4,12 +4,11 @@ describe BrDanfe::Mdfe do
|
|
4
4
|
let(:base_dir) { './spec/fixtures/mdfe/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
|
-
let(:
|
8
|
-
|
9
|
-
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
7
|
+
let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe.xml') }
|
10
8
|
|
11
9
|
subject { described_class.new(xml) }
|
12
|
-
|
10
|
+
|
11
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
13
12
|
|
14
13
|
before do
|
15
14
|
subject.logo_options.logo_dimensions = { width: 100, height: 100 }
|
@@ -34,7 +33,7 @@ describe BrDanfe::Mdfe do
|
|
34
33
|
end
|
35
34
|
|
36
35
|
context 'when MDF-e has multiple pages' do
|
37
|
-
let(:
|
36
|
+
let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe-multiples-pages.xml') }
|
38
37
|
|
39
38
|
it 'renders the header and the identification on each page' do
|
40
39
|
expect(File.exist?(output_pdf)).to be false
|
@@ -11,23 +11,14 @@ describe BrDanfe::QrCode do
|
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
|
-
let(:
|
15
|
-
|
16
|
-
<infNFeSupl>
|
17
|
-
<qrCode><![CDATA[http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?p=13130901144012000152651231234567891123456786|2|2|1|A604FD51E40ED8465B787B3E9CF8C1D90E61DB13]]></qrCode>
|
18
|
-
<urlChave>www.sefaz.am.gov.br/nfce/consulta</urlChave>
|
19
|
-
</infNFeSupl>
|
20
|
-
eos
|
21
|
-
|
22
|
-
BrDanfe::XML.new(xml)
|
14
|
+
let(:qr_code_url) do
|
15
|
+
'http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?p=13130901144012000152651231234567891123456786|2|2|1|A604FD51E40ED8465B787B3E9CF8C1D90E61DB13'
|
23
16
|
end
|
24
17
|
|
25
|
-
subject { described_class.new(pdf: pdf,
|
18
|
+
subject { described_class.new(pdf: pdf, qr_code_tag: qr_code_url, box_size: 3.cm) }
|
26
19
|
|
27
20
|
describe '#render' do
|
28
|
-
before
|
29
|
-
File.delete(output_pdf) if File.exist?(output_pdf)
|
30
|
-
end
|
21
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
31
22
|
|
32
23
|
it 'renders qr-code to the pdf' do
|
33
24
|
expect(File.exist?(output_pdf)).to be_falsey
|
data/spec/br_danfe/xml_spec.rb
CHANGED
@@ -6,12 +6,12 @@ describe BrDanfe::XML do
|
|
6
6
|
describe '#version_is_310_or_newer?' do
|
7
7
|
describe "when xml's version is equal 3.10" do
|
8
8
|
let(:xml_as_string) do
|
9
|
-
|
9
|
+
<<~XML
|
10
10
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
11
11
|
<infNFe versao="3.10" Id="NFe35150162013294000143550010000000011000000017">
|
12
12
|
</infNFe>
|
13
13
|
</NFe>
|
14
|
-
|
14
|
+
XML
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'returns true' do
|
@@ -21,12 +21,12 @@ describe BrDanfe::XML do
|
|
21
21
|
|
22
22
|
describe "when xml's version is greather 3.10" do
|
23
23
|
let(:xml_as_string) do
|
24
|
-
|
24
|
+
<<~XML
|
25
25
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
26
26
|
<infNFe versao="4.00" Id="NFe35150162013294000143550010000000011000000017">
|
27
27
|
</infNFe>
|
28
28
|
</NFe>
|
29
|
-
|
29
|
+
XML
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'returns true' do
|
@@ -36,12 +36,12 @@ describe BrDanfe::XML do
|
|
36
36
|
|
37
37
|
describe "when xml's version is minor that 3.10" do
|
38
38
|
let(:xml_as_string) do
|
39
|
-
|
39
|
+
<<~XML
|
40
40
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
41
41
|
<infNFe versao="2.00" Id="NFe35131260891033000109550010000000011000000016">
|
42
42
|
</infNFe>
|
43
43
|
</NFe>
|
44
|
-
|
44
|
+
XML
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'returns false' do
|
Binary file
|
Binary file
|
@@ -13,20 +13,18 @@ endobj
|
|
13
13
|
3 0 obj
|
14
14
|
<< /Type /Pages
|
15
15
|
/Count 2
|
16
|
-
/Kids [5 0 R
|
16
|
+
/Kids [5 0 R 7 0 R]
|
17
17
|
>>
|
18
18
|
endobj
|
19
19
|
4 0 obj
|
20
|
-
<< /Length
|
20
|
+
<< /Length 38
|
21
21
|
>>
|
22
22
|
stream
|
23
23
|
q
|
24
24
|
0.3 w
|
25
25
|
|
26
26
|
BT
|
27
|
-
8.50394 38.
|
28
|
-
/F1.0 6 Tf
|
29
|
-
<> Tj
|
27
|
+
8.50394 38.36169 Td
|
30
28
|
ET
|
31
29
|
|
32
30
|
Q
|
@@ -43,19 +41,11 @@ endobj
|
|
43
41
|
/ArtBox [0 0 226.77165 51.02362]
|
44
42
|
/Contents 4 0 R
|
45
43
|
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
46
|
-
/Font <<
|
47
|
-
>>
|
44
|
+
/Font << >>
|
48
45
|
>>
|
49
46
|
>>
|
50
47
|
endobj
|
51
48
|
6 0 obj
|
52
|
-
<< /Type /Font
|
53
|
-
/Subtype /Type1
|
54
|
-
/BaseFont /Courier
|
55
|
-
/Encoding /WinAnsiEncoding
|
56
|
-
>>
|
57
|
-
endobj
|
58
|
-
7 0 obj
|
59
49
|
<< /Length 10
|
60
50
|
>>
|
61
51
|
stream
|
@@ -65,7 +55,7 @@ Q
|
|
65
55
|
|
66
56
|
endstream
|
67
57
|
endobj
|
68
|
-
|
58
|
+
7 0 obj
|
69
59
|
<< /Type /Page
|
70
60
|
/Parent 3 0 R
|
71
61
|
/MediaBox [0 0 226.77165 51.02362]
|
@@ -73,27 +63,26 @@ endobj
|
|
73
63
|
/BleedBox [0 0 226.77165 51.02362]
|
74
64
|
/TrimBox [0 0 226.77165 51.02362]
|
75
65
|
/ArtBox [0 0 226.77165 51.02362]
|
76
|
-
/Contents
|
66
|
+
/Contents 6 0 R
|
77
67
|
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
78
68
|
>>
|
79
69
|
>>
|
80
70
|
endobj
|
81
71
|
xref
|
82
|
-
0
|
72
|
+
0 8
|
83
73
|
0000000000 65535 f
|
84
74
|
0000000015 00000 n
|
85
75
|
0000000109 00000 n
|
86
76
|
0000000158 00000 n
|
87
77
|
0000000221 00000 n
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
0000000802 00000 n
|
78
|
+
0000000309 00000 n
|
79
|
+
0000000618 00000 n
|
80
|
+
0000000678 00000 n
|
92
81
|
trailer
|
93
|
-
<< /Size
|
82
|
+
<< /Size 8
|
94
83
|
/Root 2 0 R
|
95
84
|
/Info 1 0 R
|
96
85
|
>>
|
97
86
|
startxref
|
98
|
-
|
87
|
+
975
|
99
88
|
%%EOF
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -64,7 +64,7 @@
|
|
64
64
|
<prod>
|
65
65
|
<cProd>1173</cProd>
|
66
66
|
<cEAN>568754456745</cEAN>
|
67
|
-
<xProd>Abraçadeira with a larger name
|
67
|
+
<xProd>Abraçadeira de metal with a larger name truncated</xProd>
|
68
68
|
<NCM>01022990</NCM>
|
69
69
|
<CFOP>5101</CFOP>
|
70
70
|
<uCom>UN</uCom>
|
@@ -150,7 +150,7 @@
|
|
150
150
|
<prod>
|
151
151
|
<cProd>1173</cProd>
|
152
152
|
<cEAN>568754456745</cEAN>
|
153
|
-
<xProd>Abraçadeira with a larger name
|
153
|
+
<xProd>Abraçadeira de metal with a larger name truncated</xProd>
|
154
154
|
<NCM>01022990</NCM>
|
155
155
|
<CFOP>5101</CFOP>
|
156
156
|
<uCom>UN</uCom>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|