br_danfe 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +25 -25
  3. data/lib/br_danfe/danfe.rb +52 -25
  4. data/lib/br_danfe/danfe_lib/det_body.rb +105 -46
  5. data/lib/br_danfe/danfe_lib/document.rb +3 -7
  6. data/lib/br_danfe/danfe_lib/emit_header.rb +36 -20
  7. data/lib/br_danfe/danfe_lib/infadic.rb +12 -12
  8. data/lib/br_danfe/danfe_lib/issqn.rb +19 -8
  9. data/lib/br_danfe/version.rb +1 -1
  10. data/spec/features/danfe_spec.rb +45 -0
  11. data/spec/fixtures/nfe/lib/det_body#render-csosn.pdf +1932 -332
  12. data/spec/fixtures/nfe/lib/det_body#render-cst.pdf +1182 -138
  13. data/spec/fixtures/nfe/lib/det_body#render-fci.pdf +809 -43
  14. data/spec/fixtures/nfe/lib/det_body#render-icms_st.pdf +809 -43
  15. data/spec/fixtures/nfe/lib/det_body#render-quantity_with_custom_precision.pdf +807 -41
  16. data/spec/fixtures/nfe/lib/det_body#render-three_pages.pdf +22414 -0
  17. data/spec/fixtures/nfe/lib/det_body#render-two_pages.pdf +21442 -0
  18. data/spec/fixtures/nfe/lib/det_body#render-unit_price_with_custom_precision.pdf +807 -41
  19. data/spec/fixtures/nfe/lib/det_body#render-with_infadprod.pdf +1012 -0
  20. data/spec/fixtures/nfe/lib/det_body#render-with_issqn.pdf +10124 -0
  21. data/spec/fixtures/nfe/lib/det_body#render-without_issqn.pdf +10124 -0
  22. data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +792 -0
  23. data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +88 -8
  24. data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +85 -5
  25. data/spec/fixtures/nfe/lib/infadic#render-footer_information.pdf +111 -0
  26. data/spec/fixtures/nfe/lib/{issqn#render.pdf → issqn#render-with_issqn.pdf} +0 -0
  27. data/spec/fixtures/nfe/lib/issqn#render-with_one_issqn_value.pdf +129 -0
  28. data/spec/fixtures/nfe/lib/issqn#render-without_issqn.pdf +54 -0
  29. data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +2190 -1067
  30. data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +2183 -1059
  31. data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +8803 -3208
  32. data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +1825 -1258
  33. data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +8609 -3014
  34. data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +2664 -1541
  35. data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +4701 -1909
  36. data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +8660 -0
  37. data/spec/fixtures/nfe/v3.10/with_footer.xml +621 -0
  38. data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +8646 -0
  39. data/spec/fixtures/nfe/v3.10/with_issqn.xml +621 -0
  40. data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +25420 -0
  41. data/spec/fixtures/nfe/v3.10/with_three_pages.xml +1281 -0
  42. data/spec/fixtures/nfe/v3.10/withot_issqn.fixture.pdf +10338 -0
  43. data/spec/fixtures/nfe/v3.10/withot_issqn.xml +688 -0
  44. data/spec/lib/danfe_lib/det_body_spec.rb +350 -264
  45. data/spec/lib/danfe_lib/emit_header_spec.rb +42 -18
  46. data/spec/lib/danfe_lib/issqn_spec.rb +39 -7
  47. metadata +38 -14
  48. data/lib/br_danfe/danfe_lib/det_header.rb +0 -40
  49. data/lib/br_danfe/danfe_lib/emit.rb +0 -23
  50. data/spec/fixtures/nfe/lib/det_header#render.pdf +0 -207
  51. data/spec/fixtures/nfe/lib/emit#render.pdf +0 -143
  52. data/spec/lib/danfe_lib/det_header_spec.rb +0 -26
  53. data/spec/lib/danfe_lib/emit_spec.rb +0 -60
@@ -7,108 +7,155 @@ describe BrDanfe::DanfeLib::DetBody do
7
7
  let(:pdf) { BrDanfe::DanfeLib::Document.new }
8
8
  let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
9
9
 
10
+ let(:xml_as_string) do
11
+ <<-eos
12
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
13
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
14
+ #{products}
15
+ </infNFe>
16
+ </NFe>
17
+ eos
18
+ end
19
+
20
+ let(:products) do
21
+ "#{product_1}\n#{product_2}"
22
+ end
23
+
24
+ let(:product_1) do
25
+ <<-eos
26
+ <det nItem="1">
27
+ <prod>
28
+ <cProd>1</cProd>
29
+ <xProd>Product 1</xProd>
30
+ <NCM>45678901</NCM>
31
+ <CFOP>5401</CFOP>
32
+ <uCom>UN</uCom>
33
+ <qCom>6.4545</qCom>
34
+ <vUnCom>1.03</vUnCom>
35
+ <vProd>6.65</vProd>
36
+ </prod>
37
+ </det>
38
+ eos
39
+ end
40
+
41
+ let(:product_2) do
42
+ <<-eos
43
+ <det nItem="2">
44
+ <prod>
45
+ <cProd>2</cProd>
46
+ <xProd>Product 2</xProd>
47
+ <NCM>45678901</NCM>
48
+ <CFOP>5401</CFOP>
49
+ <uCom>UN</uCom>
50
+ <qCom>6.4545</qCom>
51
+ <vUnCom>1.03</vUnCom>
52
+ <vProd>6.65</vProd>
53
+ <infAdProd>Additional information 1 - Additional information 2 - Additional information 3</infAdProd>
54
+ </prod>
55
+ </det>
56
+ eos
57
+ end
58
+
59
+ let(:has_issqn) { false }
60
+
10
61
  subject { described_class.new(pdf, xml) }
11
62
 
12
63
  describe "#render" do
13
64
  before do
14
- subject.render
65
+ subject.render has_issqn
15
66
  File.delete(output_pdf) if File.exist?(output_pdf)
16
67
  end
17
68
 
18
69
  context "with CSOSN" do
19
- let(:xml_as_string) do
70
+ let(:products) do
20
71
  <<-eos
21
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
22
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
23
- <det nItem="1">
24
- <prod>
25
- <cProd>1</cProd>
26
- <xProd>Produto com CSOSN 101 - Nacional</xProd>
27
- <NCM>12345678</NCM>
28
- <CFOP>5101</CFOP>
29
- <uCom>UN</uCom>
30
- <qCom>2.00</qCom>
31
- <vUnCom>1.01</vUnCom>
32
- <vProd>2.02</vProd>
33
- </prod>
34
- <imposto>
35
- <ICMS>
36
- <ICMSSN101>
37
- <orig>0</orig>
38
- <CSOSN>101</CSOSN>
39
- </ICMSSN101>
40
- </ICMS>
41
- </imposto>
42
- </det>
43
- <det nItem="2">
44
- <prod>
45
- <cProd>2</cProd>
46
- <xProd>Produto com CSOSN 102 - Estrangeiro</xProd>
47
- <NCM>23456789</NCM>
48
- <CFOP>5101</CFOP>
49
- <uCom>UN</uCom>
50
- <qCom>4.00</qCom>
51
- <vUnCom>1.02</vUnCom>
52
- <vProd>4.08</vProd>
53
- </prod>
54
- <imposto>
55
- <ICMS>
56
- <ICMSSN102>
57
- <orig>1</orig>
58
- <CSOSN>102</CSOSN>
59
- </ICMSSN102>
60
- </ICMS>
61
- </imposto>
62
- </det>
63
- <det nItem="3">
64
- <prod>
65
- <cProd>3</cProd>
66
- <xProd>Produto Com Csosn 201</xProd>
67
- <NCM>45678901</NCM>
68
- <CFOP>5401</CFOP>
69
- <uCom>UN</uCom>
70
- <qCom>6.00</qCom>
71
- <vUnCom>1.03</vUnCom>
72
- <vProd>6.18</vProd>
73
- </prod>
74
- <imposto>
75
- <ICMS>
76
- <ICMSSN201>
77
- <orig>0</orig>
78
- <CSOSN>201</CSOSN>
79
- <pMVAST>24.00</pMVAST>
80
- <vBCST>7.66</vBCST>
81
- <pICMSST>17.00</pICMSST>
82
- <vICMSST>0.25</vICMSST>
83
- </ICMSSN201>
84
- </ICMS>
85
- </imposto>
86
- </det>
87
- <det nItem="4">
88
- <prod>
89
- <cProd>8</cProd>
90
- <xProd>Produto com CSOSN 900 - Com ICMS</xProd>
91
- <NCM>34567890</NCM>
92
- <CFOP>5201</CFOP>
93
- <uCom>UN</uCom>
94
- <qCom>16.00</qCom>
95
- <vUnCom>1.08</vUnCom>
96
- <vProd>17.28</vProd>
97
- </prod>
98
- <imposto>
99
- <ICMS>
100
- <ICMSSN900>
101
- <orig>0</orig>
102
- <CSOSN>900</CSOSN>
103
- <vBC>9.87</vBC>
104
- <pICMS>8.76</pICMS>
105
- <vICMS>7.65</vICMS>
106
- </ICMSSN900>
107
- </ICMS>
108
- </imposto>
109
- </det>
110
- </infNFe>
111
- </NFe>
72
+ <det nItem="1">
73
+ <prod>
74
+ <cProd>1</cProd>
75
+ <xProd>Produto com CSOSN 101 - Nacional</xProd>
76
+ <NCM>12345678</NCM>
77
+ <CFOP>5101</CFOP>
78
+ <uCom>UN</uCom>
79
+ <qCom>2.00</qCom>
80
+ <vUnCom>1.01</vUnCom>
81
+ <vProd>2.02</vProd>
82
+ </prod>
83
+ <imposto>
84
+ <ICMS>
85
+ <ICMSSN101>
86
+ <orig>0</orig>
87
+ <CSOSN>101</CSOSN>
88
+ </ICMSSN101>
89
+ </ICMS>
90
+ </imposto>
91
+ </det>
92
+ <det nItem="2">
93
+ <prod>
94
+ <cProd>2</cProd>
95
+ <xProd>Produto com CSOSN 102 - Estrangeiro</xProd>
96
+ <NCM>23456789</NCM>
97
+ <CFOP>5101</CFOP>
98
+ <uCom>UN</uCom>
99
+ <qCom>4.00</qCom>
100
+ <vUnCom>1.02</vUnCom>
101
+ <vProd>4.08</vProd>
102
+ </prod>
103
+ <imposto>
104
+ <ICMS>
105
+ <ICMSSN102>
106
+ <orig>1</orig>
107
+ <CSOSN>102</CSOSN>
108
+ </ICMSSN102>
109
+ </ICMS>
110
+ </imposto>
111
+ </det>
112
+ <det nItem="3">
113
+ <prod>
114
+ <cProd>3</cProd>
115
+ <xProd>Produto Com Csosn 201</xProd>
116
+ <NCM>45678901</NCM>
117
+ <CFOP>5401</CFOP>
118
+ <uCom>UN</uCom>
119
+ <qCom>6.00</qCom>
120
+ <vUnCom>1.03</vUnCom>
121
+ <vProd>6.18</vProd>
122
+ </prod>
123
+ <imposto>
124
+ <ICMS>
125
+ <ICMSSN201>
126
+ <orig>0</orig>
127
+ <CSOSN>201</CSOSN>
128
+ <pMVAST>24.00</pMVAST>
129
+ <vBCST>7.66</vBCST>
130
+ <pICMSST>17.00</pICMSST>
131
+ <vICMSST>0.25</vICMSST>
132
+ </ICMSSN201>
133
+ </ICMS>
134
+ </imposto>
135
+ </det>
136
+ <det nItem="4">
137
+ <prod>
138
+ <cProd>8</cProd>
139
+ <xProd>Produto com CSOSN 900 - Com ICMS</xProd>
140
+ <NCM>34567890</NCM>
141
+ <CFOP>5201</CFOP>
142
+ <uCom>UN</uCom>
143
+ <qCom>16.00</qCom>
144
+ <vUnCom>1.08</vUnCom>
145
+ <vProd>17.28</vProd>
146
+ </prod>
147
+ <imposto>
148
+ <ICMS>
149
+ <ICMSSN900>
150
+ <orig>0</orig>
151
+ <CSOSN>900</CSOSN>
152
+ <vBC>9.87</vBC>
153
+ <pICMS>8.76</pICMS>
154
+ <vICMS>7.65</vICMS>
155
+ </ICMSSN900>
156
+ </ICMS>
157
+ </imposto>
158
+ </det>
112
159
  eos
113
160
  end
114
161
 
@@ -122,84 +169,80 @@ describe BrDanfe::DanfeLib::DetBody do
122
169
  end
123
170
 
124
171
  context "with CST" do
125
- let(:xml_as_string) do
172
+ let(:products) do
126
173
  <<-eos
127
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
128
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
129
- <det nItem="1">
130
- <prod>
131
- <cProd>REF 04</cProd>
132
- <xProd>Produto com CST 00 - Nacional - ICMS - IPI</xProd>
133
- <NCM>90303329</NCM>
134
- <EXTIPI>00</EXTIPI>
135
- <CFOP>5101</CFOP>
136
- <uCom>PC</uCom>
137
- <qCom>1.00</qCom>
138
- <vUnCom>49.23</vUnCom>
139
- <vProd>49.23</vProd>
140
- <xPed>98001921</xPed>
141
- <nItemPed>10</nItemPed>
142
- </prod>
143
- <imposto>
144
- <ICMS>
145
- <ICMS00>
146
- <orig>0</orig>
147
- <CST>00</CST>
148
- <modBC>3</modBC>
149
- <vBC>49.23</vBC>
150
- <pICMS>12.00</pICMS>
151
- <vICMS>5.90</vICMS>
152
- </ICMS00>
153
- </ICMS>
154
- <IPI>
155
- <cEnq>999</cEnq>
156
- <IPITrib>
157
- <CST>50</CST>
158
- <vBC>49.23</vBC>
159
- <pIPI>5.00</pIPI>
160
- <vIPI>2.46</vIPI>
161
- </IPITrib>
162
- </IPI>
163
- </imposto>
164
- </det>
165
- <det nItem="2">
166
- <prod>
167
- <cProd>REF 05</cProd>
168
- <xProd>Produto com CST 00 - Estrangeiro - ICMS - IPI</xProd>
169
- <NCM>90303329</NCM>
170
- <EXTIPI>00</EXTIPI>
171
- <CFOP>5101</CFOP>
172
- <uCom>PC</uCom>
173
- <qCom>1.00</qCom>
174
- <vUnCom>49.23</vUnCom>
175
- <vProd>49.23</vProd>
176
- <xPed>98001921</xPed>
177
- <nItemPed>10</nItemPed>
178
- </prod>
179
- <imposto>
180
- <ICMS>
181
- <ICMS00>
182
- <orig>1</orig>
183
- <CST>00</CST>
184
- <modBC>3</modBC>
185
- <vBC>49.23</vBC>
186
- <pICMS>12.00</pICMS>
187
- <vICMS>5.90</vICMS>
188
- </ICMS00>
189
- </ICMS>
190
- <IPI>
191
- <cEnq>999</cEnq>
192
- <IPITrib>
193
- <CST>50</CST>
194
- <vBC>49.23</vBC>
195
- <pIPI>5.00</pIPI>
196
- <vIPI>2.46</vIPI>
197
- </IPITrib>
198
- </IPI>
199
- </imposto>
200
- </det>
201
- </infNFe>
202
- </NFe>
174
+ <det nItem="1">
175
+ <prod>
176
+ <cProd>REF 04</cProd>
177
+ <xProd>Produto com CST 00 - Nacional - ICMS - IPI</xProd>
178
+ <NCM>90303329</NCM>
179
+ <EXTIPI>00</EXTIPI>
180
+ <CFOP>5101</CFOP>
181
+ <uCom>PC</uCom>
182
+ <qCom>1.00</qCom>
183
+ <vUnCom>49.23</vUnCom>
184
+ <vProd>49.23</vProd>
185
+ <xPed>98001921</xPed>
186
+ <nItemPed>10</nItemPed>
187
+ </prod>
188
+ <imposto>
189
+ <ICMS>
190
+ <ICMS00>
191
+ <orig>0</orig>
192
+ <CST>00</CST>
193
+ <modBC>3</modBC>
194
+ <vBC>49.23</vBC>
195
+ <pICMS>12.00</pICMS>
196
+ <vICMS>5.90</vICMS>
197
+ </ICMS00>
198
+ </ICMS>
199
+ <IPI>
200
+ <cEnq>999</cEnq>
201
+ <IPITrib>
202
+ <CST>50</CST>
203
+ <vBC>49.23</vBC>
204
+ <pIPI>5.00</pIPI>
205
+ <vIPI>2.46</vIPI>
206
+ </IPITrib>
207
+ </IPI>
208
+ </imposto>
209
+ </det>
210
+ <det nItem="2">
211
+ <prod>
212
+ <cProd>REF 05</cProd>
213
+ <xProd>Produto com CST 00 - Estrangeiro - ICMS - IPI</xProd>
214
+ <NCM>90303329</NCM>
215
+ <EXTIPI>00</EXTIPI>
216
+ <CFOP>5101</CFOP>
217
+ <uCom>PC</uCom>
218
+ <qCom>1.00</qCom>
219
+ <vUnCom>49.23</vUnCom>
220
+ <vProd>49.23</vProd>
221
+ <xPed>98001921</xPed>
222
+ <nItemPed>10</nItemPed>
223
+ </prod>
224
+ <imposto>
225
+ <ICMS>
226
+ <ICMS00>
227
+ <orig>1</orig>
228
+ <CST>00</CST>
229
+ <modBC>3</modBC>
230
+ <vBC>49.23</vBC>
231
+ <pICMS>12.00</pICMS>
232
+ <vICMS>5.90</vICMS>
233
+ </ICMS00>
234
+ </ICMS>
235
+ <IPI>
236
+ <cEnq>999</cEnq>
237
+ <IPITrib>
238
+ <CST>50</CST>
239
+ <vBC>49.23</vBC>
240
+ <pIPI>5.00</pIPI>
241
+ <vIPI>2.46</vIPI>
242
+ </IPITrib>
243
+ </IPI>
244
+ </imposto>
245
+ </det>
203
246
  eos
204
247
  end
205
248
 
@@ -213,34 +256,30 @@ describe BrDanfe::DanfeLib::DetBody do
213
256
  end
214
257
 
215
258
  context "with FCI" do
216
- let(:xml_as_string) do
259
+ let(:products) do
217
260
  <<-eos
218
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
219
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
220
- <det nItem="1">
221
- <prod>
222
- <cProd>REF 06</cProd>
223
- <xProd>Produto com FCI</xProd>
224
- <NCM>90303329</NCM>
225
- <EXTIPI>00</EXTIPI>
226
- <CFOP>5101</CFOP>
227
- <uCom>PC</uCom>
228
- <qCom>1.00</qCom>
229
- <vUnCom>49.23</vUnCom>
230
- <vProd>49.23</vProd>
231
- <nFCI>12232531-74B2-4FDD-87A6-CF0AD3E55386</nFCI>
232
- </prod>
233
- <imposto>
234
- <ICMS>
235
- <ICMS00>
236
- <orig>0</orig>
237
- <CST>00</CST>
238
- </ICMS00>
239
- </ICMS>
240
- </imposto>
241
- </det>
242
- </infNFe>
243
- </NFe>
261
+ <det nItem="1">
262
+ <prod>
263
+ <cProd>REF 06</cProd>
264
+ <xProd>Produto com FCI</xProd>
265
+ <NCM>90303329</NCM>
266
+ <EXTIPI>00</EXTIPI>
267
+ <CFOP>5101</CFOP>
268
+ <uCom>PC</uCom>
269
+ <qCom>1.00</qCom>
270
+ <vUnCom>49.23</vUnCom>
271
+ <vProd>49.23</vProd>
272
+ <nFCI>12232531-74B2-4FDD-87A6-CF0AD3E55386</nFCI>
273
+ </prod>
274
+ <imposto>
275
+ <ICMS>
276
+ <ICMS00>
277
+ <orig>0</orig>
278
+ <CST>00</CST>
279
+ </ICMS00>
280
+ </ICMS>
281
+ </imposto>
282
+ </det>
244
283
  eos
245
284
  end
246
285
 
@@ -254,36 +293,32 @@ describe BrDanfe::DanfeLib::DetBody do
254
293
  end
255
294
 
256
295
  context "with ICMS ST" do
257
- let(:xml_as_string) do
296
+ let(:products) do
258
297
  <<-eos
259
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
260
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
261
- <det nItem="1">
262
- <prod>
263
- <cProd>3</cProd>
264
- <xProd>Produto Com Csosn 201 - ICMS ST</xProd>
265
- <NCM>45678901</NCM>
266
- <CFOP>5401</CFOP>
267
- <uCom>UN</uCom>
268
- <qCom>6.00</qCom>
269
- <vUnCom>1.03</vUnCom>
270
- <vProd>6.18</vProd>
271
- </prod>
272
- <imposto>
273
- <ICMS>
274
- <ICMSSN201>
275
- <orig>0</orig>
276
- <CSOSN>201</CSOSN>
277
- <pMVAST>24.00</pMVAST>
278
- <vBCST>7.66</vBCST>
279
- <pICMSST>17.00</pICMSST>
280
- <vICMSST>0.25</vICMSST>
281
- </ICMSSN201>
282
- </ICMS>
283
- </imposto>
284
- </det>
285
- </infNFe>
286
- </NFe>
298
+ <det nItem="1">
299
+ <prod>
300
+ <cProd>3</cProd>
301
+ <xProd>Produto Com Csosn 201 - ICMS ST</xProd>
302
+ <NCM>45678901</NCM>
303
+ <CFOP>5401</CFOP>
304
+ <uCom>UN</uCom>
305
+ <qCom>6.00</qCom>
306
+ <vUnCom>1.03</vUnCom>
307
+ <vProd>6.18</vProd>
308
+ </prod>
309
+ <imposto>
310
+ <ICMS>
311
+ <ICMSSN201>
312
+ <orig>0</orig>
313
+ <CSOSN>201</CSOSN>
314
+ <pMVAST>24.00</pMVAST>
315
+ <vBCST>7.66</vBCST>
316
+ <pICMSST>17.00</pICMSST>
317
+ <vICMSST>0.25</vICMSST>
318
+ </ICMSSN201>
319
+ </ICMS>
320
+ </imposto>
321
+ </det>
287
322
  eos
288
323
  end
289
324
 
@@ -297,26 +332,20 @@ describe BrDanfe::DanfeLib::DetBody do
297
332
  end
298
333
 
299
334
  context "when the unit price of the product has a custom precision" do
300
- subject { described_class.new(pdf, xml) }
301
-
302
- let(:xml_as_string) do
335
+ let(:products) do
303
336
  <<-eos
304
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
305
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
306
- <det nItem="1">
307
- <prod>
308
- <cProd>3</cProd>
309
- <xProd>Produto Com Csosn 201 - ICMS ST</xProd>
310
- <NCM>45678901</NCM>
311
- <CFOP>5401</CFOP>
312
- <uCom>UN</uCom>
313
- <qCom>6.00</qCom>
314
- <vUnCom>1.1312</vUnCom>
315
- <vProd>6.79</vProd>
316
- </prod>
317
- </det>
318
- </infNFe>
319
- </NFe>
337
+ <det nItem="1">
338
+ <prod>
339
+ <cProd>3</cProd>
340
+ <xProd>Produto Com Csosn 201 - ICMS ST</xProd>
341
+ <NCM>45678901</NCM>
342
+ <CFOP>5401</CFOP>
343
+ <uCom>UN</uCom>
344
+ <qCom>6.00</qCom>
345
+ <vUnCom>1.1312</vUnCom>
346
+ <vProd>6.79</vProd>
347
+ </prod>
348
+ </det>
320
349
  eos
321
350
  end
322
351
 
@@ -330,26 +359,20 @@ describe BrDanfe::DanfeLib::DetBody do
330
359
  end
331
360
 
332
361
  context "when the quantity of the product has a custom precision" do
333
- subject { described_class.new(pdf, xml) }
334
-
335
- let(:xml_as_string) do
362
+ let(:products) do
336
363
  <<-eos
337
- <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
338
- <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
339
- <det nItem="1">
340
- <prod>
341
- <cProd>3</cProd>
342
- <xProd>Produto Com Csosn 201 - ICMS ST</xProd>
343
- <NCM>45678901</NCM>
344
- <CFOP>5401</CFOP>
345
- <uCom>UN</uCom>
346
- <qCom>6.4545</qCom>
347
- <vUnCom>1.03</vUnCom>
348
- <vProd>6.65</vProd>
349
- </prod>
350
- </det>
351
- </infNFe>
352
- </NFe>
364
+ <det nItem="1">
365
+ <prod>
366
+ <cProd>3</cProd>
367
+ <xProd>Produto Com Csosn 201 - ICMS ST</xProd>
368
+ <NCM>45678901</NCM>
369
+ <CFOP>5401</CFOP>
370
+ <uCom>UN</uCom>
371
+ <qCom>6.4545</qCom>
372
+ <vUnCom>1.03</vUnCom>
373
+ <vProd>6.65</vProd>
374
+ </prod>
375
+ </det>
353
376
  eos
354
377
  end
355
378
 
@@ -361,5 +384,68 @@ describe BrDanfe::DanfeLib::DetBody do
361
384
  expect("#{base_dir}det_body#render-quantity_with_custom_precision.pdf").to have_same_content_of file: output_pdf
362
385
  end
363
386
  end
387
+
388
+ context "when there is ISSQN" do
389
+ let(:has_issqn) { true }
390
+ let(:products) { "#{product_1}\n#{product_2}" * 10 }
391
+
392
+ it "renders xml to the pdf" do
393
+ expect(File.exist?(output_pdf)).to be_falsey
394
+
395
+ pdf.render_file output_pdf
396
+
397
+ expect("#{base_dir}det_body#render-with_issqn.pdf").to have_same_content_of file: output_pdf
398
+ end
399
+ end
400
+
401
+ context "when there isn't ISSQN" do
402
+ let(:products) { "#{product_1}\n#{product_2}" * 10 }
403
+
404
+ it "renders xml to the pdf" do
405
+ expect(File.exist?(output_pdf)).to be_falsey
406
+
407
+ pdf.render_file output_pdf
408
+
409
+ expect("#{base_dir}det_body#render-without_issqn.pdf").to have_same_content_of file: output_pdf
410
+ end
411
+ end
412
+
413
+ context "with infAdProd" do
414
+ let(:products) { "#{product_2}" }
415
+
416
+ it "renders xml to the pdf" do
417
+ expect(File.exist?(output_pdf)).to be_falsey
418
+
419
+ pdf.render_file output_pdf
420
+
421
+ expect("#{base_dir}det_body#render-with_infadprod.pdf").to have_same_content_of file: output_pdf
422
+ end
423
+ end
424
+
425
+ context "when the product table occupies more than one page" do
426
+ context "when the product table occupies two pages" do
427
+ let(:products) { ("#{product_1}\n#{product_2}" * 22) + "\n#{product_1}" }
428
+
429
+ it "renders xml to the pdf" do
430
+ expect(File.exist?(output_pdf)).to be_falsey
431
+
432
+ pdf.render_file output_pdf
433
+
434
+ expect("#{base_dir}det_body#render-two_pages.pdf").to have_same_content_of file: output_pdf
435
+ end
436
+ end
437
+
438
+ context "when the product table occupies three pages" do
439
+ let(:products) { ("#{product_1}\n#{product_2}" * 23) }
440
+
441
+ it "renders xml to the pdf" do
442
+ expect(File.exist?(output_pdf)).to be_falsey
443
+
444
+ pdf.render_file output_pdf
445
+
446
+ expect("#{base_dir}det_body#render-three_pages.pdf").to have_same_content_of file: output_pdf
447
+ end
448
+ end
449
+ end
364
450
  end
365
451
  end