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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -8
  3. data/.github/dependabot.yml +19 -0
  4. data/.rubocop.yml +24 -11
  5. data/Gemfile.lock +38 -30
  6. data/Guardfile +3 -1
  7. data/bin/_guard-core +29 -0
  8. data/bin/guard +29 -0
  9. data/br_danfe.gemspec +6 -5
  10. data/lib/br_danfe/danfe_lib/nfce.rb +10 -8
  11. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +1 -2
  12. data/lib/br_danfe/danfe_lib/nfe.rb +11 -9
  13. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -2
  14. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +4 -5
  15. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +2 -1
  16. data/lib/br_danfe/helper.rb +1 -1
  17. data/lib/br_danfe/mdfe.rb +1 -1
  18. data/lib/br_danfe/mdfe_lib/authorization_protocol.rb +1 -1
  19. data/lib/br_danfe/mdfe_lib/fisco_control.rb +6 -25
  20. data/lib/br_danfe/mdfe_lib/header.rb +7 -8
  21. data/lib/br_danfe/mdfe_lib/mdfe_identification.rb +1 -1
  22. data/lib/br_danfe/mdfe_lib/notes.rb +1 -1
  23. data/lib/br_danfe/qr_code.rb +1 -2
  24. data/lib/br_danfe/version.rb +1 -1
  25. data/lib/br_danfe.rb +2 -2
  26. data/spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb +3 -2
  27. data/spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb +2 -2
  28. data/spec/br_danfe/danfe_lib/nfce_lib/helper_spec.rb +2 -2
  29. data/spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb +2 -2
  30. data/spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb +2 -2
  31. data/spec/br_danfe/danfe_lib/nfce_lib/recipient_spec.rb +10 -10
  32. data/spec/br_danfe/danfe_lib/nfce_lib/total_list_spec.rb +12 -12
  33. data/spec/br_danfe/danfe_lib/nfe_lib/cst_spec.rb +4 -4
  34. data/spec/br_danfe/danfe_lib/nfe_lib/dest_spec.rb +178 -178
  35. data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +274 -274
  36. data/spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb +77 -77
  37. data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +23 -23
  38. data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +37 -37
  39. data/spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb +34 -34
  40. data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +19 -19
  41. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +237 -237
  42. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_vol_spec.rb +3 -2
  43. data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +16 -16
  44. data/spec/br_danfe/danfe_lib/nfe_lib/ticket_spec.rb +13 -13
  45. data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +76 -76
  46. data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +40 -40
  47. data/spec/br_danfe/danfe_lib/nfe_lib/xprod_spec.rb +118 -118
  48. data/spec/br_danfe/danfe_spec.rb +2 -2
  49. data/spec/br_danfe/helper_spec.rb +15 -15
  50. data/spec/br_danfe/mdfe_lib/document_spec.rb +2 -2
  51. data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +21 -7
  52. data/spec/br_danfe/mdfe_lib/header_spec.rb +27 -18
  53. data/spec/br_danfe/mdfe_lib/notes_spec.rb +5 -5
  54. data/spec/br_danfe/mdfe_lib/totalizer_spec.rb +1 -1
  55. data/spec/br_danfe/mdfe_spec.rb +4 -5
  56. data/spec/br_danfe/qr_code_spec.rb +4 -13
  57. data/spec/br_danfe/xml_spec.rb +6 -6
  58. data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
  59. data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
  60. data/spec/spec_helper.rb +1 -1
  61. metadata +35 -14
@@ -16,39 +16,39 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
16
16
 
17
17
  context "when nf-e's version is 2.00" do
18
18
  let(:xml_as_string) do
