br_danfe 0.17.0 → 0.17.1
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/Gemfile.lock +38 -30
- data/Guardfile +3 -1
- data/bin/_guard-core +29 -0
- data/bin/guard +29 -0
- data/br_danfe.gemspec +6 -5
- data/lib/br_danfe/danfe_lib/nfce.rb +10 -8
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +1 -2
- data/lib/br_danfe/danfe_lib/nfe.rb +11 -9
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -2
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +4 -5
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +2 -1
- data/lib/br_danfe/helper.rb +1 -1
- data/lib/br_danfe/mdfe.rb +1 -1
- data/lib/br_danfe/mdfe_lib/authorization_protocol.rb +1 -1
- data/lib/br_danfe/mdfe_lib/fisco_control.rb +6 -25
- data/lib/br_danfe/mdfe_lib/header.rb +7 -8
- data/lib/br_danfe/mdfe_lib/mdfe_identification.rb +1 -1
- data/lib/br_danfe/mdfe_lib/notes.rb +1 -1
- data/lib/br_danfe/qr_code.rb +1 -2
- 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 +2 -2
- 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/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 +237 -237
- 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 +15 -15
- data/spec/br_danfe/mdfe_lib/document_spec.rb +2 -2
- data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +21 -7
- data/spec/br_danfe/mdfe_lib/header_spec.rb +27 -18
- data/spec/br_danfe/mdfe_lib/notes_spec.rb +5 -5
- data/spec/br_danfe/mdfe_lib/totalizer_spec.rb +1 -1
- data/spec/br_danfe/mdfe_spec.rb +4 -5
- data/spec/br_danfe/qr_code_spec.rb +4 -13
- data/spec/br_danfe/xml_spec.rb +6 -6
- data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
- data/spec/spec_helper.rb +1 -1
- metadata +35 -14
@@ -74,7 +74,7 @@ module BrDanfe
|
|
74
74
|
|
75
75
|
total_height += 10 if total_chars >= MAX_CHARS_ON_LINE
|
76
76
|
|
77
|
-
total_height <= height_on_first_page ? first_page += word
|
77
|
+
total_height <= height_on_first_page ? first_page += "#{word} " : next_page += "#{word} "
|
78
78
|
end
|
79
79
|
|
80
80
|
{ first_page: first_page, next_page: next_page }
|
data/lib/br_danfe/qr_code.rb
CHANGED
data/lib/br_danfe/version.rb
CHANGED
data/lib/br_danfe.rb
CHANGED
@@ -10,12 +10,12 @@ require 'ostruct'
|
|
10
10
|
require 'i18n'
|
11
11
|
require 'br_documents'
|
12
12
|
|
13
|
-
Dir[File.dirname(__FILE__)
|
13
|
+
Dir["#{File.dirname(__FILE__)}/**/*.rb"].sort.each { |f| require f }
|
14
14
|
I18n.load_path << File.expand_path('../config/locales/pt-BR.yml', __dir__)
|
15
15
|
Prawn::Font::AFM.hide_m17n_warning = true
|
16
16
|
|
17
17
|
module BrDanfe
|
18
18
|
def self.root_path
|
19
|
-
File.expand_path('
|
19
|
+
File.expand_path('..', __dir__)
|
20
20
|
end
|
21
21
|
end
|
@@ -7,7 +7,7 @@ describe BrDanfe::DanfeLib::NfceLib::Footer do
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
8
8
|
|
9
9
|
let(:xml_footer) do
|
10
|
-
xml =
|
10
|
+
xml = <<~XML
|
11
11
|
<nfeProc>
|
12
12
|
<NFe>
|
13
13
|
<infNFe>
|
@@ -19,7 +19,7 @@ describe BrDanfe::DanfeLib::NfceLib::Footer do
|
|
19
19
|
</infNFe>
|
20
20
|
</NFe>
|
21
21
|
</nfeProc>
|
22
|
-
|
22
|
+
XML
|
23
23
|
|
24
24
|
BrDanfe::XML.new(xml)
|
25
25
|
end
|
@@ -28,6 +28,7 @@ describe BrDanfe::DanfeLib::NfceLib::Footer do
|
|
28
28
|
|
29
29
|
describe '#render' do
|
30
30
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
31
|
+
|
31
32
|
it 'renders footer to the pdf' do
|
32
33
|
subject.render
|
33
34
|
expect(File.exist?(output_pdf)).to be_falsey
|
@@ -8,7 +8,7 @@ describe BrDanfe::DanfeLib::NfceLib::Header do
|
|
8
8
|
let(:environment) { 1 }
|
9
9
|
|
10
10
|
let(:xml) do
|
11
|
-
xml =
|
11
|
+
xml = <<~XML
|
12
12
|
<nfeProc>
|
13
13
|
<NFe>
|
14
14
|
<infNFe>
|
@@ -37,7 +37,7 @@ describe BrDanfe::DanfeLib::NfceLib::Header do
|
|
37
37
|
</infNFe>
|
38
38
|
</NFe>
|
39
39
|
</nfeProc>
|
40
|
-
|
40
|
+
XML
|
41
41
|
|
42
42
|
BrDanfe::XML.new(xml)
|
43
43
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::NfceLib::Helper do
|
4
4
|
let(:xml) do
|
5
|
-
xml =
|
5
|
+
xml = <<~XML
|
6
6
|
<enderDest>
|
7
7
|
<xLgr>Rua Tijucas</xLgr>
|
8
8
|
<nro>99</nro>
|
@@ -15,7 +15,7 @@ describe BrDanfe::DanfeLib::NfceLib::Helper do
|
|
15
15
|
<cPais>1058</cPais>
|
16
16
|
<xPais>Brasil</xPais>
|
17
17
|
</enderDest>
|
18
|
-
|
18
|
+
XML
|
19
19
|
|
20
20
|
BrDanfe::XML.new(xml)
|
21
21
|
end
|
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::NfceLib::Key do
|
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
7
|
let(:xml_key) do
|
8
|
-
xml =
|
8
|
+
xml = <<~XML
|
9
9
|
<nfeProc>
|
10
10
|
<NFe>
|
11
11
|
<infNFeSupl>
|
@@ -19,7 +19,7 @@ describe BrDanfe::DanfeLib::NfceLib::Key do
|
|
19
19
|
</infProt>
|
20
20
|
</protNFe>
|
21
21
|
</nfeProc>
|
22
|
-
|
22
|
+
XML
|
23
23
|
|
24
24
|
BrDanfe::XML.new(xml)
|
25
25
|
end
|
@@ -7,7 +7,7 @@ describe BrDanfe::DanfeLib::NfceLib::NfceIdentification do
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
8
8
|
|
9
9
|
let(:xml) do
|
10
|
-
xml =
|
10
|
+
xml = <<~XML
|
11
11
|
<nfeProc>
|
12
12
|
<NFe>
|
13
13
|
<infNFe>
|
@@ -25,7 +25,7 @@ describe BrDanfe::DanfeLib::NfceLib::NfceIdentification do
|
|
25
25
|
</infNFe>
|
26
26
|
</NFe>
|
27
27
|
</nfeProc>
|
28
|
-
|
28
|
+
XML
|
29
29
|
|
30
30
|
BrDanfe::XML.new(xml)
|
31
31
|
end
|
@@ -18,7 +18,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
18
18
|
context 'when has identified recipient' do
|
19
19
|
context 'when the recipient is a company' do
|
20
20
|
let(:xml_as_string) do
|
21
|
-
|
21
|
+
<<~XML
|
22
22
|
<nfeProc>
|
23
23
|
<NFe>
|
24
24
|
<dest>
|
@@ -34,7 +34,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
34
34
|
</dest>
|
35
35
|
</NFe>
|
36
36
|
</nfeProc>
|
37
|
-
|
37
|
+
XML
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'renders the CNPJ and company informations' do
|
@@ -47,7 +47,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
47
47
|
|
48
48
|
context 'when the recipient is an individual person' do
|
49
49
|
let(:xml_as_string) do
|
50
|
-
|
50
|
+
<<~XML
|
51
51
|
<nfeProc>
|
52
52
|
<NFe>
|
53
53
|
<dest>
|
@@ -63,7 +63,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
63
63
|
</dest>
|
64
64
|
</NFe>
|
65
65
|
</nfeProc>
|
66
|
-
|
66
|
+
XML
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'renders the CPF and individual informations' do
|
@@ -76,7 +76,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
76
76
|
|
77
77
|
context 'when the recipient is a foreign' do
|
78
78
|
let(:xml_as_string) do
|
79
|
-
|
79
|
+
<<~XML
|
80
80
|
<nfeProc>
|
81
81
|
<NFe>
|
82
82
|
<dest>
|
@@ -92,7 +92,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
92
92
|
</dest>
|
93
93
|
</NFe>
|
94
94
|
</nfeProc>
|
95
|
-
|
95
|
+
XML
|
96
96
|
end
|
97
97
|
|
98
98
|
it 'renders the ID Estrangeiro and foreign informations' do
|
@@ -105,7 +105,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
105
105
|
|
106
106
|
context 'when the recipient does not have document' do
|
107
107
|
let(:xml_as_string) do
|
108
|
-
|
108
|
+
<<~XML
|
109
109
|
<nfeProc>
|
110
110
|
<NFe>
|
111
111
|
<dest>
|
@@ -120,7 +120,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
120
120
|
</dest>
|
121
121
|
</NFe>
|
122
122
|
</nfeProc>
|
123
|
-
|
123
|
+
XML
|
124
124
|
end
|
125
125
|
|
126
126
|
it 'renders the name and the address of the consumer' do
|
@@ -134,7 +134,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
134
134
|
|
135
135
|
context 'when does not have identified recipient' do
|
136
136
|
let(:xml_as_string) do
|
137
|
-
|
137
|
+
<<~XML
|
138
138
|
<nfeProc>
|
139
139
|
<NFe>
|
140
140
|
<dest>
|
@@ -149,7 +149,7 @@ describe BrDanfe::DanfeLib::NfceLib::Recipient do
|
|
149
149
|
</dest>
|
150
150
|
</NFe>
|
151
151
|
</nfeProc>
|
152
|
-
|
152
|
+
XML
|
153
153
|
end
|
154
154
|
|
155
155
|
it 'renders unidentified consumer' do
|
@@ -6,7 +6,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
6
6
|
|
7
7
|
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
8
8
|
let(:payment_xml) do
|
9
|
-
|
9
|
+
<<~XML
|
10
10
|
<pag>
|
11
11
|
<detPag>
|
12
12
|
<tPag>01</tPag>
|
@@ -21,10 +21,10 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
21
21
|
<vPag>66.70</vPag>
|
22
22
|
</detPag>
|
23
23
|
</pag>
|
24
|
-
|
24
|
+
XML
|
25
25
|
end
|
26
26
|
let(:xml_as_string) do
|
27
|
-
|
27
|
+
<<~XML
|
28
28
|
<nfeProc>
|
29
29
|
<NFe>
|
30
30
|
<infNFe>
|
@@ -43,7 +43,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
43
43
|
</infNFe>
|
44
44
|
</NFe>
|
45
45
|
</nfeProc>
|
46
|
-
|
46
|
+
XML
|
47
47
|
end
|
48
48
|
let(:xml_total_list) { BrDanfe::XML.new(xml_as_string) }
|
49
49
|
|
@@ -64,7 +64,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
64
64
|
|
65
65
|
describe 'about totals' do
|
66
66
|
let(:xml_as_string) do
|
67
|
-
|
67
|
+
<<~XML
|
68
68
|
<nfeProc>
|
69
69
|
<NFe>
|
70
70
|
<infNFe>
|
@@ -82,7 +82,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
82
82
|
</infNFe>
|
83
83
|
</NFe>
|
84
84
|
</nfeProc>
|
85
|
-
|
85
|
+
XML
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'renders the totals' do
|
@@ -95,7 +95,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
95
95
|
|
96
96
|
describe 'about payment methods' do
|
97
97
|
let(:payment_xml) do
|
98
|
-
|
98
|
+
<<~XML
|
99
99
|
<pag>
|
100
100
|
<detPag>
|
101
101
|
<tPag>01</tPag>
|
@@ -114,7 +114,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
114
114
|
<vPag>1.99</vPag>
|
115
115
|
</detPag>
|
116
116
|
</pag>
|
117
|
-
|
117
|
+
XML
|
118
118
|
end
|
119
119
|
|
120
120
|
it 'does not render the ""without payment"" payment method ' do
|
@@ -126,7 +126,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
126
126
|
|
127
127
|
context 'when there are repeated payment methods' do
|
128
128
|
let(:payment_xml) do
|
129
|
-
|
129
|
+
<<~XML
|
130
130
|
<pag>
|
131
131
|
<detPag>
|
132
132
|
<tPag>01</tPag>
|
@@ -145,7 +145,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
145
145
|
<vPag>26.50</vPag>
|
146
146
|
</detPag>
|
147
147
|
</pag>
|
148
|
-
|
148
|
+
XML
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'renders grouped payment methods' do
|
@@ -158,7 +158,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
158
158
|
|
159
159
|
context 'when there are only "without payment" payment methods' do
|
160
160
|
let(:payment_xml) do
|
161
|
-
|
161
|
+
<<~XML
|
162
162
|
<pag>
|
163
163
|
<detPag>
|
164
164
|
<tPag>90</tPag>
|
@@ -173,7 +173,7 @@ describe BrDanfe::DanfeLib::NfceLib::TotalList do
|
|
173
173
|
<vPag>66.70</vPag>
|
174
174
|
</detPag>
|
175
175
|
</pag>
|
176
|
-
|
176
|
+
XML
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'does not render payment methods' do
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::NfeLib::Cst do
|
4
4
|
let(:xml_cst) do
|
5
|
-
xml =
|
5
|
+
xml = <<~XML
|
6
6
|
<imposto>
|
7
7
|
<ICMS>
|
8
8
|
<ICMS00>
|
@@ -15,13 +15,13 @@ describe BrDanfe::DanfeLib::NfeLib::Cst do
|
|
15
15
|
</ICMS00>
|
16
16
|
</ICMS>
|
17
17
|
</imposto>
|
18
|
-
|
18
|
+
XML
|
19
19
|
|
20
20
|
Nokogiri::XML(xml)
|
21
21
|
end
|
22
22
|
|
23
23
|
let(:xml_csosn) do
|
24
|
-
xml =
|
24
|
+
xml = <<~XML
|
25
25
|
<imposto>
|
26
26
|
<ICMS>
|
27
27
|
<ICMSSN102>
|
@@ -30,7 +30,7 @@ describe BrDanfe::DanfeLib::NfeLib::Cst do
|
|
30
30
|
</ICMSSN102>
|
31
31
|
</ICMS>
|
32
32
|
</imposto>
|
33
|
-
|
33
|
+
XML
|
34
34
|
|
35
35
|
Nokogiri::XML(xml)
|
36
36
|
end
|