|
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
|
|
|
class C470 extends Element implements ElementInterface |
|
10
|
|
|
{ |
|
11
|
|
|
const REG = 'C470'; |
|
12
|
|
|
const LEVEL = 5; |
|
13
|
|
|
const PARENT = 'C400'; |
|
14
|
|
|
|
|
15
|
|
|
protected $parameters = [ |
|
16
|
|
|
'COD_ITEM' => [ |
|
17
|
|
|
'type' => 'string', |
|
18
|
|
|
'regex' => '^.{1,60}$', |
|
19
|
|
|
'required' => true, |
|
20
|
|
|
'info' => 'Código do item (campo 02 do Registro 0200)', |
|
21
|
|
|
'format' => '' |
|
22
|
|
|
], |
|
23
|
|
|
'QTD' => [ |
|
24
|
|
|
'type' => 'numeric', |
|
25
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
26
|
|
|
'required' => true, |
|
27
|
|
|
'info' => 'Quantidade do item', |
|
28
|
|
|
'format' => '15v3' |
|
29
|
|
|
], |
|
30
|
|
|
'QTD_CANC' => [ |
|
31
|
|
|
'type' => 'numeric', |
|
32
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
33
|
|
|
'required' => false, |
|
34
|
|
|
'info' => 'Quantidade cancelada, no caso de cancelamento parcial de item', |
|
35
|
|
|
'format' => '15v3' |
|
36
|
|
|
], |
|
37
|
|
|
'UNID' => [ |
|
38
|
|
|
'type' => 'string', |
|
39
|
|
|
'regex' => '^.{1,6}$', |
|
40
|
|
|
'required' => true, |
|
41
|
|
|
'info' => 'Unidade do item (Campo 02 do registro 0190)', |
|
42
|
|
|
'format' => '' |
|
43
|
|
|
], |
|
44
|
|
|
'VL_ITEM' => [ |
|
45
|
|
|
'type' => 'numeric', |
|
46
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
47
|
|
|
'required' => true, |
|
48
|
|
|
'info' => 'Valor total do item', |
|
49
|
|
|
'format' => '15v2' |
|
50
|
|
|
], |
|
51
|
|
|
'CST_ICMS' => [ |
|
52
|
|
|
'type' => 'numeric', |
|
53
|
|
|
'regex' => '^(\d{3})$', |
|
54
|
|
|
'required' => true, |
|
55
|
|
|
'info' => 'Código da Situação Tributária', |
|
56
|
|
|
'format' => '' |
|
57
|
|
|
], |
|
58
|
|
|
'CFOP' => [ |
|
59
|
|
|
'type' => 'numeric', |
|
60
|
|
|
'regex' => '^(\d{4})$', |
|
61
|
|
|
'required' => true, |
|
62
|
|
|
'info' => 'Código Fiscal de Operação e Prestação', |
|
63
|
|
|
'format' => '' |
|
64
|
|
|
], |
|
65
|
|
|
'ALIQ_ICMS' => [ |
|
66
|
|
|
'type' => 'numeric', |
|
67
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
68
|
|
|
'required' => false, |
|
69
|
|
|
'info' => 'Alíquota do ICMS – Carga tributária efetiva em percentual', |
|
70
|
|
|
'format' => '6v2' |
|
71
|
|
|
], |
|
72
|
|
|
'VL_PIS' => [ |
|
73
|
|
|
'type' => 'numeric', |
|
74
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
75
|
|
|
'required' => false, |
|
76
|
|
|
'info' => 'Valor do PIS', |
|
77
|
|
|
'format' => '15v2' |
|
78
|
|
|
], |
|
79
|
|
|
'VL_COFINS' => [ |
|
80
|
|
|
'type' => 'numeric', |
|
81
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
82
|
|
|
'required' => false, |
|
83
|
|
|
'info' => 'Valor da COFINS', |
|
84
|
|
|
'format' => '15v2' |
|
85
|
|
|
], |
|
86
|
|
|
]; |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Constructor |
|
90
|
|
|
* @param \stdClass $std |
|
91
|
|
|
*/ |
|
92
|
|
|
public function __construct(\stdClass $std) |
|
93
|
|
|
{ |
|
94
|
|
|
parent::__construct(self::REG); |
|
95
|
|
|
$this->std = $this->standarize($std); |
|
96
|
|
|
$this->postValidation(); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
View Code Duplication |
public function postValidation() |
|
|
|
|
|
|
100
|
|
|
{ |
|
101
|
|
|
if ($this->values->vl_item <= 0) { |
|
102
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
103
|
|
|
" O Valor total do item" . |
|
104
|
|
|
"(VL_ITEM) deve ser maior que 0"); |
|
105
|
|
|
} |
|
106
|
|
|
if ($this->values->qtd <= 0) { |
|
107
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
108
|
|
|
" Quantidade total do item" . |
|
109
|
|
|
"(QTD) deve ser maior que 0"); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.