19
- <<-eos
20
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
21
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
22
- <ide>
23
- <dEmi>2011-10-29</dEmi>
24
- <dSaiEnt>2011-10-30</dSaiEnt>
25
- <hSaiEnt>15:32:45</hSaiEnt>
26
- </ide>
27
- <dest>
28
- <CNPJ>82743287000880</CNPJ>
29
- <xNome>Schneider Electric Brasil Ltda</xNome>
30
- <enderDest>
31
- <xLgr>Av da Saudade</xLgr>
32
- <nro>1125</nro>
33
- <xBairro>Frutal</xBairro>
34
- <xCpl>Sala 01 e 02</xCpl>
35
- <cMun>3552403</cMun>
36
- <xMun>SUMARE</xMun>
37
- <UF>SP</UF>
38
- <CEP>13171320</CEP>
39
- <cPais>1058</cPais>
40
- <xPais>BRASIL</xPais>
41
- <fone>1921046300</fone>
42
- </enderDest>
43
- <IE>671008375110</IE>
44
- </dest>
45
- </infNFe>
46
- </NFe>
47
- eos
19
+ <<~XML
20
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
21
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
22
+ <ide>
23
+ <dEmi>2011-10-29</dEmi>
24
+ <dSaiEnt>2011-10-30</dSaiEnt>
25
+ <hSaiEnt>15:32:45</hSaiEnt>
26
+ </ide>
27
+ <dest>
28
+ <CNPJ>82743287000880</CNPJ>
29
+ <xNome>Schneider Electric Brasil Ltda</xNome>
30
+ <enderDest>
31
+ <xLgr>Av da Saudade</xLgr>
32
+ <nro>1125</nro>
33
+ <xBairro>Frutal</xBairro>
34
+ <xCpl>Sala 01 e 02</xCpl>
35
+ <cMun>3552403</cMun>
36
+ <xMun>SUMARE</xMun>
37
+ <UF>SP</UF>
38
+ <CEP>13171320</CEP>
39
+ <cPais>1058</cPais>
40
+ <xPais>BRASIL</xPais>
41
+ <fone>1921046300</fone>
42
+ </enderDest>
43
+ <IE>671008375110</IE>
44
+ </dest>
45
+ </infNFe>
46
+ </NFe>
47
+ XML
48
48
  end
49
49
 
50
50
  it 'renders xml to the pdf' do
51
- expect(File.exist?(path_of_expected_pdf)).to eql false
51
+ expect(File.exist?(path_of_expected_pdf)).to be false
52
52
 
53
53
  pdf.render_file path_of_expected_pdf
54
54
 
@@ -58,38 +58,38 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
58
58
 
59
59
  context "when nf-e's version is 3.10" do
60
60
  let(:xml_as_string) do
61
- <<-eos
62
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
63
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
64
- <ide>
65
- <dhEmi>2011-09-29T13:02:59+00:00</dhEmi>
66
- <dhSaiEnt>2011-09-30T12:32:45-03:00</dhSaiEnt>
67
- </ide>
68
- <dest>
69
- <CNPJ>82743287000880</CNPJ>
70
- <xNome>Schneider Electric Brasil Ltda</xNome>
71
- <enderDest>
72
- <xLgr>Av da Saudade</xLgr>
73
- <nro>1125</nro>
74
- <xBairro>Frutal</xBairro>
75
- <xCpl>Sala 01 e 02</xCpl>
76
- <cMun>3552403</cMun>
77
- <xMun>SUMARE</xMun>
78
- <UF>SP</UF>
79
- <CEP>13171320</CEP>
80
- <cPais>1058</cPais>
81
- <xPais>BRASIL</xPais>
82
- <fone>1921046300</fone>
83
- </enderDest>
84
- <IE>671008375110</IE>
85
- </dest>
86
- </infNFe>
87
- </NFe>
88
- eos
61
+ <<~XML
62
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
63
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
64
+ <ide>
65
+ <dhEmi>2011-09-29T13:02:59+00:00</dhEmi>
66
+ <dhSaiEnt>2011-09-30T12:32:45-03:00</dhSaiEnt>
67
+ </ide>
68
+ <dest>
69
+ <CNPJ>82743287000880</CNPJ>
70
+ <xNome>Schneider Electric Brasil Ltda</xNome>
71
+ <enderDest>
72
+ <xLgr>Av da Saudade</xLgr>
73
+ <nro>1125</nro>
74
+ <xBairro>Frutal</xBairro>
75
+ <xCpl>Sala 01 e 02</xCpl>
76
+ <cMun>3552403</cMun>
77
+ <xMun>SUMARE</xMun>
78
+ <UF>SP</UF>
79
+ <CEP>13171320</CEP>
80
+ <cPais>1058</cPais>
81
+ <xPais>BRASIL</xPais>
82
+ <fone>1921046300</fone>
83
+ </enderDest>
84
+ <IE>671008375110</IE>
85
+ </dest>
86
+ </infNFe>
87
+ </NFe>
88
+ XML
89
89
  end
