br_danfe 0.11.2 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/Gemfile.lock +31 -31
- data/br_danfe.gemspec +6 -5
- data/config/locales/pt-BR.yml +8 -0
- data/lib/br_danfe/danfe.rb +2 -2
- data/lib/br_danfe/danfe_lib/det_body.rb +1 -1
- data/lib/br_danfe/danfe_lib/document.rb +1 -1
- data/lib/br_danfe/danfe_lib/emit_header.rb +2 -2
- data/lib/br_danfe/danfe_lib/helper.rb +1 -27
- data/lib/br_danfe/danfe_lib/infadic.rb +1 -1
- data/lib/br_danfe/danfe_lib/xprod.rb +15 -15
- data/lib/br_danfe/danfe_nfce.rb +43 -0
- data/lib/br_danfe/danfe_nfce_lib/document.rb +35 -0
- data/lib/br_danfe/danfe_nfce_lib/footer.rb +15 -0
- data/lib/br_danfe/danfe_nfce_lib/header.rb +67 -0
- data/lib/br_danfe/danfe_nfce_lib/helper.rb +9 -0
- data/lib/br_danfe/danfe_nfce_lib/key.rb +18 -0
- data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +20 -0
- data/lib/br_danfe/danfe_nfce_lib/product_list.rb +100 -0
- data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +23 -0
- data/lib/br_danfe/danfe_nfce_lib/recipient.rb +72 -0
- data/lib/br_danfe/danfe_nfce_lib/total_list.rb +78 -0
- data/lib/br_danfe/helper.rb +29 -0
- data/lib/br_danfe/{danfe_lib/options.rb → logo_config.rb} +2 -2
- data/lib/br_danfe/{danfe_lib/logo_options.rb → logo_options.rb} +2 -2
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe/xml.rb +36 -0
- data/spec/features/danfe_nfce_spec.rb +31 -0
- data/spec/fixtures/nfce/lib/document#render.pdf +99 -0
- data/spec/fixtures/nfce/lib/footer#render.pdf +74 -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 +118 -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 +118 -0
- data/spec/fixtures/nfce/lib/key#render.pdf +104 -0
- data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +118 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +307 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +335 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +181 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +195 -0
- data/spec/fixtures/nfce/lib/product_list_with_many_products.xml +367 -0
- data/spec/fixtures/nfce/lib/product_list_with_many_products_and_long_names.xml +367 -0
- data/spec/fixtures/nfce/lib/product_list_with_single_product.xml +238 -0
- data/spec/fixtures/nfce/lib/product_list_with_single_product_and_long_name.xml +238 -0
- data/spec/fixtures/nfce/lib/qr_code#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-company.pdf +95 -0
- data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +88 -0
- data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +95 -0
- data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +95 -0
- data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +81 -0
- data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +139 -0
- data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +188 -0
- data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +139 -0
- data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +202 -0
- data/spec/fixtures/nfce/lib/total_list#render.pdf +202 -0
- data/spec/fixtures/nfce/v4.00/nfce.xml +367 -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/lib/danfe_lib/dest_spec.rb +1 -1
- data/spec/lib/danfe_lib/det_body_spec.rb +1 -1
- data/spec/lib/danfe_lib/document_spec.rb +1 -1
- data/spec/lib/danfe_lib/dup_spec.rb +1 -1
- data/spec/lib/danfe_lib/emit_header_spec.rb +1 -1
- data/spec/lib/danfe_lib/helper_spec.rb +0 -54
- data/spec/lib/danfe_lib/icmstot_spec.rb +1 -1
- data/spec/lib/danfe_lib/infadic_spec.rb +1 -1
- data/spec/lib/danfe_lib/infadic_vol_spec.rb +1 -1
- data/spec/lib/danfe_lib/issqn_spec.rb +1 -1
- data/spec/lib/danfe_lib/ticket_spec.rb +1 -1
- data/spec/lib/danfe_lib/transp_spec.rb +1 -1
- data/spec/lib/danfe_lib/vol_spec.rb +1 -1
- data/spec/lib/danfe_nfce_lib/document_spec.rb +19 -0
- data/spec/lib/danfe_nfce_lib/footer_spec.rb +42 -0
- data/spec/lib/danfe_nfce_lib/header_spec.rb +117 -0
- data/spec/lib/danfe_nfce_lib/helper_spec.rb +28 -0
- data/spec/lib/danfe_nfce_lib/key_spec.rb +45 -0
- data/spec/lib/danfe_nfce_lib/nfce_identification_spec.rb +48 -0
- data/spec/lib/danfe_nfce_lib/product_list_spec.rb +66 -0
- data/spec/lib/danfe_nfce_lib/qr_code_spec.rb +35 -0
- data/spec/lib/danfe_nfce_lib/recipient_spec.rb +163 -0
- data/spec/lib/danfe_nfce_lib/total_list_spec.rb +188 -0
- data/spec/lib/helper_spec.rb +102 -0
- data/spec/lib/logo_config_spec.rb +21 -0
- data/spec/lib/{danfe_lib/logo_options_spec.rb → logo_options_spec.rb} +8 -22
- data/spec/lib/{danfe_lib/xml_spec.rb → xml_spec.rb} +2 -2
- metadata +87 -18
- data/lib/br_danfe/danfe_lib/xml.rb +0 -38
- data/spec/lib/danfe_lib/options_spec.rb +0 -17
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::Icmstot do
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
8
|
-
let(:xml) { BrDanfe::
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::Infadic do
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
8
|
-
let(:xml) { BrDanfe::
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
@@ -4,7 +4,7 @@ describe BrDanfe::DanfeLib::InfadicVol do
|
|
4
4
|
let(:base_dir) { './spec/fixtures/nfe/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
7
|
-
let(:xml) { BrDanfe::
|
7
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
8
8
|
subject { described_class.new(xml, pdf) }
|
9
9
|
|
10
10
|
describe '#render' do
|
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::Issqn do
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
8
|
-
let(:xml) { BrDanfe::
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::Ticket do
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
8
|
-
let(:xml) { BrDanfe::
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::Transp do
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
8
|
-
let(:xml) { BrDanfe::
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::Vol do
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
8
|
-
let(:xml) { BrDanfe::
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
9
|
|
10
10
|
subject { described_class.new(pdf, xml) }
|
11
11
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::ProductList do
|
4
|
+
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:subject) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 1.8.cm) }
|
8
|
+
|
9
|
+
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
10
|
+
|
11
|
+
it 'render the document with blank lines' do
|
12
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
13
|
+
|
14
|
+
2.times { subject.render_blank_line }
|
15
|
+
subject.render_file output_pdf
|
16
|
+
|
17
|
+
expect("#{base_dir}document#render.pdf").to have_same_content_of file: output_pdf
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::Footer do
|
4
|
+
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 5.cm) }
|
8
|
+
|
9
|
+
let(:xml_footer) do
|
10
|
+
xml = <<-eos
|
11
|
+
<nfeProc>
|
12
|
+
<NFe>
|
13
|
+
<infNFe>
|
14
|
+
<total>
|
15
|
+
<ICMSTot>
|
16
|
+
<vTotTrib>7.50</vTotTrib>
|
17
|
+
</ICMSTot>
|
18
|
+
</total>
|
19
|
+
</infNFe>
|
20
|
+
</NFe>
|
21
|
+
</nfeProc>
|
22
|
+
eos
|
23
|
+
|
24
|
+
BrDanfe::XML.new(xml)
|
25
|
+
end
|
26
|
+
|
27
|
+
subject { described_class.new pdf, xml_footer }
|
28
|
+
|
29
|
+
describe '#render' do
|
30
|
+
before do
|
31
|
+
subject.render
|
32
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'renders footer to the pdf' do
|
36
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
37
|
+
pdf.render_file output_pdf
|
38
|
+
|
39
|
+
expect("#{base_dir}footer#render.pdf").to have_same_content_of file: output_pdf
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::Header do
|
4
|
+
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
let(:logo) { './spec/fixtures/logo.png' }
|
7
|
+
let(:logo_options) { { width: 100, height: 100 } }
|
8
|
+
let(:environment) { 1 }
|
9
|
+
|
10
|
+
let(:xml) do
|
11
|
+
xml = <<-eos
|
12
|
+
<nfeProc>
|
13
|
+
<NFe>
|
14
|
+
<infNFe>
|
15
|
+
<ide>
|
16
|
+
<tpAmb>#{environment}</tpAmb>
|
17
|
+
</ide>
|
18
|
+
<emit>
|
19
|
+
<CNPJ>10845180000166</CNPJ>
|
20
|
+
<xNome>#{company_name}</xNome>
|
21
|
+
<xFant>Empresa teste</xFant>
|
22
|
+
<enderEmit>
|
23
|
+
<xLgr>R GEREMIAS EUGENIO DA SILVA</xLgr>
|
24
|
+
<nro>85</nro>
|
25
|
+
<xBairro>SERRARIA</xBairro>
|
26
|
+
<cMun>4202859</cMun>
|
27
|
+
<xMun>BRACO DO TROMBUDO</xMun>
|
28
|
+
<UF>SC</UF>
|
29
|
+
<CEP>88113160</CEP>
|
30
|
+
<cPais>1058</cPais>
|
31
|
+
<xPais>Brasil</xPais>
|
32
|
+
<fone>4832579854</fone>
|
33
|
+
</enderEmit>
|
34
|
+
<IE>255916191</IE>
|
35
|
+
<CRT>1</CRT>
|
36
|
+
</emit>
|
37
|
+
</infNFe>
|
38
|
+
</NFe>
|
39
|
+
</nfeProc>
|
40
|
+
eos
|
41
|
+
|
42
|
+
BrDanfe::XML.new(xml)
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:pdf) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 5.cm) }
|
46
|
+
|
47
|
+
subject { described_class.new pdf, xml, logo, logo_options }
|
48
|
+
|
49
|
+
describe '#render' do
|
50
|
+
before do
|
51
|
+
subject.render
|
52
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when has a short name' do
|
56
|
+
let(:company_name) { 'Test company' }
|
57
|
+
|
58
|
+
context 'when has a logo' do
|
59
|
+
it 'renders header to the pdf' do
|
60
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
61
|
+
pdf.render_file output_pdf
|
62
|
+
|
63
|
+
expect("#{base_dir}header#render-short_name_with_logo.pdf").to have_same_content_of file: output_pdf
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when does not have a logo' do
|
68
|
+
let(:logo) { nil }
|
69
|
+
let(:logo_options) { nil }
|
70
|
+
|
71
|
+
it 'renders header to the pdf' do
|
72
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
73
|
+
pdf.render_file output_pdf
|
74
|
+
|
75
|
+
expect("#{base_dir}header#render-short_name_without_logo.pdf").to have_same_content_of file: output_pdf
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when has a long name' do
|
81
|
+
let(:company_name) { 'Test company with some very long name to do a line break' }
|
82
|
+
|
83
|
+
context 'when has a logo' do
|
84
|
+
it 'renders the header with company name line breaked' do
|
85
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
86
|
+
pdf.render_file output_pdf
|
87
|
+
|
88
|
+
expect("#{base_dir}header#render-long_name_with_logo.pdf").to have_same_content_of file: output_pdf
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when does not have a logo' do
|
93
|
+
let(:logo) { nil }
|
94
|
+
let(:logo_options) { nil }
|
95
|
+
|
96
|
+
it 'renders header to the pdf' do
|
97
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
98
|
+
pdf.render_file output_pdf
|
99
|
+
|
100
|
+
expect("#{base_dir}header#render-long_name_without_logo.pdf").to have_same_content_of file: output_pdf
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when the environment is homologation' do
|
106
|
+
let(:environment) { 2 }
|
107
|
+
let(:company_name) { 'Homologation example' }
|
108
|
+
|
109
|
+
it 'renders homologation label' do
|
110
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
111
|
+
pdf.render_file output_pdf
|
112
|
+
|
113
|
+
expect("#{base_dir}header#render-homologation.pdf").to have_same_content_of file: output_pdf
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::Helper do
|
4
|
+
let(:xml) do
|
5
|
+
xml = <<-eos
|
6
|
+
<enderDest>
|
7
|
+
<xLgr>Rua Tijucas</xLgr>
|
8
|
+
<nro>99</nro>
|
9
|
+
<xCpl>dwdwa</xCpl>
|
10
|
+
<xBairro>Centro</xBairro>
|
11
|
+
<cMun>4218004</cMun>
|
12
|
+
<xMun>TIJUCAS</xMun>
|
13
|
+
<UF>SC</UF>
|
14
|
+
<CEP>88200000</CEP>
|
15
|
+
<cPais>1058</cPais>
|
16
|
+
<xPais>Brasil</xPais>
|
17
|
+
</enderDest>
|
18
|
+
eos
|
19
|
+
|
20
|
+
BrDanfe::XML.new(xml)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#address' do
|
24
|
+
it 'returns a formated address string' do
|
25
|
+
expect(described_class.address(xml)).to eql 'Rua Tijucas, 99, Centro, TIJUCAS - SC'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::Key do
|
4
|
+
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:xml_key) do
|
8
|
+
xml = <<-eos
|
9
|
+
<nfeProc>
|
10
|
+
<NFe>
|
11
|
+
<infNFeSupl>
|
12
|
+
<qrCode><![CDATA[http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?p=13130901144012000152651231234567891123456786|2|2|1|A604FD51E40ED8465B787B3E9CF8C1D90E61DB13]]></qrCode>
|
13
|
+
<urlChave>www.sefaz.am.gov.br/nfce/consulta</urlChave>
|
14
|
+
</infNFeSupl>
|
15
|
+
</NFe>
|
16
|
+
<protNFe versao="4.00">
|
17
|
+
<infProt>
|
18
|
+
<chNFe>42200310845180000166550010000016291182910232</chNFe>
|
19
|
+
</infProt>
|
20
|
+
</protNFe>
|
21
|
+
</nfeProc>
|
22
|
+
eos
|
23
|
+
|
24
|
+
BrDanfe::XML.new(xml)
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:pdf) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 5.cm) }
|
28
|
+
|
29
|
+
subject { described_class.new pdf, xml_key }
|
30
|
+
|
31
|
+
describe '#render' do
|
32
|
+
before do
|
33
|
+
subject.render
|
34
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'renders key to the pdf' do
|
38
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
39
|
+
|
40
|
+
pdf.render_file output_pdf
|
41
|
+
|
42
|
+
expect("#{base_dir}key#render.pdf").to have_same_content_of file: output_pdf
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::NfceIdentification do
|
4
|
+
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 5.cm) }
|
8
|
+
|
9
|
+
let(:xml) do
|
10
|
+
xml = <<-eos
|
11
|
+
<nfeProc>
|
12
|
+
<NFe>
|
13
|
+
<infNFe>
|
14
|
+
<ide>
|
15
|
+
<dhEmi>2020-03-24T13:33:20-05:00</dhEmi>
|
16
|
+
<serie>1</serie>
|
17
|
+
<nNF>1629</nNF>
|
18
|
+
</ide>
|
19
|
+
<protNFe versao="4.00">
|
20
|
+
<infProt>
|
21
|
+
<nProt>342200000151784</nProt>
|
22
|
+
<dhRecbto>2020-03-24T15:36:14-03:00</dhRecbto>
|
23
|
+
</infProt>
|
24
|
+
</protNFe>
|
25
|
+
</infNFe>
|
26
|
+
</NFe>
|
27
|
+
</nfeProc>
|
28
|
+
eos
|
29
|
+
|
30
|
+
BrDanfe::XML.new(xml)
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { described_class.new pdf, xml }
|
34
|
+
|
35
|
+
describe '#render' do
|
36
|
+
before do
|
37
|
+
subject.render
|
38
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'renders nfce identification to the pdf' do
|
42
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
43
|
+
pdf.render_file output_pdf
|
44
|
+
|
45
|
+
expect("#{base_dir}nfce_identification#render.pdf").to have_same_content_of file: output_pdf
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::ProductList do
|
4
|
+
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}#{xml_name}.xml")) }
|
7
|
+
|
8
|
+
let(:pdf) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 5.cm) }
|
9
|
+
|
10
|
+
subject { described_class.new pdf, xml }
|
11
|
+
|
12
|
+
describe '#render' do
|
13
|
+
before do
|
14
|
+
subject.render
|
15
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when does not have a long name' do
|
19
|
+
describe 'when has a single product' do
|
20
|
+
let(:xml_name) { 'product_list_with_single_product' }
|
21
|
+
|
22
|
+
it 'renders product list with single product to the pdf' do
|
23
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
24
|
+
pdf.render_file output_pdf
|
25
|
+
|
26
|
+
expect("#{base_dir}product_list#render-with_single_product.pdf").to have_same_content_of file: output_pdf
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'when has many products' do
|
31
|
+
let(:xml_name) { 'product_list_with_many_products' }
|
32
|
+
|
33
|
+
it 'renders product list with many products to the pdf' do
|
34
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
35
|
+
pdf.render_file output_pdf
|
36
|
+
|
37
|
+
expect("#{base_dir}product_list#render-with_many_products.pdf").to have_same_content_of file: output_pdf
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when has a long name' do
|
43
|
+
describe 'when has a single product' do
|
44
|
+
let(:xml_name) { 'product_list_with_single_product_and_long_name' }
|
45
|
+
|
46
|
+
it 'renders product list with single product to the pdf' do
|
47
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
48
|
+
pdf.render_file output_pdf
|
49
|
+
|
50
|
+
expect("#{base_dir}product_list#render-with_single_product_and_long_name.pdf").to have_same_content_of file: output_pdf
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe 'when has many products' do
|
55
|
+
let(:xml_name) { 'product_list_with_many_products_and_long_names' }
|
56
|
+
|
57
|
+
it 'renders product list with many products to the pdf' do
|
58
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
59
|
+
pdf.render_file output_pdf
|
60
|
+
|
61
|
+
expect("#{base_dir}product_list#render-with_many_products_and_long_names.pdf").to have_same_content_of file: output_pdf
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeNfceLib::QrCode do
|
4
|
+
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::DanfeNfceLib::Document.new(8.cm, 5.cm) }
|
8
|
+
|
9
|
+
let(:xml) do
|
10
|
+
xml = <<-eos
|
11
|
+
<infNFeSupl>
|
12
|
+
<qrCode><![CDATA[http://sistemas.sefaz.am.gov.br/nfceweb/consultarNFCe.jsp?p=13130901144012000152651231234567891123456786|2|2|1|A604FD51E40ED8465B787B3E9CF8C1D90E61DB13]]></qrCode>
|
13
|
+
<urlChave>www.sefaz.am.gov.br/nfce/consulta</urlChave>
|
14
|
+
</infNFeSupl>
|
15
|
+
eos
|
16
|
+
|
17
|
+
BrDanfe::XML.new(xml)
|
18
|
+
end
|
19
|
+
|
20
|
+
subject { described_class.new pdf, xml }
|
21
|
+
|
22
|
+
describe '#render' do
|
23
|
+
before do
|
24
|
+
subject.render
|
25
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'renders qr-code to the pdf' do
|
29
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
30
|
+
pdf.render_file output_pdf
|
31
|
+
|
32
|
+
expect("#{base_dir}qr_code#render.pdf").to have_same_content_of file: output_pdf
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|