br_danfe 0.16.0 → 0.17.3
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 +41 -35
- data/Guardfile +3 -1
- data/bin/_guard-core +29 -0
- data/bin/guard +29 -0
- data/br_danfe.gemspec +7 -6
- data/lib/br_danfe/danfe_lib/nfce.rb +11 -9
- data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +2 -2
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +30 -16
- data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +3 -3
- data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +3 -3
- data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +44 -53
- data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +16 -15
- 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 +6 -7
- 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 +6 -4
- 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/nfce_spec.rb +2 -1
- 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 +55 -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/fixtures/nfce/lib/document#render.pdf +12 -23
- data/spec/fixtures/nfce/lib/footer#render-with_additional_information.pdf +0 -0
- data/spec/fixtures/nfce/lib/footer#render.pdf +0 -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/lib/key#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list_with_many_products_and_long_names.xml +2 -2
- data/spec/fixtures/nfce/lib/product_list_with_single_product_and_long_name.xml +1 -1
- data/spec/fixtures/nfce/lib/recipient#render-company.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/multiples_xmls_on_the_same_pdf.pdf +568 -447
- 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
- data/spec/spec_helper.rb +1 -1
- metadata +38 -16
@@ -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
|
@@ -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
|
@@ -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
|