90
90
 
91
91
  it 'renders xml to the pdf' do
92
- expect(File.exist?(path_of_expected_pdf)).to eql false
92
+ expect(File.exist?(path_of_expected_pdf)).to be false
93
93
 
94
94
  pdf.render_file path_of_expected_pdf
95
95
 
@@ -99,38 +99,38 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
99
99
 
100
100
  context "when nf-e's version is 4.00" do
101
101
  let(:xml_as_string) do
102
- <<-eos
103
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
104
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="4.00">
105
- <ide>
106
- <dhEmi>2018-07-30T13:30:59+00:00</dhEmi>
107
- <dhSaiEnt>2018-07-30T14:32:45-03:00</dhSaiEnt>
108
- </ide>
109
- <dest>
110
- <CNPJ>82743287000880</CNPJ>
111
- <xNome>Schneider Electric Brasil Ltda</xNome>
112
- <enderDest>
113
- <xLgr>Av da Saudade</xLgr>
114
- <nro>1125</nro>
115
- <xBairro>Frutal</xBairro>
116
- <xCpl>Sala 01 e 02</xCpl>
117
- <cMun>3552403</cMun>
118
- <xMun>SUMARE</xMun>
119
- <UF>SP</UF>
120
- <CEP>13171320</CEP>
121
- <cPais>1058</cPais>
122
- <xPais>BRASIL</xPais>
123
- <fone>1921046300</fone>
124
- </enderDest>
125
- <IE>671008375110</IE>
126
- </dest>
127
- </infNFe>
128
- </NFe>
129
- eos
102
+ <<~XML
103
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
104
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="4.00">
105
+ <ide>
106
+ <dhEmi>2018-07-30T13:30:59+00:00</dhEmi>
107
+ <dhSaiEnt>2018-07-30T14:32:45-03:00</dhSaiEnt>
108
+ </ide>
109
+ <dest>
110
+ <CNPJ>82743287000880</CNPJ>
111
+ <xNome>Schneider Electric Brasil Ltda</xNome>
112
+ <enderDest>
113
+ <xLgr>Av da Saudade</xLgr>
114
+ <nro>1125</nro>
115
+ <xBairro>Frutal</xBairro>
116
+ <xCpl>Sala 01 e 02</xCpl>
117
+ <cMun>3552403</cMun>
118
+ <xMun>SUMARE</xMun>
119
+ <UF>SP</UF>
120
+ <CEP>13171320</CEP>
121
+ <cPais>1058</cPais>
122
+ <xPais>BRASIL</xPais>
123
+ <fone>1921046300</fone>
124
+ </enderDest>
125
+ <IE>671008375110</IE>
126
+ </dest>
127
+ </infNFe>
128
+ </NFe>
129
+ XML
130
130
  end
131
131
 
132
132
  it 'renders xml to the pdf' do
133
- expect(File.exist?(path_of_expected_pdf)).to eql false
133
+ expect(File.exist?(path_of_expected_pdf)).to be false
134
134
 
135
135
  pdf.render_file path_of_expected_pdf
136
136
 
@@ -140,19 +140,19 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
140
140
 
141
141
  context 'when recipient has CNPJ' do
142
142
  let(:xml_as_string) do
