|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\EFD\Elements\ICMSIPI; |
|
4
|
|
|
|
|
5
|
|
|
use NFePHP\EFD\Common\Element; |
|
6
|
|
|
use NFePHP\EFD\Common\ElementInterface; |
|
7
|
|
|
use \stdClass; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* REGISTRO C170: ITENS DO DOCUMENTO (CÓDIGO 01, 1B, 04 e 55). |
|
11
|
|
|
* Registro obrigatório para discriminar os itens da nota fiscal (mercadorias e/ou serviços constantes em notas |
|
12
|
|
|
* conjugadas), inclusive em operações de entrada de mercadorias acompanhadas |
|
13
|
|
|
* de Nota Fiscal Eletrônica (NF-e) de emissão de terceiros. |
|
14
|
|
|
* @package NFePHP\EFD\Elements\ICMSIPI |
|
15
|
|
|
*/ |
|
16
|
|
|
class C170 extends Element implements ElementInterface |
|
17
|
|
|
{ |
|
18
|
|
|
const REG = 'C170'; |
|
19
|
|
|
const LEVEL = 3; |
|
20
|
|
|
const PARENT = ''; |
|
21
|
|
|
|
|
22
|
|
|
protected $parameters = [ |
|
23
|
|
|
'NUM_ITEM' => [ |
|
24
|
|
|
'type' => 'numeric', |
|
25
|
|
|
'regex' => '^(\d{1,3})$', |
|
26
|
|
|
'required' => true, |
|
27
|
|
|
'info' => 'Número sequencial do item no documento fiscal', |
|
28
|
|
|
'format' => '' |
|
29
|
|
|
], |
|
30
|
|
|
'COD_ITEM' => [ |
|
31
|
|
|
'type' => 'string', |
|
32
|
|
|
'regex' => '^.{1,60}$', |
|
33
|
|
|
'required' => true, |
|
34
|
|
|
'info' => 'Código do item (campo 02 do Registro 0200)', |
|
35
|
|
|
'format' => '' |
|
36
|
|
|
], |
|
37
|
|
|
'DESCR_COMPL' => [ |
|
38
|
|
|
'type' => 'string', |
|
39
|
|
|
'regex' => '^(.*)$', |
|
40
|
|
|
'required' => false, |
|
41
|
|
|
'info' => 'Descrição complementar do item como adotado no documento fiscal', |
|
42
|
|
|
'format' => '' |
|
43
|
|
|
], |
|
44
|
|
|
'QTD' => [ |
|
45
|
|
|
'type' => 'numeric', |
|
46
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
47
|
|
|
'required' => true, |
|
48
|
|
|
'info' => 'Quantidade do item', |
|
49
|
|
|
'format' => '15v5' |
|
50
|
|
|
], |
|
51
|
|
|
'UNID' => [ |
|
52
|
|
|
'type' => 'string', |
|
53
|
|
|
'regex' => '^.{1,6}$', |
|
54
|
|
|
'required' => true, |
|
55
|
|
|
'info' => 'Unidade do item (Campo 02 do registro 0190)', |
|
56
|
|
|
'format' => '' |
|
57
|
|
|
], |
|
58
|
|
|
'VL_ITEM' => [ |
|
59
|
|
|
'type' => 'numeric', |
|
60
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
61
|
|
|
'required' => true, |
|
62
|
|
|
'info' => 'Valor total do item (mercadorias ou serviços)', |
|
63
|
|
|
'format' => '15v2' |
|
64
|
|
|
], |
|
65
|
|
|
'VL_DESC' => [ |
|
66
|
|
|
'type' => 'numeric', |
|
67
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
68
|
|
|
'required' => false, |
|
69
|
|
|
'info' => 'Valor do desconto comercial', |
|
70
|
|
|
'format' => '15v2' |
|
71
|
|
|
], |
|
72
|
|
|
'IND_MOV' => [ |
|
73
|
|
|
'type' => 'string', |
|
74
|
|
|
'regex' => '^(0|1)$', |
|
75
|
|
|
'required' => true, |
|
76
|
|
|
'info' => 'Movimentação física do ITEM/PRODUTO: 0. SIM 1. NÃO', |
|
77
|
|
|
'format' => '' |
|
78
|
|
|
], |
|
79
|
|
|
'CST_ICMS' => [ |
|
80
|
|
|
'type' => 'numeric', |
|
81
|
|
|
'regex' => '^(\d{3})$', |
|
82
|
|
|
'required' => true, |
|
83
|
|
|
'info' => 'Código da Situação Tributária referente ao ICMS', |
|
84
|
|
|
'format' => '' |
|
85
|
|
|
], |
|
86
|
|
|
'CFOP' => [ |
|
87
|
|
|
'type' => 'numeric', |
|
88
|
|
|
'regex' => '^(\d{4})$', |
|
89
|
|
|
'required' => true, |
|
90
|
|
|
'info' => 'Código Fiscal de Operação e Prestação', |
|
91
|
|
|
'format' => '' |
|
92
|
|
|
], |
|
93
|
|
|
'COD_NAT' => [ |
|
94
|
|
|
'type' => 'string', |
|
95
|
|
|
'regex' => '^.{0,10}$', |
|
96
|
|
|
'required' => false, |
|
97
|
|
|
'info' => 'Código da natureza da operação (campo 02 do Registro 0400)', |
|
98
|
|
|
'format' => '' |
|
99
|
|
|
], |
|
100
|
|
|
'VL_BC_ICMS' => [ |
|
101
|
|
|
'type' => 'numeric', |
|
102
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
103
|
|
|
'required' => false, |
|
104
|
|
|
'info' => 'Valor da base de cálculo do ICMS', |
|
105
|
|
|
'format' => '15v2' |
|
106
|
|
|
], |
|
107
|
|
|
'ALIQ_ICMS' => [ |
|
108
|
|
|
'type' => 'numeric', |
|
109
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
110
|
|
|
'required' => false, |
|
111
|
|
|
'info' => 'Alíquota do ICMS', |
|
112
|
|
|
'format' => '6v2' |
|
113
|
|
|
], |
|
114
|
|
|
'VL_ICMS' => [ |
|
115
|
|
|
'type' => 'numeric', |
|
116
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
117
|
|
|
'required' => false, |
|
118
|
|
|
'info' => 'Valor do ICMS creditado/debitado', |
|
119
|
|
|
'format' => '15v2' |
|
120
|
|
|
], |
|
121
|
|
|
'VL_BC_ICMS_ST' => [ |
|
122
|
|
|
'type' => 'numeric', |
|
123
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
124
|
|
|
'required' => false, |
|
125
|
|
|
'info' => 'Valor da base de cálculo referente à substituição', |
|
126
|
|
|
'format' => '15v2' |
|
127
|
|
|
], |
|
128
|
|
|
'ALIQ_ST' => [ |
|
129
|
|
|
'type' => 'numeric', |
|
130
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
131
|
|
|
'required' => false, |
|
132
|
|
|
'info' => 'Alíquota do ICMS da substituição tributária na unidade da federação de destino', |
|
133
|
|
|
'format' => '15v2' |
|
134
|
|
|
], |
|
135
|
|
|
'VL_ICMS_ST' => [ |
|
136
|
|
|
'type' => 'numeric', |
|
137
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
138
|
|
|
'required' => false, |
|
139
|
|
|
'info' => 'Valor do ICMS referente à substituição tributária', |
|
140
|
|
|
'format' => '15v2' |
|
141
|
|
|
], |
|
142
|
|
|
'IND_APUR' => [ |
|
143
|
|
|
'type' => 'string', |
|
144
|
|
|
'regex' => '^(0|1)$', |
|
145
|
|
|
'required' => false, |
|
146
|
|
|
'info' => 'Indicador de período de apuração do IPI: 0 - Mensal; 1 - Decendial', |
|
147
|
|
|
'format' => '' |
|
148
|
|
|
], |
|
149
|
|
|
'CST_IPI' => [ |
|
150
|
|
|
'type' => 'string', |
|
151
|
|
|
'regex' => '^(00|01|02|03|04|05|49||50|51|52|53|54|55|99)$', |
|
152
|
|
|
'required' => false, |
|
153
|
|
|
'info' => 'Código da Situação Tributária referente ao IPI, conforme a Tabela indicada no item 4.3.2.', |
|
154
|
|
|
'format' => '' |
|
155
|
|
|
], |
|
156
|
|
|
'COD_ENQ' => [ |
|
157
|
|
|
'type' => 'string', |
|
158
|
|
|
'regex' => '^.{3}$', |
|
159
|
|
|
'required' => false, |
|
160
|
|
|
'info' => 'Código de enquadramento legal do IPI, conforme tabela indicada no item 4.5.3.', |
|
161
|
|
|
'format' => '' |
|
162
|
|
|
], |
|
163
|
|
|
'VL_BC_IPI' => [ |
|
164
|
|
|
'type' => 'numeric', |
|
165
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
166
|
|
|
'required' => false, |
|
167
|
|
|
'info' => 'Valor da base de cálculo do IPI', |
|
168
|
|
|
'format' => '15v2' |
|
169
|
|
|
], |
|
170
|
|
|
'ALIQ_IPI' => [ |
|
171
|
|
|
'type' => 'numeric', |
|
172
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
173
|
|
|
'required' => false, |
|
174
|
|
|
'info' => 'Alíquota do IPI', |
|
175
|
|
|
'format' => '6v2' |
|
176
|
|
|
], |
|
177
|
|
|
'VL_IPI' => [ |
|
178
|
|
|
'type' => 'numeric', |
|
179
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
180
|
|
|
'required' => false, |
|
181
|
|
|
'info' => 'Valor do IPI creditado/debitado', |
|
182
|
|
|
'format' => '15v2' |
|
183
|
|
|
], |
|
184
|
|
|
'CST_PIS' => [ |
|
185
|
|
|
'type' => 'numeric', |
|
186
|
|
|
'regex' => '^((0)([1-9]{1})|49|(5)([0-6]{1})|(6)([0-7]{1})|(7)([0-5]{1})|98|99)$', |
|
187
|
|
|
'required' => false, |
|
188
|
|
|
'info' => 'Código da Situação Tributária referente ao PIS.', |
|
189
|
|
|
'format' => '' |
|
190
|
|
|
], |
|
191
|
|
|
'VL_BC_PIS' => [ |
|
192
|
|
|
'type' => 'numeric', |
|
193
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
194
|
|
|
'required' => false, |
|
195
|
|
|
'info' => 'Valor da base de cálculo do PIS', |
|
196
|
|
|
'format' => '15v2' |
|
197
|
|
|
], |
|
198
|
|
|
'ALIQ_PIS' => [ |
|
199
|
|
|
'type' => 'numeric', |
|
200
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
201
|
|
|
'required' => false, |
|
202
|
|
|
'info' => 'Alíquota do PIS (em percentual)', |
|
203
|
|
|
'format' => '8v4' |
|
204
|
|
|
], |
|
205
|
|
|
'QUANT_BC_PIS' => [ |
|
206
|
|
|
'type' => 'numeric', |
|
207
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
208
|
|
|
'required' => false, |
|
209
|
|
|
'info' => 'Quantidade – Base de cálculo PIS', |
|
210
|
|
|
'format' => '15v2' |
|
211
|
|
|
], |
|
212
|
|
|
'ALIQ_PIS_R' => [ |
|
213
|
|
|
'type' => 'numeric', |
|
214
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
215
|
|
|
'required' => false, |
|
216
|
|
|
'info' => 'Alíquota do PIS (em reais)', |
|
217
|
|
|
'format' => '15v4' |
|
218
|
|
|
], |
|
219
|
|
|
'VL_PIS' => [ |
|
220
|
|
|
'type' => 'numeric', |
|
221
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
222
|
|
|
'required' => false, |
|
223
|
|
|
'info' => 'Valor do PIS', |
|
224
|
|
|
'format' => '15v2' |
|
225
|
|
|
], |
|
226
|
|
|
'CST_COFINS' => [ |
|
227
|
|
|
'type' => 'numeric', |
|
228
|
|
|
'regex' => '^((0)([1-9]{1})|49|(5)([0-6]{1})|(6)([0-7]{1})|(7)([0-5]{1})|98|99)$', |
|
229
|
|
|
'required' => false, |
|
230
|
|
|
'info' => 'Código da COFINS.', |
|
231
|
|
|
'format' => '' |
|
232
|
|
|
], |
|
233
|
|
|
'VL_BC_COFINS' => [ |
|
234
|
|
|
'type' => 'numeric', |
|
235
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
236
|
|
|
'required' => false, |
|
237
|
|
|
'info' => 'Valor da base de cálculo da COFINS', |
|
238
|
|
|
'format' => '15v2' |
|
239
|
|
|
], |
|
240
|
|
|
'ALIQ_COFINS' => [ |
|
241
|
|
|
'type' => 'numeric', |
|
242
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
243
|
|
|
'required' => false, |
|
244
|
|
|
'info' => 'Alíquota do COFINS (em percentual)', |
|
245
|
|
|
'format' => '8v4' |
|
246
|
|
|
], |
|
247
|
|
|
'QUANT_BC_COFINS' => [ |
|
248
|
|
|
'type' => 'numeric', |
|
249
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
250
|
|
|
'required' => false, |
|
251
|
|
|
'info' => 'Quantidade – Base de cálculo COFINS', |
|
252
|
|
|
'format' => '15v3' |
|
253
|
|
|
], |
|
254
|
|
|
'ALIQ_COFINS_R' => [ |
|
255
|
|
|
'type' => 'numeric', |
|
256
|
|
|
'regex' => '\d+(\.\d*)?|\.\d+$', |
|
257
|
|
|
'required' => false, |
|
258
|
|
|
'info' => 'Alíquota da COFINS (em reais)', |
|
259
|
|
|
'format' => '15v4' |
|
260
|
|
|
], |
|
261
|
|
|
'VL_COFINS' => [ |
|
262
|
|
|
'type' => 'numeric', |
|
263
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
264
|
|
|
'required' => false, |
|
265
|
|
|
'info' => 'Valor da COFINS', |
|
266
|
|
|
'format' => '15v2' |
|
267
|
|
|
], |
|
268
|
|
|
'COD_CTA' => [ |
|
269
|
|
|
'type' => 'string', |
|
270
|
|
|
'regex' => '^(.*)$', |
|
271
|
|
|
'required' => false, |
|
272
|
|
|
'info' => 'Código da debitada/creditada', |
|
273
|
|
|
'format' => '' |
|
274
|
|
|
], |
|
275
|
|
|
'VL_ABAT_NT' => [ |
|
276
|
|
|
'type' => 'numeric', |
|
277
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
278
|
|
|
'required' => false, |
|
279
|
|
|
'info' => 'Valor do abatimento não tributado e não comercial', |
|
280
|
|
|
'format' => '15v2' |
|
281
|
|
|
], |
|
282
|
|
|
]; |
|
283
|
|
|
|
|
284
|
|
|
/** |
|
285
|
|
|
* Constructor |
|
286
|
|
|
* @param \stdClass $std |
|
287
|
|
|
*/ |
|
288
|
|
|
public function __construct(\stdClass $std) |
|
289
|
|
|
{ |
|
290
|
|
|
parent::__construct(self::REG); |
|
291
|
|
|
$this->std = $this->standarize($std); |
|
292
|
|
|
$this->postValidation(); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
public function postValidation() |
|
296
|
|
|
{ |
|
297
|
|
|
if (((float) str_replace('.', '', str_replace(',', '.', $this->std->qtd))) < 0) { |
|
298
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
299
|
|
|
" O valor do campo Quantidade do item (QTD) deve ser positivo "); |
|
300
|
|
|
} |
|
301
|
|
|
return false; |
|
302
|
|
|
} |
|
303
|
|
|
} |
|
304
|
|
|
|