br_danfe 0.10.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +4 -4
  3. data/config/locales/pt-BR.yml +0 -1
  4. data/lib/br_danfe/danfe_lib/infadic.rb +60 -91
  5. data/lib/br_danfe/danfe_lib/infadic_vol.rb +101 -0
  6. data/lib/br_danfe/version.rb +1 -1
  7. data/spec/features/danfe_spec.rb +2 -2
  8. data/spec/fixtures/nfe/lib/{infadic#render-extra_volume_difal.pdf → infadic#render-all_the_informations.pdf} +55 -55
  9. data/spec/fixtures/nfe/lib/infadic#render-difal.pdf +7 -21
  10. data/spec/fixtures/nfe/lib/infadic#render-extra_volume.pdf +43 -57
  11. data/spec/fixtures/nfe/lib/{infadic#render-footer_information.pdf → infadic#render-with_complementary_information.pdf} +6 -13
  12. data/spec/fixtures/nfe/lib/{infadic-with-street-data#render.pdf → infadic#render-with_fisco_additional_information.pdf} +7 -7
  13. data/spec/fixtures/nfe/lib/infadic#render-with_street_data.pdf +104 -0
  14. data/spec/fixtures/nfe/lib/infadic#render.pdf +5 -12
  15. data/spec/fixtures/nfe/lib/infadic_vol#render-extra_volume.pdf +331 -0
  16. data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +2 -2
  17. data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +2 -2
  18. data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +51 -51
  19. data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +2 -2
  20. data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +2 -2
  21. data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +3 -3
  22. data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +21 -21
  23. data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +23 -23
  24. data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +23 -23
  25. data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +25 -25
  26. data/spec/fixtures/nfe/v3.10/{withot_issqn.fixture.pdf → without_issqn.fixture.pdf} +23 -23
  27. data/spec/fixtures/nfe/v3.10/{withot_issqn.xml → without_issqn.xml} +0 -0
  28. data/spec/lib/danfe_lib/infadic_spec.rb +258 -97
  29. data/spec/lib/danfe_lib/infadic_vol_spec.rb +96 -0
  30. metadata +11 -7
@@ -1,7 +1,7 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe BrDanfe::DanfeLib::Infadic do
4
- let(:base_dir) { "./spec/fixtures/nfe/lib/" }
4
+ let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
5
  let(:output_pdf) { "#{base_dir}output.pdf" }
6
6
 
7
7
  let(:pdf) { BrDanfe::DanfeLib::Document.new }
@@ -9,9 +9,166 @@ describe BrDanfe::DanfeLib::Infadic do
9
9
 
10
10
  subject { described_class.new(pdf, xml) }
11
11
 
12
- describe "#render" do
13
- let(:xml_as_string) do
14
- <<-eos
12
+ describe '#render' do
13
+ let(:volumes_number) { 1 }
14
+
15
+ before do
16
+ subject.render(volumes_number)
17
+ File.delete(output_pdf) if File.exist?(output_pdf)
18
+ end
19
+
20
+ context 'when there is no information' do
21
+ let(:xml_as_string) do
22
+ <<-EOS
23
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
24
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
25
+ <transp>
26
+ <vol>
27
+ <qVol>1</qVol>
28
+ <esp>VOLUMES 1</esp>
29
+ <marca>DIVERSOS 1</marca>
30
+ <nVol>1</nVol>
31
+ <pesoL>1000.000</pesoL>
32
+ <pesoB>1100.000</pesoB>
33
+ </vol>
34
+ <vol>
35
+ <qVol>2</qVol>
36
+ <esp>VOLUMES 2</esp>
37
+ <marca>DIVERSOS 2</marca>
38
+ <nVol>2</nVol>
39
+ <pesoL>2000.000</pesoL>
40
+ <pesoB>2200.000</pesoB>
41
+ </vol>
42
+ <vol>
43
+ <qVol>3</qVol>
44
+ <esp>VOLUMES 3</esp>
45
+ <marca>DIVERSOS 3</marca>
46
+ <nVol>3</nVol>
47
+ <pesoL>3000.000</pesoL>
48
+ <pesoB>3300.000</pesoB>
49
+ </vol>
50
+ </transp>
51
+ <total>
52
+ <ICMSTot>
53
+ <vFCPUFDest>4892.78</vFCPUFDest>
54
+ <vICMSUFRemet>75394.78</vICMSUFRemet>
55
+ </ICMSTot>
56
+ </total>
57
+ </infNFe>
58
+ </NFe>
59
+ EOS
60
+ end
61
+
62
+ it 'renders title with box, subtitle and fisco box on the pdf' do
63
+ expect(File.exist?(output_pdf)).to be_falsey
64
+
65
+ pdf.render_file output_pdf
66
+
67
+ expect(
68
+ "#{base_dir}infadic#render.pdf"
69
+ ).to have_same_content_of file: output_pdf
70
+ end
71
+ end
72
+
73
+ context 'when has difal' do
74
+ let(:xml_as_string) do
75
+ <<-EOS
76
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
77
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
78
+ <transp>
79
+ <vol>
80
+ <qVol>1</qVol>
81
+ <esp>VOLUMES 1</esp>
82
+ <marca>DIVERSOS 1</marca>
83
+ <nVol>1</nVol>
84
+ <pesoL>1000.000</pesoL>
85
+ <pesoB>1100.000</pesoB>
86
+ </vol>
87
+ <vol>
88
+ <qVol>2</qVol>
89
+ <esp>VOLUMES 2</esp>
90
+ <marca>DIVERSOS 2</marca>
91
+ <nVol>2</nVol>
92
+ <pesoL>2000.000</pesoL>
93
+ <pesoB>2200.000</pesoB>
94
+ </vol>
95
+ <vol>
96
+ <qVol>3</qVol>
97
+ <esp>VOLUMES 3</esp>
98
+ <marca>DIVERSOS 3</marca>
99
+ <nVol>3</nVol>
100
+ <pesoL>3000.000</pesoL>
101
+ <pesoB>3300.000</pesoB>
102
+ </vol>
103
+ </transp>
104
+ <total>
105
+ <ICMSTot>
106
+ <vFCPUFDest>4892.78</vFCPUFDest>
107
+ <vICMSUFDest>2915.78</vICMSUFDest>
108
+ <vICMSUFRemet>75394.78</vICMSUFRemet>
109
+ </ICMSTot>
110
+ </total>
111
+ </infNFe>
112
+ </NFe>
113
+ EOS
114
+ end
115
+
116
+ it 'renders title with box, subtitle, fisco box and difal on the pdf' do
117
+ expect(File.exist?(output_pdf)).to be_falsey
118
+
119
+ pdf.render_file output_pdf
120
+
121
+ expect("#{base_dir}infadic#render-difal.pdf").to have_same_content_of file: output_pdf
122
+ end
123
+ end
124
+
125
+ context 'when has too big address' do
126
+ let(:xml_as_string) do
127
+ <<-EOS
128
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
129
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
130
+ <ide>
131
+ <dEmi>2011-10-29</dEmi>
132
+ <dSaiEnt>2011-10-30</dSaiEnt>
133
+ <hSaiEnt>15:32:45</hSaiEnt>
134
+ </ide>
135
+ <dest>
136
+ <CNPJ>82743287000880</CNPJ>
137
+ <xNome>Schneider Electric Brasil Ltda</xNome>
138
+ <enderDest>
139
+ <xLgr>Av da Saudade</xLgr>
140
+ <nro>1125</nro>
141
+ <xBairro>Frutal</xBairro>
142
+ <xCpl>Em anexo ao super mercado maior do bairro</xCpl>
143
+ <cMun>3552403</cMun>
144
+ <xMun>SUMARE</xMun>
145
+ <UF>SP</UF>
146
+ <CEP>13171320</CEP>
147
+ <cPais>1058</cPais>
148
+ <xPais>BRASIL</xPais>
149
+ <fone>1921046300</fone>
150
+ </enderDest>
151
+ <IE>671008375110</IE>
152
+ </dest>
153
+ </infNFe>
154
+ </NFe>
155
+ EOS
156
+ end
157
+
158
+ it 'renders title with box, subtitle, fisco box and address on the pdf' do
159
+ expect(File.exist?(output_pdf)).to be_falsey
160
+
161
+ pdf.render_file output_pdf
162
+
163
+ expect(
164
+ "#{base_dir}infadic#render-with_street_data.pdf"
165
+ ).to have_same_content_of file: output_pdf
166
+ end
167
+ end
168
+
169
+ context 'when has complementary information' do
170
+ let(:xml_as_string) do
171
+ <<-EOS
15
172
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
16
173
  <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
17
174
  <ide>
@@ -75,81 +232,45 @@ describe BrDanfe::DanfeLib::Infadic do
75
232
  </total>
76
233
  </infNFe>
77
234
  </NFe>
78
- eos
79
- end
80
-
81
- context "without extra volume" do
82
- before do
83
- subject.render(1)
84
- File.delete(output_pdf) if File.exist?(output_pdf)
235
+ EOS
85
236
  end
86
237
 
87
- it "renders xml to the pdf" do
238
+ it 'renders title with box, subtitle, fisco box and complementary ' \
239
+ 'information on the pdf' do
88
240
  expect(File.exist?(output_pdf)).to be_falsey
89
241
 
90
242
  pdf.render_file output_pdf
91
243
 
92
- expect("#{base_dir}infadic#render.pdf").to have_same_content_of file: output_pdf
244
+ expect(
245
+ "#{base_dir}infadic#render-with_complementary_information.pdf"
246
+ ).to have_same_content_of file: output_pdf
93
247
  end
248
+ end
94
249
 
95
- context "with difal" do
96
- let(:xml_as_string) do
97
- <<-eos
250
+ context 'when has additional fisco information' do
251
+ let(:xml_as_string) do
252
+ <<-EOS
98
253
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
99
254
  <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
100
- <transp>
101
- <vol>
102
- <qVol>1</qVol>
103
- <esp>VOLUMES 1</esp>
104
- <marca>DIVERSOS 1</marca>
105
- <nVol>1</nVol>
106
- <pesoL>1000.000</pesoL>
107
- <pesoB>1100.000</pesoB>
108
- </vol>
109
- <vol>
110
- <qVol>2</qVol>
111
- <esp>VOLUMES 2</esp>
112
- <marca>DIVERSOS 2</marca>
113
- <nVol>2</nVol>
114
- <pesoL>2000.000</pesoL>
115
- <pesoB>2200.000</pesoB>
116
- </vol>
117
- <vol>
118
- <qVol>3</qVol>
119
- <esp>VOLUMES 3</esp>
120
- <marca>DIVERSOS 3</marca>
121
- <nVol>3</nVol>
122
- <pesoL>3000.000</pesoL>
123
- <pesoB>3300.000</pesoB>
124
- </vol>
125
- </transp>
126
255
  <infAdic>
127
- <infCpl>Uma observação</infCpl>
256
+ <infAdFisco>Total de FCP-ST: 348,96</infAdFisco>
128
257
  </infAdic>
129
- <total>
130
- <ICMSTot>
131
- <vFCPUFDest>4892.78</vFCPUFDest>
132
- <vICMSUFDest>2915.78</vICMSUFDest>
133
- <vICMSUFRemet>75394.78</vICMSUFRemet>
134
- </ICMSTot>
135
- </total>
136
258
  </infNFe>
137
259
  </NFe>
138
- eos
139
- end
140
-
141
- it "renders xml to the pdf" do
142
- expect(File.exist?(output_pdf)).to be_falsey
260
+ EOS
261
+ end
143
262
 
144
- pdf.render_file output_pdf
263
+ it 'renders title with box, subtitle, fisco box and additional information about fisco on the pdf' do
264
+ expect(File.exist?(output_pdf)).to be_falsey
145
265
 
146
- expect("#{base_dir}infadic#render-difal.pdf").to have_same_content_of file: output_pdf
147
- end
266
+ pdf.render_file output_pdf
267
+ expect("#{base_dir}infadic#render-with_fisco_additional_information.pdf").to have_same_content_of file: output_pdf
148
268
  end
269
+ end
149
270
 
150
- context "with too big address" do
151
- let(:xml_as_string) do
152
- <<-eos
271
+ context 'when has extra volume' do
272
+ let(:xml_as_string) do
273
+ <<-EOS
153
274
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
154
275
  <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
155
276
  <ide>
@@ -164,7 +285,7 @@ describe BrDanfe::DanfeLib::Infadic do
164
285
  <xLgr>Av da Saudade</xLgr>
165
286
  <nro>1125</nro>
166
287
  <xBairro>Frutal</xBairro>
167
- <xCpl>Em anexo ao super mercado maior do bairro</xCpl>
288
+ <xCpl>Sala 01 e 02</xCpl>
168
289
  <cMun>3552403</cMun>
169
290
  <xMun>SUMARE</xMun>
170
291
  <UF>SP</UF>
@@ -175,43 +296,80 @@ describe BrDanfe::DanfeLib::Infadic do
175
296
  </enderDest>
176
297
  <IE>671008375110</IE>
177
298
  </dest>
178
- <infAdic>
179
- <infCpl>Uma observação</infCpl>
180
- </infAdic>
299
+ <transp>
300
+ <vol>
301
+ <qVol>1</qVol>
302
+ <esp>VOLUMES 1</esp>
303
+ <marca>DIVERSOS 1</marca>
304
+ <nVol>1</nVol>
305
+ <pesoL>1000.000</pesoL>
306
+ <pesoB>1100.000</pesoB>
307
+ </vol>
308
+ <vol>
309
+ <qVol>2</qVol>
310
+ <esp>VOLUMES 2</esp>
311
+ <marca>DIVERSOS 2</marca>
312
+ <nVol>2</nVol>
313
+ <pesoL>2000.000</pesoL>
314
+ <pesoB>2200.000</pesoB>
315
+ </vol>
316
+ <vol>
317
+ <qVol>3</qVol>
318
+ <esp>VOLUMES 3</esp>
319
+ <marca>DIVERSOS 3</marca>
320
+ <nVol>3</nVol>
321
+ <pesoL>3000.000</pesoL>
322
+ <pesoB>3300.000</pesoB>
323
+ </vol>
324
+ </transp>
325
+ <total>
326
+ <ICMSTot>
327
+ <vFCPUFDest>0.00</vFCPUFDest>
328
+ <vICMSUFDest>0.00</vICMSUFDest>
329
+ <vICMSUFRemet>0.00</vICMSUFRemet>
330
+ </ICMSTot>
331
+ </total>
181
332
  </infNFe>
182
333
  </NFe>
183
- eos
184
- end
185
-
186
- it "renders xml to the pdf with street on observation" do
187
- expect(File.exist?(output_pdf)).to be_falsey
188
-
189
- pdf.render_file output_pdf
190
-
191
- expect("#{base_dir}infadic-with-street-data#render.pdf").to have_same_content_of file: output_pdf
192
- end
334
+ EOS
193
335
  end
194
- end
336
+ let(:volumes_number) { 2 }
195
337
 
196
- context "with extra volume" do
197
- before do
198
- subject.render(3)
199
- File.delete(output_pdf) if File.exist?(output_pdf)
200
- end
201
-
202
- it "renders xml to the pdf" do
338
+ it 'renders title with box, subtitle, fisco box and extra volumes on the ' \
339
+ 'pdf' do
203
340
  expect(File.exist?(output_pdf)).to be_falsey
204
341
 
205
342
  pdf.render_file output_pdf
206
343
 
207
- expect("#{base_dir}infadic#render-extra_volume.pdf").to have_same_content_of file: output_pdf
344
+ expect(
345
+ "#{base_dir}infadic#render-extra_volume.pdf"
346
+ ).to have_same_content_of file: output_pdf
208
347
  end
348
+ end
209
349
 
210
- context "with difal" do
211
- let(:xml_as_string) do
212
- <<-eos
350
+ context 'when has all the informations' do
351
+ let(:xml_as_string) do
352
+ <<-EOS
213
353
  <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
214
354
  <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
355
+ <dest>
356
+ <CNPJ>82743287000880</CNPJ>
357
+ <xNome>Schneider Electric Brasil Ltda</xNome>
358
+ <enderDest>
359
+ <xLgr>Av da Saudade</xLgr>
360
+ <nro>1125</nro>
361
+ <xBairro>Frutal</xBairro>
362
+ <xCpl>Em anexo ao super mercado maior do bairro</xCpl>
363
+ <cMun>3552403</cMun>
364
+ <xMun>SUMARE</xMun>
365
+ <UF>SP</UF>
366
+ <CEP>13171320</CEP>
367
+ <cPais>1058</cPais>
368
+ <xPais>BRASIL</xPais>
369
+ <fone>1921046300</fone>
370
+ </enderDest>
371
+ <IE>671008375110</IE>
372
+ </dest>
215
373
  <transp>
216
374
  <vol>
217
375
  <qVol>1</qVol>
@@ -239,26 +397,29 @@ describe BrDanfe::DanfeLib::Infadic do
239
397
  </vol>
240
398
  </transp>
241
399
  <infAdic>
242
- <infCpl>Uma observação</infCpl>
400
+ <infCpl>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec congue in dolor sed sagittis.</infCpl>
401
+ <infAdFisco>Total de FCP-ST: 348,96</infAdFisco>
243
402
  </infAdic>
244
403
  <ICMSTot>
404
+ <vFCPST>348.96</vFCPST>
245
405
  <vFCPUFDest>4892.78</vFCPUFDest>
246
406
  <vICMSUFDest>2915.78</vICMSUFDest>
247
407
  <vICMSUFRemet>75394.78</vICMSUFRemet>
248
408
  </ICMSTot>
249
409
  </infNFe>
250
410
  </NFe>
251
- eos
252
- end
411
+ EOS
412
+ end
413
+ let(:volumes_number) { 3 }
253
414
 
254
- it "renders xml to the pdf" do
255
- expect(File.exist?(output_pdf)).to be_falsey
415
+ it 'renders title with box, subtitle, fisco box, extra volumes, ' \
416
+ 'complementary information, address and difal on the pdf' do
417
+ expect(File.exist?(output_pdf)).to be_falsey
256
418
 
257
- pdf.render_file output_pdf
419
+ pdf.render_file output_pdf
258
420
 
259
- expect("#{base_dir}infadic#render-extra_volume_difal.pdf").to have_same_content_of file: output_pdf
260
- end
421
+ expect("#{base_dir}infadic#render-all_the_informations.pdf").to have_same_content_of file: output_pdf
261
422
  end
262
423
  end
263
424
  end
264
- end
425
+ end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+
3
+ describe BrDanfe::DanfeLib::InfadicVol do
4
+ let(:base_dir) { './spec/fixtures/nfe/lib/' }
5
+ let(:output_pdf) { "#{base_dir}output.pdf" }
6
+ let(:pdf) { BrDanfe::DanfeLib::Document.new }
7
+ let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
8
+ subject { described_class.new(xml, pdf) }
9
+
10
+ describe '#render' do
11
+ let(:xml_as_string) do
12
+ <<-EOS
13
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
14
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
15
+ <dest>
16
+ <CNPJ>82743287000880</CNPJ>
17
+ <xNome>Schneider Electric Brasil Ltda</xNome>
18
+ <enderDest>
19
+ <xLgr>Av da Saudade</xLgr>
20
+ <nro>1125</nro>
21
+ <xBairro>Frutal</xBairro>
22
+ <xCpl>Em anexo ao super mercado maior do bairro</xCpl>
23
+ <cMun>3552403</cMun>
24
+ <xMun>SUMARE</xMun>
25
+ <UF>SP</UF>
26
+ <CEP>13171320</CEP>
27
+ <cPais>1058</cPais>
28
+ <xPais>BRASIL</xPais>
29
+ <fone>1921046300</fone>
30
+ </enderDest>
31
+ <IE>671008375110</IE>
32
+ </dest>
33
+ <transp>
34
+ <vol>
35
+ <qVol>1</qVol>
36
+ <esp>VOLUMES 1</esp>
37
+ <marca>DIVERSOS 1</marca>
38
+ <nVol>1</nVol>
39
+ <pesoL>1000.000</pesoL>
40
+ <pesoB>1100.000</pesoB>
41
+ </vol>
42
+ <vol>
43
+ <qVol>2</qVol>
44
+ <esp>VOLUMES 2</esp>
45
+ <marca>DIVERSOS 2</marca>
46
+ <nVol>2</nVol>
47
+ <pesoL>2000.000</pesoL>
48
+ <pesoB>2200.000</pesoB>
49
+ </vol>
50
+ <vol>
51
+ <qVol>3</qVol>
52
+ <esp>VOLUMES 3</esp>
53
+ <marca>DIVERSOS 3</marca>
54
+ <nVol>3</nVol>
55
+ <pesoL>3000.000</pesoL>
56
+ <pesoB>3300.000</pesoB>
57
+ </vol>
58
+ <vol>
59
+ <qVol>4</qVol>
60
+ <esp>VOLUMES 4</esp>
61
+ <marca>DIVERSOS 4</marca>
62
+ <nVol>4</nVol>
63
+ <pesoL>4000.000</pesoL>
64
+ <pesoB>4400.000</pesoB>
65
+ </vol>
66
+ </transp>
67
+ <infAdic>
68
+ <infCpl>Uma observação</infCpl>
69
+ </infAdic>
70
+ <ICMSTot>
71
+ <vFCPUFDest>4892.78</vFCPUFDest>
72
+ <vICMSUFDest>2915.78</vICMSUFDest>
73
+ <vICMSUFRemet>75394.78</vICMSUFRemet>
74
+ </ICMSTot>
75
+ </infNFe>
76
+ </NFe>
77
+ EOS
78
+ end
79
+
80
+ before do
81
+ subject.render
82
+ File.delete(output_pdf) if File.exist?(output_pdf)
83
+ end
84
+
85
+ it 'renders extra volumes to the pdf' do
86
+ expect(File.exist?(output_pdf)).to be_falsey
87
+
88
+ pdf.render_file output_pdf
89
+
90
+ expect(
91
+ "#{base_dir}infadic_vol#render-extra_volume.pdf"
92
+ ).to have_same_content_of file: output_pdf
93
+ end
94
+ end
95
+
96
+ end