143
- <<-eos
144
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
145
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
146
- <dest>
147
- <CNPJ>71058884000183</CNPJ>
148
- </dest>
149
- </infNFe>
150
- </NFe>
151
- eos
143
+ <<~XML
144
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
145
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
146
+ <dest>
147
+ <CNPJ>71058884000183</CNPJ>
148
+ </dest>
149
+ </infNFe>
150
+ </NFe>
151
+ XML
152
152
  end
153
153
 
154
154
  it 'renders xml to the pdf' do
155
- expect(File.exist?(path_of_expected_pdf)).to eql false
155
+ expect(File.exist?(path_of_expected_pdf)).to be false
156
156
 
157
157
  pdf.render_file path_of_expected_pdf
158
158
 
@@ -162,19 +162,19 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
162
162
 
163
163
  context 'when recipient has CPF' do
164
164
  let(:xml_as_string) do
165
- <<-eos
166
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
167
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
168
- <dest>
169
- <CPF>48532557457</CPF>
170
- </dest>
171
- </infNFe>
172
- </NFe>
173
- eos
165
+ <<~XML
166
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
167
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
168
+ <dest>
169
+ <CPF>48532557457</CPF>
170
+ </dest>
171
+ </infNFe>
172
+ </NFe>
173
+ XML
174
174
  end
175
175
 
176
176
  it 'renders xml to the pdf' do
177
- expect(File.exist?(path_of_expected_pdf)).to eql false
177
+ expect(File.exist?(path_of_expected_pdf)).to be false
178
178
 
179
179
  pdf.render_file path_of_expected_pdf
180
180
 
@@ -184,22 +184,22 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
184
184
 
185
185
  context 'when recipient has IE' do
186
186
  let(:xml_as_string) do
187
- <<-eos
188
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
189
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
190
- <dest>
191
- <enderDest>
192
- <UF>SP</UF>
193
- </enderDest>
194
- <IE>671008375110</IE>
195
- </dest>
196
- </infNFe>
197
- </NFe>
198
- eos
187
+ <<~XML
188
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
189
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
190
+ <dest>
191
+ <enderDest>
192
+ <UF>SP</UF>
193
+ </enderDest>
194
+ <IE>671008375110</IE>
195
+ </dest>
196
+ </infNFe>
197
+ </NFe>
198
+ XML
199
199
  end
200
200
 
201
201
  it 'renders xml to the pdf' do
202
- expect(File.exist?(path_of_expected_pdf)).to eql false
202
+ expect(File.exist?(path_of_expected_pdf)).to be false
203
203
 
204
204
  pdf.render_file path_of_expected_pdf
205
205
 
@@ -209,37 +209,37 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
209
209
 
210
210
  context "when recipient doesn't have address complement" do
211
211
  let(:xml_as_string) do
212
- <<-eos
213
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
214
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
215
- <ide>
216
- <dhEmi>2011-09-29T13:02:59+00:00</dhEmi>
217
- <dhSaiEnt>2011-09-30T12:32:45-03:00</dhSaiEnt>
218
- </ide>
219
- <dest>
220
- <CNPJ>82743287000880</CNPJ>
221
- <xNome>Schneider Electric Brasil Ltda</xNome>
222
- <enderDest>
223
- <xLgr>Av da Saudade</xLgr>
224
- <nro>1125</nro>
225
- <xBairro>Frutal</xBairro>
226
- <cMun>3552403</cMun>
227
- <xMun>SUMARE</xMun>
228
- <UF>SP</UF>
229
- <CEP>13171320</CEP>
230
- <cPais>1058</cPais>
231
- <xPais>BRASIL</xPais>
232
- <fone>1921046300</fone>
233
- </enderDest>
234
- <IE>671008375110</IE>
235
- </dest>
236
- </infNFe>
237
- </NFe>
238
- eos
212
+ <<~XML
213
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
214
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
215
+ <ide>
216
+ <dhEmi>2011-09-29T13:02:59+00:00</dhEmi>
217
+ <dhSaiEnt>2011-09-30T12:32:45-03:00</dhSaiEnt>
218
+ </ide>
219
+ <dest>
220
+ <CNPJ>82743287000880</CNPJ>
221
+ <xNome>Schneider Electric Brasil Ltda</xNome>
222
+ <enderDest>
223
+ <xLgr>Av da Saudade</xLgr>
224
+ <nro>1125</nro>
225
+ <xBairro>Frutal</xBairro>
226
+ <cMun>3552403</cMun>
227
+ <xMun>SUMARE</xMun>
228
+ <UF>SP</UF>
229
+ <CEP>13171320</CEP>
230
+ <cPais>1058</cPais>
231
+ <xPais>BRASIL</xPais>
232
+ <fone>1921046300</fone>
233
+ </enderDest>
234
+ <IE>671008375110</IE>
235
+ </dest>
236
+ </infNFe>
237
+ </NFe>
238
+ XML
239
239
  end
