br_danfe 0.17.1 → 0.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -6
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +13 -12
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +2 -2
- data/lib/br_danfe/version.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb +3 -1
- data/spec/br_danfe/danfe_lib/nfce_spec.rb +2 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +18 -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/v4.00/multiples_xmls_on_the_same_pdf.pdf +172 -172
- 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
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3d3b2150c3a402b60290cec03c5cf876a8c220c42abf91a6e9728950478e06e
|
4
|
+
data.tar.gz: 135046af062cb860b844b526425d8e18a6282bd7be87bb4a9cf3180dc05f0ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2da619a08cfd3f2af12021a2affc67c0672e82d8c371b8b6ec624dac17dfd3b42809aa353f5672185f92484a9c0fd1bff3b05c1fd6abf23f92441fb376450172
|
7
|
+
data.tar.gz: 232a65f8b1ec56f9639d185dc785ffae0160c5ccbd20ab77727a43b012d3cd58c8ad89b0861f20884b83ecf892ad1d112a17b9c1d308efea1c82acceed209d64
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
br_danfe (0.17.
|
4
|
+
br_danfe (0.17.4)
|
5
5
|
barby (= 0.6.8)
|
6
6
|
br_documents (>= 0.1.3)
|
7
7
|
i18n (>= 0.8.6)
|
@@ -25,13 +25,13 @@ GEM
|
|
25
25
|
afm (0.2.2)
|
26
26
|
ast (2.4.2)
|
27
27
|
barby (0.6.8)
|
28
|
-
br_documents (0.2.
|
28
|
+
br_documents (0.2.2)
|
29
29
|
activemodel (>= 4.0.0)
|
30
30
|
i18n (>= 0.6.5)
|
31
31
|
byebug (11.1.3)
|
32
32
|
chunky_png (1.4.0)
|
33
33
|
coderay (1.1.3)
|
34
|
-
concurrent-ruby (1.1.
|
34
|
+
concurrent-ruby (1.1.10)
|
35
35
|
diff-lcs (1.4.4)
|
36
36
|
docile (1.4.0)
|
37
37
|
ffi (1.15.3)
|
@@ -51,7 +51,7 @@ GEM
|
|
51
51
|
guard-compat (~> 1.1)
|
52
52
|
rspec (>= 2.99.0, < 4.0)
|
53
53
|
hashery (2.1.2)
|
54
|
-
i18n (1.
|
54
|
+
i18n (1.12.0)
|
55
55
|
concurrent-ruby (~> 1.0)
|
56
56
|
json (2.5.1)
|
57
57
|
listen (3.6.0)
|
@@ -59,9 +59,11 @@ GEM
|
|
59
59
|
rb-inotify (~> 0.9, >= 0.9.10)
|
60
60
|
lumberjack (1.2.8)
|
61
61
|
method_source (1.0.0)
|
62
|
+
mini_portile2 (2.7.1)
|
62
63
|
minitest (5.14.4)
|
63
64
|
nenv (0.3.0)
|
64
|
-
nokogiri (1.
|
65
|
+
nokogiri (1.13.1)
|
66
|
+
mini_portile2 (~> 2.7.0)
|
65
67
|
racc (~> 1.4)
|
66
68
|
notiffany (0.1.3)
|
67
69
|
nenv (~> 0.1)
|
@@ -138,7 +140,7 @@ GEM
|
|
138
140
|
simplecov-html (0.10.2)
|
139
141
|
thor (1.1.0)
|
140
142
|
ttfunk (1.7.0)
|
141
|
-
tzinfo (2.0.
|
143
|
+
tzinfo (2.0.5)
|
142
144
|
concurrent-ruby (~> 1.0)
|
143
145
|
unicode-display_width (1.8.0)
|
144
146
|
zeitwerk (2.5.1)
|
@@ -12,7 +12,7 @@ module BrDanfe
|
|
12
12
|
def render
|
13
13
|
cursor = @pdf.cursor
|
14
14
|
|
15
|
-
render_company_info
|
15
|
+
render_company_info
|
16
16
|
render_logo(cursor) if @logo.present?
|
17
17
|
render_doc
|
18
18
|
|
@@ -21,15 +21,18 @@ module BrDanfe
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
def render_company_info
|
24
|
+
def render_company_info
|
25
25
|
one_line = 1
|
26
26
|
|
27
|
-
@pdf.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
@pdf.text_box (@xml['emit/xNome']).to_s, at: [x_position, @pdf.cursor], height: 36, size: 9, align: :left, style: :bold, overflow: :shrink_to_fit
|
28
|
+
@pdf.move_down 36
|
29
|
+
|
30
|
+
@pdf.text_box cnpj(@xml['emit/CNPJ']), at: [x_position, @pdf.cursor], height: 9, size: 9, align: :left, overflow: :shrink_to_fit
|
31
|
+
@pdf.move_down 9
|
32
|
+
|
33
|
+
@pdf.text_box BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderEmit')), at: [x_position, @pdf.cursor], height: 20, size: 9, align: :left, overflow: :shrink_to_fit
|
34
|
+
@pdf.move_down 20
|
35
|
+
@pdf.render_blank_line if count_name_lines(@xml['emit/xNome']) == one_line
|
33
36
|
end
|
34
37
|
|
35
38
|
def x_position
|
@@ -60,9 +63,8 @@ module BrDanfe
|
|
60
63
|
|
61
64
|
def render_doc
|
62
65
|
@pdf.render_blank_line
|
63
|
-
cursor = @pdf.cursor
|
64
66
|
|
65
|
-
@pdf.bounding_box([0, cursor], width: 6.7.cm, height: 20) do
|
67
|
+
@pdf.bounding_box([0, @pdf.cursor], width: 6.7.cm, height: 20) do
|
66
68
|
@pdf.text 'Documento Auxiliar da Nota Fiscal de Consumidor Eletrônica', size: 9, align: :center
|
67
69
|
end
|
68
70
|
end
|
@@ -70,8 +72,7 @@ module BrDanfe
|
|
70
72
|
def render_homologation
|
71
73
|
2.times { @pdf.render_blank_line }
|
72
74
|
|
73
|
-
|
74
|
-
@pdf.bounding_box([0, cursor], width: 6.7.cm, height: 20) do
|
75
|
+
@pdf.bounding_box([0, @pdf.cursor], width: 6.7.cm, height: 20) do
|
75
76
|
@pdf.text 'EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO', size: 8, align: :center, style: :bold
|
76
77
|
@pdf.text 'SEM VALOR FISCAL', size: 8, align: :center, style: :bold
|
77
78
|
end
|
@@ -88,9 +88,9 @@ module BrDanfe
|
|
88
88
|
|
89
89
|
def access_key_box
|
90
90
|
@pdf.ibox 2.22, 10.02, 10.29, @y_position
|
91
|
-
@pdf.ibarcode 1.50, 8.00, 10.4010, @y_position + 1.90, @xml['chNFe']
|
91
|
+
@pdf.ibarcode 1.50, 8.00, 10.4010, @y_position + 1.90, @xml['infProt > chNFe']
|
92
92
|
@pdf.ibox 0.85, 10.02, 10.29, @y_position + 2.22, I18n.t('danfe.chNFe'),
|
93
|
-
@xml['chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '), style: :bold, align: :center
|
93
|
+
@xml['infProt > chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '), style: :bold, align: :center
|
94
94
|
end
|
95
95
|
|
96
96
|
def sefaz_box
|
data/lib/br_danfe/version.rb
CHANGED
@@ -52,6 +52,8 @@ describe BrDanfe::DanfeLib::NfceLib::Header do
|
|
52
52
|
File.delete(output_pdf) if File.exist?(output_pdf)
|
53
53
|
end
|
54
54
|
|
55
|
+
after { File.delete(output_pdf) if File.exist?(output_pdf) }
|
56
|
+
|
55
57
|
context 'when has a short name' do
|
56
58
|
let(:company_name) { 'Test company' }
|
57
59
|
|
@@ -81,7 +83,7 @@ describe BrDanfe::DanfeLib::NfceLib::Header do
|
|
81
83
|
let(:company_name) { 'Test company with some very long name to do a line break' }
|
82
84
|
|
83
85
|
context 'when has a logo' do
|
84
|
-
it 'renders the header with company name line breaked' do
|
86
|
+
it 'renders the header with company name line breaked and shrinked to fit' do
|
85
87
|
expect(File.exist?(output_pdf)).to be_falsey
|
86
88
|
pdf.render_file output_pdf
|
87
89
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Nfce do
|
4
|
-
let(:output_pdf) { "#{base_dir}output.pdf" }
|
5
4
|
let(:base_dir) { './spec/fixtures/nfce/v4.00/' }
|
5
|
+
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}nfce.xml")) }
|
7
7
|
|
8
8
|
subject { described_class.new [xml] }
|
@@ -15,6 +15,7 @@ describe BrDanfe::DanfeLib::Nfce do
|
|
15
15
|
describe '#render_pdf' do
|
16
16
|
it 'renders the NFC-e pdf' do
|
17
17
|
expected = IO.binread("#{base_dir}rendered_nfce.fixture.pdf")
|
18
|
+
|
18
19
|
expect(subject.render_pdf).to eq expected
|
19
20
|
end
|
20
21
|
end
|
@@ -38,6 +38,15 @@ describe BrDanfe::DanfeLib::NfeLib::EmitHeader do
|
|
38
38
|
<email>foo@bar.com</email>
|
39
39
|
</enderEmit>
|
40
40
|
</emit>
|
41
|
+
<det nItem="1">
|
42
|
+
<prod>
|
43
|
+
<detExport>
|
44
|
+
<exportInd>
|
45
|
+
<chNFe>41211285493849000105550020000027171182910239</chNFe>
|
46
|
+
</exportInd>
|
47
|
+
</detExport>
|
48
|
+
</prod>
|
49
|
+
</det>
|
41
50
|
</infNFe>
|
42
51
|
</NFe>
|
43
52
|
<protNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
|
@@ -51,6 +60,15 @@ describe BrDanfe::DanfeLib::NfeLib::EmitHeader do
|
|
51
60
|
XML
|
52
61
|
end
|
53
62
|
|
63
|
+
it 'renders only the nfe key' do
|
64
|
+
subject.render 2, 1.85, 2
|
65
|
+
File.delete(output_pdf) if File.exist?(output_pdf)
|
66
|
+
|
67
|
+
pdf.render_file output_pdf
|
68
|
+
|
69
|
+
expect("#{base_dir}emit_header#render-nfe_key.pdf").to have_same_content_of file: output_pdf
|
70
|
+
end
|
71
|
+
|
54
72
|
context 'render emitter on first page' do
|
55
73
|
before do
|
56
74
|
subject.render 1, 3.96, 1
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|