br_danfe 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/br_danfe.gemspec +3 -1
- data/circle.yml +5 -0
- data/config/locales/pt-BR.yml +4 -3
- data/lib/br_danfe/danfe.rb +2 -2
- data/lib/br_danfe/dest.rb +12 -22
- data/lib/br_danfe/det_header.rb +1 -2
- data/lib/br_danfe/document.rb +34 -9
- data/lib/br_danfe/emit.rb +8 -18
- data/lib/br_danfe/issqn.rb +3 -3
- data/lib/br_danfe/ticket.rb +10 -5
- data/lib/br_danfe/transp.rb +17 -4
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe/xprod.rb +4 -4
- data/lib/br_danfe.rb +1 -0
- data/spec/features/br_danfe_spec.rb +2 -19
- data/spec/fixtures/lib/dest#render-with_cnpj.pdf +201 -0
- data/spec/fixtures/lib/dest#render-with_cpf.pdf +201 -0
- data/spec/fixtures/lib/dest#render-with_ie.pdf +208 -0
- data/spec/fixtures/lib/det_body#render-csosn.pdf +855 -0
- data/spec/fixtures/lib/det_body#render-cst.pdf +512 -0
- data/spec/fixtures/lib/det_body#render-fci.pdf +260 -0
- data/spec/fixtures/lib/det_body#render-icms_st.pdf +267 -0
- data/spec/fixtures/lib/det_header#render.pdf +207 -0
- data/spec/fixtures/lib/document#lcnpj-blank.pdf +74 -0
- data/spec/fixtures/lib/document#lcnpj-invalid.pdf +74 -0
- data/spec/fixtures/lib/document#lcnpj-valid.pdf +81 -0
- data/spec/fixtures/lib/document#lie-blank.pdf +74 -0
- data/spec/fixtures/lib/document#lie-invalid.pdf +74 -0
- data/spec/fixtures/lib/document#lie-valid.pdf +81 -0
- data/spec/fixtures/lib/dup#render.pdf +216 -0
- data/spec/fixtures/lib/emit#render.pdf +143 -0
- data/spec/fixtures/lib/emit_header#render-with_logo.pdf +712 -0
- data/spec/fixtures/lib/emit_header#render-without_logo.pdf +650 -0
- data/spec/fixtures/lib/icmstot#render.pdf +255 -0
- data/spec/fixtures/lib/infadic#render-extra_volume.pdf +295 -0
- data/spec/fixtures/lib/infadic#render.pdf +104 -0
- data/spec/fixtures/lib/issqn#render.pdf +143 -0
- data/spec/fixtures/lib/ticket#render.pdf +113 -0
- data/spec/fixtures/lib/transp#render.pdf +239 -0
- data/spec/fixtures/lib/vol#render.pdf +152 -0
- data/spec/fixtures/{v2.00/nfe_with_logo.xml.logo.png → logo.png} +0 -0
- data/spec/fixtures/v2.00/nfe_simples_nacional.xml.fixture.pdf +14 -14
- data/spec/fixtures/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +29 -43
- data/spec/fixtures/v2.00/nfe_with_fci.xml.fixture.pdf +12 -12
- data/spec/fixtures/v2.00/nfe_with_logo.xml.fixture.pdf +16 -16
- data/spec/fixtures/v2.00/nfe_with_ns.xml.fixture.pdf +29 -43
- data/spec/fixtures/v2.00/nfe_without_ns.xml.fixture.pdf +13 -27
- data/spec/fixtures/v3.10/nfe_simples_nacional.xml.fixture.pdf +23 -23
- data/spec/lib/dest_spec.rb +69 -0
- data/spec/lib/det_body_spec.rb +299 -0
- data/spec/lib/det_header_spec.rb +26 -0
- data/spec/lib/document_spec.rb +172 -0
- data/spec/lib/dup_spec.rb +52 -0
- data/spec/lib/emit_header_spec.rb +76 -0
- data/spec/lib/emit_spec.rb +54 -0
- data/spec/lib/icmstot_spec.rb +48 -0
- data/spec/lib/infadic_spec.rb +81 -0
- data/spec/lib/issqn_spec.rb +45 -0
- data/spec/lib/ticket_spec.rb +42 -0
- data/spec/lib/transp_spec.rb +51 -0
- data/spec/lib/vol_spec.rb +65 -0
- data/spec/lib/xprod_spec.rb +2 -2
- metadata +96 -12
- data/spec/fixtures/v2.00/nfe_with_cpf.xml +0 -1
- data/spec/fixtures/v2.00/nfe_with_cpf.xml.fixture.pdf +0 -1871
@@ -0,0 +1,172 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Document do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
8
|
+
|
9
|
+
describe "#lie" do
|
10
|
+
before do
|
11
|
+
subject.render
|
12
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when IE is valid" do
|
16
|
+
let(:xml_as_string) do
|
17
|
+
<<-eos
|
18
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
19
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
20
|
+
<transp>
|
21
|
+
<transporta>
|
22
|
+
<IE>964508990089</IE>
|
23
|
+
<UF>SP</UF>
|
24
|
+
</transporta>
|
25
|
+
</transp>
|
26
|
+
</infNFe>
|
27
|
+
</NFe>
|
28
|
+
eos
|
29
|
+
end
|
30
|
+
|
31
|
+
it "renders a box with a formated IE to the pdf" do
|
32
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
33
|
+
|
34
|
+
subject.lie 0.80, 3.94, 1, 1, xml, "transporta/UF", "transporta/IE"
|
35
|
+
subject.render_file output_pdf
|
36
|
+
|
37
|
+
expect("#{base_dir}document#lie-valid.pdf").to be_same_file_as(output_pdf)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when IE is invalid" do
|
42
|
+
let(:xml_as_string) do
|
43
|
+
<<-eos
|
44
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
45
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
46
|
+
<transp>
|
47
|
+
<transporta>
|
48
|
+
<IE>123</IE>
|
49
|
+
<UF>SC</UF>
|
50
|
+
</transporta>
|
51
|
+
</transp>
|
52
|
+
</infNFe>
|
53
|
+
</NFe>
|
54
|
+
eos
|
55
|
+
end
|
56
|
+
|
57
|
+
it "renders a blank box to the pdf" do
|
58
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
59
|
+
|
60
|
+
subject.lie 0.80, 3.94, 1, 1, xml, "transporta/UF", "transporta/IE"
|
61
|
+
subject.render_file output_pdf
|
62
|
+
|
63
|
+
expect("#{base_dir}document#lie-invalid.pdf").to be_same_file_as(output_pdf)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when IE is blank" do
|
68
|
+
let(:xml_as_string) do
|
69
|
+
<<-eos
|
70
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
71
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
72
|
+
<transp>
|
73
|
+
<transporta>
|
74
|
+
</transporta>
|
75
|
+
</transp>
|
76
|
+
</infNFe>
|
77
|
+
</NFe>
|
78
|
+
eos
|
79
|
+
end
|
80
|
+
|
81
|
+
it "renders a blank box to the pdf" do
|
82
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
83
|
+
|
84
|
+
subject.lie 0.80, 3.94, 1, 1, xml, "transporta/UF", "transporta/IE"
|
85
|
+
subject.render_file output_pdf
|
86
|
+
|
87
|
+
expect("#{base_dir}document#lie-blank.pdf").to be_same_file_as(output_pdf)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "#lcnpj" do
|
93
|
+
before do
|
94
|
+
subject.render
|
95
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
96
|
+
end
|
97
|
+
|
98
|
+
context "when CNPJ is valid" do
|
99
|
+
let(:xml_as_string) do
|
100
|
+
<<-eos
|
101
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
102
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
103
|
+
<transp>
|
104
|
+
<transporta>
|
105
|
+
<CNPJ>71434064000149</CNPJ>
|
106
|
+
</transporta>
|
107
|
+
</transp>
|
108
|
+
</infNFe>
|
109
|
+
</NFe>
|
110
|
+
eos
|
111
|
+
end
|
112
|
+
|
113
|
+
it "renders a box with a formated CNPJ to the pdf" do
|
114
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
115
|
+
|
116
|
+
subject.lcnpj 0.80, 3.94, 1, 1, xml, "transporta/CNPJ"
|
117
|
+
subject.render_file output_pdf
|
118
|
+
|
119
|
+
expect("#{base_dir}document#lcnpj-valid.pdf").to be_same_file_as(output_pdf)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "when CNPJ is invalid" do
|
124
|
+
let(:xml_as_string) do
|
125
|
+
<<-eos
|
126
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
127
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
128
|
+
<transp>
|
129
|
+
<transporta>
|
130
|
+
<CNPJ>714</CNPJ>
|
131
|
+
</transporta>
|
132
|
+
</transp>
|
133
|
+
</infNFe>
|
134
|
+
</NFe>
|
135
|
+
eos
|
136
|
+
end
|
137
|
+
|
138
|
+
it "renders a blank box to the pdf" do
|
139
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
140
|
+
|
141
|
+
subject.lcnpj 0.80, 3.94, 1, 1, xml, "transporta/CNPJ"
|
142
|
+
subject.render_file output_pdf
|
143
|
+
|
144
|
+
expect("#{base_dir}document#lcnpj-invalid.pdf").to be_same_file_as(output_pdf)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "when CNPJ is blank" do
|
149
|
+
let(:xml_as_string) do
|
150
|
+
<<-eos
|
151
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
152
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
153
|
+
<transp>
|
154
|
+
<transporta>
|
155
|
+
</transporta>
|
156
|
+
</transp>
|
157
|
+
</infNFe>
|
158
|
+
</NFe>
|
159
|
+
eos
|
160
|
+
end
|
161
|
+
|
162
|
+
it "renders a blank box to the pdf" do
|
163
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
164
|
+
|
165
|
+
subject.lcnpj 0.80, 3.94, 1, 1, xml, "transporta/CNPJ"
|
166
|
+
subject.render_file output_pdf
|
167
|
+
|
168
|
+
expect("#{base_dir}document#lcnpj-blank.pdf").to be_same_file_as(output_pdf)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Dup do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
16
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
17
|
+
<cobr>
|
18
|
+
<dup>
|
19
|
+
<nDup>1</nDup>
|
20
|
+
<dVenc>2015-02-13</dVenc>
|
21
|
+
<vDup>25.56</vDup>
|
22
|
+
</dup>
|
23
|
+
<dup>
|
24
|
+
<nDup>2</nDup>
|
25
|
+
<dVenc>2015-03-15</dVenc>
|
26
|
+
<vDup>25.56</vDup>
|
27
|
+
</dup>
|
28
|
+
<dup>
|
29
|
+
<nDup>3</nDup>
|
30
|
+
<dVenc>2015-04-14</dVenc>
|
31
|
+
<vDup>25.55</vDup>
|
32
|
+
</dup>
|
33
|
+
</cobr>
|
34
|
+
</infNFe>
|
35
|
+
</NFe>
|
36
|
+
eos
|
37
|
+
end
|
38
|
+
|
39
|
+
before do
|
40
|
+
subject.render
|
41
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "renders xml to the pdf" do
|
45
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
46
|
+
|
47
|
+
pdf.render_file output_pdf
|
48
|
+
|
49
|
+
expect("#{base_dir}dup#render.pdf").to be_same_file_as(output_pdf)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::EmitHeader do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
describe "#render" do
|
11
|
+
let(:xml_as_string) do
|
12
|
+
<<-eos
|
13
|
+
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
|
14
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
15
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
16
|
+
<ide>
|
17
|
+
<tpNF>1</tpNF>
|
18
|
+
<nNF>1</nNF>
|
19
|
+
<serie>1</serie>
|
20
|
+
</ide>
|
21
|
+
<emit>
|
22
|
+
<xNome>Nome do Remetente Ltda</xNome>
|
23
|
+
<enderEmit>
|
24
|
+
<xLgr>Rua do Remetente, Casa</xLgr>
|
25
|
+
<nro>123</nro>
|
26
|
+
<xBairro>Bairro do Remetente</xBairro>
|
27
|
+
<xMun>SAO PAULO</xMun>
|
28
|
+
<UF>SP</UF>
|
29
|
+
<CEP>12345678</CEP>
|
30
|
+
<fone>1112345678</fone>
|
31
|
+
<email>foo@bar.com</email>
|
32
|
+
</enderEmit>
|
33
|
+
</emit>
|
34
|
+
</infNFe>
|
35
|
+
</NFe>
|
36
|
+
<protNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
|
37
|
+
<infProt Id="ID325110012866320">
|
38
|
+
<chNFe>25111012345678901234550020000134151000134151</chNFe>
|
39
|
+
</infProt>
|
40
|
+
</protNFe>
|
41
|
+
</nfeProc>
|
42
|
+
eos
|
43
|
+
end
|
44
|
+
|
45
|
+
before do
|
46
|
+
subject.render
|
47
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
48
|
+
end
|
49
|
+
|
50
|
+
context "without logo" do
|
51
|
+
subject { described_class.new(pdf, xml, "") }
|
52
|
+
|
53
|
+
it "renders xml to the pdf" do
|
54
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
55
|
+
|
56
|
+
pdf.render_file output_pdf
|
57
|
+
|
58
|
+
expect("#{base_dir}emit_header#render-without_logo.pdf").to be_same_file_as(output_pdf)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "with logo" do
|
63
|
+
let(:logo_path) { "spec/fixtures/logo.png" }
|
64
|
+
|
65
|
+
subject { described_class.new(pdf, xml, logo_path) }
|
66
|
+
|
67
|
+
it "renders xml to the pdf" do
|
68
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
69
|
+
|
70
|
+
pdf.render_file output_pdf
|
71
|
+
|
72
|
+
expect("#{base_dir}emit_header#render-with_logo.pdf").to be_same_file_as(output_pdf)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Emit do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
|
16
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
17
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
18
|
+
<ide>
|
19
|
+
<natOp>Vendas de producao do estabelecimento</natOp>
|
20
|
+
</ide>
|
21
|
+
<emit>
|
22
|
+
<CNPJ>62013294000143</CNPJ>
|
23
|
+
<enderEmit>
|
24
|
+
<UF>SP</UF>
|
25
|
+
</enderEmit>
|
26
|
+
<IE>526926313553</IE>
|
27
|
+
<IE_ST>611724092039</IE_ST>
|
28
|
+
</emit>
|
29
|
+
</infNFe>
|
30
|
+
</NFe>
|
31
|
+
<protNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
|
32
|
+
<infProt Id="ID325110012866320">
|
33
|
+
<dhRecbto>2011-10-29T14:37:09</dhRecbto>
|
34
|
+
<nProt>325110012866320</nProt>
|
35
|
+
</infProt>
|
36
|
+
</protNFe>
|
37
|
+
</nfeProc>
|
38
|
+
eos
|
39
|
+
end
|
40
|
+
|
41
|
+
before do
|
42
|
+
subject.render
|
43
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "renders xml to the pdf" do
|
47
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
48
|
+
|
49
|
+
pdf.render_file output_pdf
|
50
|
+
|
51
|
+
expect("#{base_dir}emit#render.pdf").to be_same_file_as(output_pdf)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Icmstot do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
16
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
17
|
+
<ICMSTot>
|
18
|
+
<vBC>1.23</vBC>
|
19
|
+
<vICMS>2.34</vICMS>
|
20
|
+
<vBCST>3.45</vBCST>
|
21
|
+
<vST>4.56</vST>
|
22
|
+
<vProd>5.67</vProd>
|
23
|
+
<vFrete>6.78</vFrete>
|
24
|
+
<vSeg>7.89</vSeg>
|
25
|
+
<vDesc>9.01</vDesc>
|
26
|
+
<vIPI>0.12</vIPI>
|
27
|
+
<vOutro>1.34</vOutro>
|
28
|
+
<vNF>4.35</vNF>
|
29
|
+
</ICMSTot>
|
30
|
+
</infNFe>
|
31
|
+
</NFe>
|
32
|
+
eos
|
33
|
+
end
|
34
|
+
|
35
|
+
before do
|
36
|
+
subject.render
|
37
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "renders xml to the pdf" do
|
41
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
42
|
+
|
43
|
+
pdf.render_file output_pdf
|
44
|
+
|
45
|
+
expect("#{base_dir}icmstot#render.pdf").to be_same_file_as(output_pdf)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Infadic do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
16
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
17
|
+
<transp>
|
18
|
+
<vol>
|
19
|
+
<qVol>1</qVol>
|
20
|
+
<esp>VOLUMES 1</esp>
|
21
|
+
<marca>DIVERSOS 1</marca>
|
22
|
+
<nVol>1</nVol>
|
23
|
+
<pesoL>1000.000</pesoL>
|
24
|
+
<pesoB>1100.000</pesoB>
|
25
|
+
</vol>
|
26
|
+
<vol>
|
27
|
+
<qVol>2</qVol>
|
28
|
+
<esp>VOLUMES 2</esp>
|
29
|
+
<marca>DIVERSOS 2</marca>
|
30
|
+
<nVol>2</nVol>
|
31
|
+
<pesoL>2000.000</pesoL>
|
32
|
+
<pesoB>2200.000</pesoB>
|
33
|
+
</vol>
|
34
|
+
<vol>
|
35
|
+
<qVol>3</qVol>
|
36
|
+
<esp>VOLUMES 3</esp>
|
37
|
+
<marca>DIVERSOS 3</marca>
|
38
|
+
<nVol>3</nVol>
|
39
|
+
<pesoL>3000.000</pesoL>
|
40
|
+
<pesoB>3300.000</pesoB>
|
41
|
+
</vol>
|
42
|
+
</transp>
|
43
|
+
<infAdic>
|
44
|
+
<infCpl>Uma observação</infCpl>
|
45
|
+
</infAdic>
|
46
|
+
</infNFe>
|
47
|
+
</NFe>
|
48
|
+
eos
|
49
|
+
end
|
50
|
+
|
51
|
+
context "without extra volume" do
|
52
|
+
before do
|
53
|
+
subject.render(1)
|
54
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "renders xml to the pdf" do
|
58
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
59
|
+
|
60
|
+
pdf.render_file output_pdf
|
61
|
+
|
62
|
+
expect("#{base_dir}infadic#render.pdf").to be_same_file_as(output_pdf)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "with extra volume" do
|
67
|
+
before do
|
68
|
+
subject.render(3)
|
69
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "renders xml to the pdf" do
|
73
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
74
|
+
|
75
|
+
pdf.render_file output_pdf
|
76
|
+
|
77
|
+
expect("#{base_dir}infadic#render-extra_volume.pdf").to be_same_file_as(output_pdf)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Issqn do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
16
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
17
|
+
<emit>
|
18
|
+
<IM>2345</IM>
|
19
|
+
</emit>
|
20
|
+
<total>
|
21
|
+
<ISSQNtot>
|
22
|
+
<vServ>1.43</vServ>
|
23
|
+
<vBC>2.34</vBC>
|
24
|
+
<vISS>3.45</vISS>
|
25
|
+
</ISSQNtot>
|
26
|
+
</total>
|
27
|
+
</infNFe>
|
28
|
+
</NFe>
|
29
|
+
eos
|
30
|
+
end
|
31
|
+
|
32
|
+
before do
|
33
|
+
subject.render
|
34
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "renders xml 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}issqn#render.pdf").to be_same_file_as(output_pdf)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Ticket do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
16
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
17
|
+
<ide>
|
18
|
+
<nNF>1</nNF>
|
19
|
+
<serie>1</serie>
|
20
|
+
</ide>
|
21
|
+
<emit>
|
22
|
+
<xNome>Nome do Remetente Ltda</xNome>
|
23
|
+
</emit>
|
24
|
+
</infNFe>
|
25
|
+
</NFe>
|
26
|
+
eos
|
27
|
+
end
|
28
|
+
|
29
|
+
before do
|
30
|
+
subject.render
|
31
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "renders xml to the pdf" do
|
35
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
36
|
+
|
37
|
+
pdf.render_file output_pdf
|
38
|
+
|
39
|
+
expect("#{base_dir}ticket#render.pdf").to be_same_file_as(output_pdf)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Transp do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
16
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
17
|
+
<transp>
|
18
|
+
<modFrete>0</modFrete>
|
19
|
+
<transporta>
|
20
|
+
<CNPJ>71434064000149</CNPJ>
|
21
|
+
<xNome>Nome do Transportador Ltda</xNome>
|
22
|
+
<IE>964508990089</IE>
|
23
|
+
<xEnder>Rua do Transportador, 456</xEnder>
|
24
|
+
<xMun>Votorantim</xMun>
|
25
|
+
<UF>SP</UF>
|
26
|
+
</transporta>
|
27
|
+
<veicTransp>
|
28
|
+
<placa>ABC-1234</placa>
|
29
|
+
<UF>SP</UF>
|
30
|
+
<RNTC>123456</RNTC>
|
31
|
+
</veicTransp>
|
32
|
+
</transp>
|
33
|
+
</infNFe>
|
34
|
+
</NFe>
|
35
|
+
eos
|
36
|
+
end
|
37
|
+
|
38
|
+
before do
|
39
|
+
subject.render
|
40
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "renders xml to the pdf" do
|
44
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
45
|
+
|
46
|
+
pdf.render_file output_pdf
|
47
|
+
|
48
|
+
expect("#{base_dir}transp#render.pdf").to be_same_file_as(output_pdf)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe BrDanfe::Vol do
|
4
|
+
let(:base_dir) { "./spec/fixtures/lib/"}
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
|
+
|
7
|
+
let(:pdf) { BrDanfe::Document.new }
|
8
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
9
|
+
|
10
|
+
subject { described_class.new(pdf, xml) }
|
11
|
+
|
12
|
+
describe "#render" do
|
13
|
+
let(:xml_as_string) do
|
14
|
+
<<-eos
|
15
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
16
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
17
|
+
<transp>
|
18
|
+
<vol>
|
19
|
+
<qVol>1</qVol>
|
20
|
+
<esp>VOLUMES 1</esp>
|
21
|
+
<marca>DIVERSOS 1</marca>
|
22
|
+
<nVol>1</nVol>
|
23
|
+
<pesoL>1000.000</pesoL>
|
24
|
+
<pesoB>1100.000</pesoB>
|
25
|
+
</vol>
|
26
|
+
<vol>
|
27
|
+
<qVol>2</qVol>
|
28
|
+
<esp>VOLUMES 2</esp>
|
29
|
+
<marca>DIVERSOS 2</marca>
|
30
|
+
<nVol>2</nVol>
|
31
|
+
<pesoL>2000.000</pesoL>
|
32
|
+
<pesoB>2200.000</pesoB>
|
33
|
+
</vol>
|
34
|
+
<vol>
|
35
|
+
<qVol>3</qVol>
|
36
|
+
<esp>VOLUMES 3</esp>
|
37
|
+
<marca>DIVERSOS 3</marca>
|
38
|
+
<nVol>3</nVol>
|
39
|
+
<pesoL>3000.000</pesoL>
|
40
|
+
<pesoB>3300.000</pesoB>
|
41
|
+
</vol>
|
42
|
+
</transp>
|
43
|
+
</infNFe>
|
44
|
+
</NFe>
|
45
|
+
eos
|
46
|
+
end
|
47
|
+
|
48
|
+
before do
|
49
|
+
subject.render
|
50
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "renders xml to the pdf" do
|
54
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
55
|
+
|
56
|
+
pdf.render_file output_pdf
|
57
|
+
|
58
|
+
expect("#{base_dir}vol#render.pdf").to be_same_file_as(output_pdf)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "returns the quantity of volumes" do
|
62
|
+
expect(subject.render).to eq 3
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|