240
240
 
241
241
  it 'renders xml to the pdf' do
242
- expect(File.exist?(path_of_expected_pdf)).to eql false
242
+ expect(File.exist?(path_of_expected_pdf)).to be false
243
243
 
244
244
  pdf.render_file path_of_expected_pdf
245
245
 
@@ -250,38 +250,38 @@ describe BrDanfe::DanfeLib::NfeLib::Dest do
250
250
 
251
251
  context 'when recipient address (xLgr + nro + xCpl) has more than 63 characters' do
252
252
  let(:xml_as_string) do
253
- <<-eos
254
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
255
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
256
- <ide>
257
- <dhEmi>2011-09-29T13:02:59+00:00</dhEmi>
258
- <dhSaiEnt>2011-09-30T12:32:45-03:00</dhSaiEnt>
259
- </ide>
260
- <dest>
261
- <CNPJ>82743287000880</CNPJ>
262
- <xNome>Schneider Electric Brasil Ltda</xNome>
263
- <enderDest>
264
- <xLgr>Rua do governo do estado</xLgr>
265
- <nro>1125</nro>
266
- <xCpl>Em anexo ao super mercado maior do bairro</xCpl>
267
- <xBairro>Frutal</xBairro>
268
- <cMun>3552403</cMun>
269
- <xMun>SUMARE</xMun>
270
- <UF>SP</UF>
271
- <CEP>13171320</CEP>
272
- <cPais>1058</cPais>
273
- <xPais>BRASIL</xPais>
274
- <fone>1921046300</fone>
275
- </enderDest>
276
- <IE>671008375110</IE>
277
- </dest>
278
- </infNFe>
279
- </NFe>
280
- eos
253
+ <<~XML
254
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
255
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
256
+ <ide>
257
+ <dhEmi>2011-09-29T13:02:59+00:00</dhEmi>
258
+ <dhSaiEnt>2011-09-30T12:32:45-03:00</dhSaiEnt>
259
+ </ide>
260
+ <dest>
261
+ <CNPJ>82743287000880</CNPJ>
262
+ <xNome>Schneider Electric Brasil Ltda</xNome>
263
+ <enderDest>
264
+ <xLgr>Rua do governo do estado</xLgr>
265
+ <nro>1125</nro>
266
+ <xCpl>Em anexo ao super mercado maior do bairro</xCpl>
267
+ <xBairro>Frutal</xBairro>
268
+ <cMun>3552403</cMun>
269
+ <xMun>SUMARE</xMun>
270
+ <UF>SP</UF>
271
+ <CEP>13171320</CEP>
272
+ <cPais>1058</cPais>
273
+ <xPais>BRASIL</xPais>
274
+ <fone>1921046300</fone>
275
+ </enderDest>
276
+ <IE>671008375110</IE>
277
+ </dest>
278
+ </infNFe>
279
+ </NFe>
280
+ XML
281
281
  end
282
282
 
283
283
  it 'renders xml to pdf discarding the address of after 63 characters' do
284
- expect(File.exist?(path_of_expected_pdf)).to eql false
284
+ expect(File.exist?(path_of_expected_pdf)).to be false
285
285
 
286
286
  pdf.render_file path_of_expected_pdf
287
287