br_danfe 0.15.1 → 0.17.2
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/.tool-versions +1 -0
- data/Gemfile.lock +69 -50
- data/Guardfile +4 -2
- data/README.md +23 -0
- data/bin/_guard-core +29 -0
- data/bin/guard +29 -0
- data/br_danfe.gemspec +9 -7
- 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/dest.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -2
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +5 -6
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +2 -1
- data/lib/br_danfe/document_builder.rb +1 -1
- data/lib/br_danfe/helper.rb +8 -10
- data/lib/br_danfe/mdfe.rb +55 -0
- data/lib/br_danfe/mdfe_lib/authorization_protocol.rb +24 -0
- data/lib/br_danfe/mdfe_lib/document.rb +26 -0
- data/lib/br_danfe/mdfe_lib/drivers.rb +70 -0
- data/lib/br_danfe/mdfe_lib/fisco_control.rb +21 -0
- data/lib/br_danfe/mdfe_lib/header.rb +77 -0
- data/lib/br_danfe/mdfe_lib/mdfe_identification.rb +69 -0
- data/lib/br_danfe/mdfe_lib/notes.rb +94 -0
- data/lib/br_danfe/mdfe_lib/totalizer.rb +57 -0
- data/lib/br_danfe/mdfe_lib/vehicles.rb +80 -0
- data/lib/br_danfe/qr_code.rb +21 -0
- 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 +37 -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 +240 -240
- 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 +26 -14
- data/spec/br_danfe/mdfe_lib/authorization_protocol_spec.rb +35 -0
- data/spec/br_danfe/mdfe_lib/document_spec.rb +20 -0
- data/spec/br_danfe/mdfe_lib/drivers_spec.rb +88 -0
- data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +69 -0
- data/spec/br_danfe/mdfe_lib/header_spec.rb +135 -0
- data/spec/br_danfe/mdfe_lib/mdfe_identification_spec.rb +104 -0
- data/spec/br_danfe/mdfe_lib/notes_spec.rb +97 -0
- data/spec/br_danfe/mdfe_lib/totalizer_spec.rb +63 -0
- data/spec/br_danfe/mdfe_lib/vehicles_spec.rb +66 -0
- data/spec/br_danfe/mdfe_spec.rb +45 -0
- data/spec/br_danfe/qr_code_spec.rb +31 -0
- data/spec/br_danfe/xml_spec.rb +6 -6
- data/spec/fixtures/mdfe/lib/document#render.pdf +0 -0
- data/spec/fixtures/mdfe/lib/document#text.align.pdf +0 -0
- data/spec/fixtures/mdfe/lib/document#text.pad.pdf +0 -0
- data/spec/fixtures/mdfe/lib/document#text.simple.pdf +0 -0
- data/spec/fixtures/mdfe/lib/document#text.size.pdf +0 -0
- data/spec/fixtures/mdfe/lib/document#text.style.pdf +0 -0
- data/spec/fixtures/mdfe/lib/fisco_control#barcode.pdf +0 -0
- data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-qr-code.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-with_logo.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-without_logo.pdf +0 -0
- data/spec/fixtures/mdfe/lib/mdfe-with-multiple-pages.pdf +1945 -0
- data/spec/fixtures/mdfe/lib/mdfe.fixture.pdf +1286 -0
- data/spec/fixtures/mdfe/lib/notes#render-big-aditional-information.pdf +1943 -0
- data/spec/fixtures/mdfe/lib/xml-mdfe-multiples-pages.xml +116 -0
- data/spec/fixtures/mdfe/lib/xml-mdfe.xml +250 -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/qr_code/qr_code#render.pdf +0 -0
- data/spec/spec_helper.rb +1 -1
- metadata +118 -48
- data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +0 -25
- data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +0 -11
- data/spec/br_danfe/danfe_lib/nfce_lib/qr_code_spec.rb +0 -35
- data/spec/br_danfe/danfe_lib/nfe_lib/cep_spec.rb +0 -10
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::MdfeLib::Notes do
|
4
|
+
def xml_as_string(options = {})
|
5
|
+
params = {
|
6
|
+
infAdFisco: '<infAdFisco>EXEMPLO INFORMAÇÕES ADICIONAIS FISCO</infAdFisco>',
|
7
|
+
infCpl: '<infCpl>EXEMPLO INFORMAÇÕES ADICIONAIS CONTRIBUINTE</infCpl>'
|
8
|
+
}.merge(options)
|
9
|
+
|
10
|
+
<<~XML
|
11
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
12
|
+
<mdfeProc xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00">
|
13
|
+
<MDFe xmlns="http://www.portalfiscal.inf.br/mdfe">
|
14
|
+
<infMDFe Id="MDFe32210717781119000141580010000001211000000003" versao="3.00">
|
15
|
+
<infAdic>
|
16
|
+
#{params[:infAdFisco]}
|
17
|
+
#{params[:infCpl]}
|
18
|
+
</infAdic>
|
19
|
+
</infMDFe>
|
20
|
+
</MDFe>
|
21
|
+
</mdfeProc>
|
22
|
+
XML
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:pdf) { BrDanfe::MdfeLib::Document.new }
|
26
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
27
|
+
|
28
|
+
subject { described_class.new(pdf, xml) }
|
29
|
+
|
30
|
+
let(:pdf_text) do
|
31
|
+
PDF::Inspector::Text.analyze(pdf.render).strings.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
before { pdf.move_cursor_to 345 }
|
35
|
+
|
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
|
+
|
42
|
+
it 'generates the title' do
|
43
|
+
title = 'Observações'
|
44
|
+
|
45
|
+
subject.generate
|
46
|
+
expect(pdf_text).to include title
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'generates additional information for fisco when xml has content in infAdFisco tag' do
|
50
|
+
fisco_information = "INFORMAÇÕES ADICIONAIS DE INTERESSE DO FISCO\nEXEMPLO INFORMAÇÕES ADICIONAIS FISCO"
|
51
|
+
|
52
|
+
subject.generate
|
53
|
+
expect(pdf_text).to include fisco_information
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'does not generate the additional information for fisco when xml does not have content in infAdFisco tag' do
|
57
|
+
fisco_information = "INFORMAÇÕES ADICIONAIS DE INTERESSE DO FISCO\n"
|
58
|
+
|
59
|
+
xml = BrDanfe::XML.new(xml_as_string(infAdFisco: '', infCpl: ''))
|
60
|
+
subject = described_class.new(pdf, xml)
|
61
|
+
subject.generate
|
62
|
+
expect(pdf_text).not_to include fisco_information
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'generates the additional information for taxpayer when xml has content in infCpl tag' do
|
66
|
+
taxpayer_information = "INFORMAÇÕES ADICIONAIS DE INTERESSE DO CONTRIBUINTE\nEXEMPLO INFORMAÇÕES ADICIONAIS CONTRIBUINTE"
|
67
|
+
|
68
|
+
subject.generate
|
69
|
+
expect(pdf_text).to include taxpayer_information
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'does not generate the additional information for taxpayer when xml does not have content in infCpl tag' do
|
73
|
+
taxpayer_information = "INFORMAÇÕES ADICIONAIS DE INTERESSE DO CONTRIBUINTE\n"
|
74
|
+
|
75
|
+
xml = BrDanfe::XML.new(xml_as_string(infAdFisco: '', infCpl: ''))
|
76
|
+
subject = described_class.new(pdf, xml)
|
77
|
+
subject.generate
|
78
|
+
expect(pdf_text).not_to include taxpayer_information
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'creates a new page if aditional information do not fit on first page' do
|
82
|
+
expect(File.exist?(output_pdf)).to be false
|
83
|
+
|
84
|
+
xml = BrDanfe::XML.new(
|
85
|
+
xml_as_string(
|
86
|
+
infAdFisco: "<infAdFisco>#{'alguma coisa ' * 153}</infAdFisco>",
|
87
|
+
infCpl: "<infCpl>#{'alguma coisa ' * 2000}<infCpl>"
|
88
|
+
)
|
89
|
+
)
|
90
|
+
subject = described_class.new(pdf, xml)
|
91
|
+
subject.generate
|
92
|
+
pdf.render_file output_pdf
|
93
|
+
|
94
|
+
expect("#{base_dir}notes#render-big-aditional-information.pdf").to have_same_content_of file: output_pdf
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::MdfeLib::Totalizer do
|
4
|
+
let(:xml_as_string) do
|
5
|
+
<<~XML
|
6
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
7
|
+
<mdfeProc xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00">
|
8
|
+
<MDFe xmlns="http://www.portalfiscal.inf.br/mdfe">
|
9
|
+
<infMDFe Id="MDFe32210717781119000141580010000001211000000003" versao="3.00">
|
10
|
+
<tot>
|
11
|
+
<qNFe>10</qNFe>
|
12
|
+
<vCarga>8222.10</vCarga>
|
13
|
+
<cUnid>01</cUnid>
|
14
|
+
<qCarga>615.1400</qCarga>
|
15
|
+
</tot>
|
16
|
+
</infMDFe>
|
17
|
+
</MDFe>
|
18
|
+
</mdfeProc>
|
19
|
+
XML
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:pdf) { BrDanfe::MdfeLib::Document.new }
|
23
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
24
|
+
|
25
|
+
let(:base_dir) { './spec/fixtures/mdfe/lib/' }
|
26
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
27
|
+
|
28
|
+
subject { described_class.new(pdf, xml) }
|
29
|
+
|
30
|
+
let(:pdf_text) do
|
31
|
+
PDF::Inspector::Text.analyze(pdf.render).strings.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#generate' do
|
35
|
+
it 'generates the nfe quantity' do
|
36
|
+
nfe_quantity = "QTD. NFe\n10"
|
37
|
+
|
38
|
+
subject.generate
|
39
|
+
expect(pdf_text).to include nfe_quantity
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'generates only the box of cte quantity' do
|
43
|
+
cte_quantity = "QTD. CTe\n"
|
44
|
+
|
45
|
+
subject.generate
|
46
|
+
expect(pdf_text).to include cte_quantity
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'generates the total weight' do
|
50
|
+
total_weight = "Peso total (Kg)\n615,14"
|
51
|
+
|
52
|
+
subject.generate
|
53
|
+
expect(pdf_text).to include total_weight
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'generates the totalizer title' do
|
57
|
+
title = 'Modelo Rodoviário de Carga'
|
58
|
+
|
59
|
+
subject.generate
|
60
|
+
expect(pdf_text).to include title
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::MdfeLib::Vehicles do
|
4
|
+
let(:xml_as_string) do
|
5
|
+
<<~XML
|
6
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
7
|
+
<mdfeProc xmlns="http://www.portalfiscal.inf.br/mdfe" versao="3.00">
|
8
|
+
<MDFe xmlns="http://www.portalfiscal.inf.br/mdfe">
|
9
|
+
<infMDFe Id="MDFe32210717781119000141580010000001211000000003" versao="3.00">
|
10
|
+
<infModal versaoModal="3.00">
|
11
|
+
<rodo>
|
12
|
+
<infANTT/>
|
13
|
+
<veicTracao>
|
14
|
+
<placa>RQM8B64</placa>
|
15
|
+
</veicTracao>
|
16
|
+
<veicReboque>
|
17
|
+
<placa>RVA1B90</placa>
|
18
|
+
</veicReboque>
|
19
|
+
<veicReboque>
|
20
|
+
<placa>MCU9123</placa>
|
21
|
+
</veicReboque>
|
22
|
+
<veicReboque>
|
23
|
+
<placa>QIU1239</placa>
|
24
|
+
</veicReboque>
|
25
|
+
</rodo>
|
26
|
+
</infModal>
|
27
|
+
</infMDFe>
|
28
|
+
</MDFe>
|
29
|
+
</mdfeProc>
|
30
|
+
XML
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:pdf) { BrDanfe::MdfeLib::Document.new }
|
34
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
35
|
+
|
36
|
+
subject { described_class.new(pdf, xml) }
|
37
|
+
|
38
|
+
let(:pdf_text) { PDF::Inspector::Text.analyze(pdf.render).strings.join("\n") }
|
39
|
+
|
40
|
+
describe '#generate' do
|
41
|
+
it 'generates the title' do
|
42
|
+
title = 'Veículo'
|
43
|
+
|
44
|
+
subject.generate
|
45
|
+
expect(pdf_text).to include title
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'generates the title of table' do
|
49
|
+
plate = 'Placa'
|
50
|
+
rntrc = 'RNTR'
|
51
|
+
|
52
|
+
subject.generate
|
53
|
+
expect(pdf_text).to include plate, rntrc
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'generates the list of vehicles' do
|
57
|
+
vehicle1_plate = 'RQM8B64'
|
58
|
+
vehicle2_plate = 'RVA1B90'
|
59
|
+
vehicle3_plate = 'MCU9123'
|
60
|
+
vehicle4_plate = 'QIU1239'
|
61
|
+
|
62
|
+
subject.generate
|
63
|
+
expect(pdf_text).to include vehicle1_plate, vehicle2_plate, vehicle3_plate, vehicle4_plate
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::Mdfe do
|
4
|
+
let(:base_dir) { './spec/fixtures/mdfe/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe.xml') }
|
8
|
+
|
9
|
+
subject { described_class.new(xml) }
|
10
|
+
|
11
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
subject.logo_options.logo_dimensions = { width: 100, height: 100 }
|
15
|
+
subject.logo_options.logo = 'spec/fixtures/logo.png'
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#render_pdf' do
|
19
|
+
it 'renders the mdfe' do
|
20
|
+
expected = IO.binread("#{base_dir}mdfe.fixture.pdf")
|
21
|
+
|
22
|
+
expect(subject.render_pdf).to eql expected
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#save_pdf' do
|
27
|
+
it 'saves the mdfe' do
|
28
|
+
expect(File.exist?(output_pdf)).to be false
|
29
|
+
|
30
|
+
subject.save_pdf output_pdf
|
31
|
+
expect("#{base_dir}mdfe.fixture.pdf").to have_same_content_of file: output_pdf
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when MDF-e has multiple pages' do
|
36
|
+
let(:xml) { File.read('./spec/fixtures/mdfe/lib/xml-mdfe-multiples-pages.xml') }
|
37
|
+
|
38
|
+
it 'renders the header and the identification on each page' do
|
39
|
+
expect(File.exist?(output_pdf)).to be false
|
40
|
+
|
41
|
+
subject.save_pdf output_pdf
|
42
|
+
expect("#{base_dir}mdfe-with-multiple-pages.pdf").to have_same_content_of file: output_pdf
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::QrCode do
|
4
|
+
let(:base_dir) { './spec/fixtures/qr_code/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) do
|
8
|
+
BrDanfe::DocumentBuilder.build(
|
9
|
+
page_size: 'A4',
|
10
|
+
page_layout: :portrait
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:qr_code_url) do
|
15
|
+
'http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?p=13130901144012000152651231234567891123456786|2|2|1|A604FD51E40ED8465B787B3E9CF8C1D90E61DB13'
|
16
|
+
end
|
17
|
+
|
18
|
+
subject { described_class.new(pdf: pdf, qr_code_tag: qr_code_url, box_size: 3.cm) }
|
19
|
+
|
20
|
+
describe '#render' do
|
21
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
22
|
+
|
23
|
+
it 'renders qr-code to the pdf' do
|
24
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
25
|
+
subject.render
|
26
|
+
pdf.render_file output_pdf
|
27
|
+
|
28
|
+
expect("#{base_dir}qr_code#render.pdf").to have_same_content_of file: output_pdf
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
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
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|