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.
- checksums.yaml +4 -4
- data/Gemfile.lock +25 -25
- data/lib/br_danfe/danfe.rb +52 -25
- data/lib/br_danfe/danfe_lib/det_body.rb +105 -46
- data/lib/br_danfe/danfe_lib/document.rb +3 -7
- data/lib/br_danfe/danfe_lib/emit_header.rb +36 -20
- data/lib/br_danfe/danfe_lib/infadic.rb +12 -12
- data/lib/br_danfe/danfe_lib/issqn.rb +19 -8
- data/lib/br_danfe/version.rb +1 -1
- data/spec/features/danfe_spec.rb +45 -0
- data/spec/fixtures/nfe/lib/det_body#render-csosn.pdf +1932 -332
- data/spec/fixtures/nfe/lib/det_body#render-cst.pdf +1182 -138
- data/spec/fixtures/nfe/lib/det_body#render-fci.pdf +809 -43
- data/spec/fixtures/nfe/lib/det_body#render-icms_st.pdf +809 -43
- data/spec/fixtures/nfe/lib/det_body#render-quantity_with_custom_precision.pdf +807 -41
- data/spec/fixtures/nfe/lib/det_body#render-three_pages.pdf +22414 -0
- data/spec/fixtures/nfe/lib/det_body#render-two_pages.pdf +21442 -0
- data/spec/fixtures/nfe/lib/det_body#render-unit_price_with_custom_precision.pdf +807 -41
- data/spec/fixtures/nfe/lib/det_body#render-with_infadprod.pdf +1012 -0
- data/spec/fixtures/nfe/lib/det_body#render-with_issqn.pdf +10124 -0
- data/spec/fixtures/nfe/lib/det_body#render-without_issqn.pdf +10124 -0
- data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +792 -0
- data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +88 -8
- data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +85 -5
- data/spec/fixtures/nfe/lib/infadic#render-footer_information.pdf +111 -0
- data/spec/fixtures/nfe/lib/{issqn#render.pdf → issqn#render-with_issqn.pdf} +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-with_one_issqn_value.pdf +129 -0
- data/spec/fixtures/nfe/lib/issqn#render-without_issqn.pdf +54 -0
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +2190 -1067
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +2183 -1059
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +8803 -3208
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +1825 -1258
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +8609 -3014
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +2664 -1541
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +4701 -1909
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +8660 -0
- data/spec/fixtures/nfe/v3.10/with_footer.xml +621 -0
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +8646 -0
- data/spec/fixtures/nfe/v3.10/with_issqn.xml +621 -0
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +25420 -0
- data/spec/fixtures/nfe/v3.10/with_three_pages.xml +1281 -0
- data/spec/fixtures/nfe/v3.10/withot_issqn.fixture.pdf +10338 -0
- data/spec/fixtures/nfe/v3.10/withot_issqn.xml +688 -0
- data/spec/lib/danfe_lib/det_body_spec.rb +350 -264
- data/spec/lib/danfe_lib/emit_header_spec.rb +42 -18
- data/spec/lib/danfe_lib/issqn_spec.rb +39 -7
- metadata +38 -14
- data/lib/br_danfe/danfe_lib/det_header.rb +0 -40
- data/lib/br_danfe/danfe_lib/emit.rb +0 -23
- data/spec/fixtures/nfe/lib/det_header#render.pdf +0 -207
- data/spec/fixtures/nfe/lib/emit#render.pdf +0 -143
- data/spec/lib/danfe_lib/det_header_spec.rb +0 -26
- 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(:
|
70
|
+
let(:products) do
|
20
71
|
<<-eos
|
21
|
-
<
|
22
|
-
<
|
23
|
-
<
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
<
|
35
|
-
<
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
<
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<
|
55
|
-
<
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
<
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
<
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
<
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
<
|
99
|
-
<
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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(:
|
172
|
+
let(:products) do
|
126
173
|
<<-eos
|
127
|
-
<
|
128
|
-
<
|
129
|
-
<
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
<
|
144
|
-
<
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
<
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
<
|
180
|
-
<
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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(:
|
259
|
+
let(:products) do
|
217
260
|
<<-eos
|
218
|
-
<
|
219
|
-
<
|
220
|
-
<
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
<
|
234
|
-
<
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
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(:
|
296
|
+
let(:products) do
|
258
297
|
<<-eos
|
259
|
-
<
|
260
|
-
<
|
261
|
-
<
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
<
|
273
|
-
|
274
|
-
<
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
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
|
-
|
301
|
-
|
302
|
-
let(:xml_as_string) do
|
335
|
+
let(:products) do
|
303
336
|
<<-eos
|
304
|
-
<
|
305
|
-
<
|
306
|
-
<
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
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
|
-
|
334
|
-
|
335
|
-
let(:xml_as_string) do
|
362
|
+
let(:products) do
|
336
363
|
<<-eos
|
337
|
-
<
|
338
|
-
<
|
339
|
-
<
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
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
|