|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\EFD\Elements\ICMSIPI; |
|
4
|
|
|
|
|
5
|
|
|
use NFePHP\Common\Keys; |
|
6
|
|
|
use NFePHP\EFD\Common\Element; |
|
7
|
|
|
use NFePHP\EFD\Common\ElementInterface; |
|
8
|
|
|
use \stdClass; |
|
9
|
|
|
|
|
10
|
|
|
class C116 extends Element implements ElementInterface |
|
11
|
|
|
{ |
|
12
|
|
|
const REG = 'C116'; |
|
13
|
|
|
const LEVEL = 4; |
|
14
|
|
|
const PARENT = 'C110'; |
|
15
|
|
|
|
|
16
|
|
|
protected $parameters = [ |
|
17
|
|
|
'COD_MOD' => [ |
|
18
|
|
|
'type' => 'string', |
|
19
|
|
|
'regex' => '^(59)+$', |
|
20
|
|
|
'required' => true, |
|
21
|
|
|
'info' => 'Código do modelo do documento fiscalValor total do estoque', |
|
22
|
|
|
'format' => '' |
|
23
|
|
|
], |
|
24
|
|
|
'NR_SAT' => [ |
|
25
|
|
|
'type' => 'numeric', |
|
26
|
|
|
'regex' => '^([0-9]{9})+$', |
|
27
|
|
|
'required' => true, |
|
28
|
|
|
'info' => 'Número de Série do equipamento SAT', |
|
29
|
|
|
'format' => '' |
|
30
|
|
|
], |
|
31
|
|
|
'CHV_CFE' => [ |
|
32
|
|
|
'type' => 'numeric', |
|
33
|
|
|
'regex' => '^([0-9]{44})?$', |
|
34
|
|
|
'required' => false, |
|
35
|
|
|
'info' => 'Chave do Cupom Fiscal Eletrônico', |
|
36
|
|
|
'format' => '' |
|
37
|
|
|
], |
|
38
|
|
|
'NUM_CFE' => [ |
|
39
|
|
|
'type' => 'numeric', |
|
40
|
|
|
'regex' => '^([0-9]{6})?$', |
|
41
|
|
|
'required' => false, |
|
42
|
|
|
'info' => 'Número do Cupom Fiscal Eletrônico', |
|
43
|
|
|
'format' => '' |
|
44
|
|
|
], |
|
45
|
|
|
'DT_DOC' => [ |
|
46
|
|
|
'type' => 'string', |
|
47
|
|
|
'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$', |
|
48
|
|
|
'required' => false, |
|
49
|
|
|
'info' => 'Data da emissão do documento fiscal', |
|
50
|
|
|
'format' => '' |
|
51
|
|
|
], |
|
52
|
|
|
]; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Constructor |
|
56
|
|
|
* @param \stdClass $std |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __construct(\stdClass $std) |
|
59
|
|
|
{ |
|
60
|
|
|
parent::__construct(self::REG); |
|
61
|
|
|
$this->std = $this->standarize($std); |
|
62
|
|
|
$this->postValidation(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
public function postValidation() |
|
67
|
|
|
{ |
|
68
|
|
|
/** |
|
69
|
|
|
* Verifica a chave do cupom fiscal eletronico |
|
70
|
|
|
*/ |
|
71
|
|
|
if (!empty($this->std->chv_cfe) and !Keys::isValid($this->std->chv_cfe)) { |
|
72
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
73
|
|
|
" Dígito verificador incorreto no campo campo chave do " . |
|
74
|
|
|
"cupom fiscal eletronico (CHV_CFE)"); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
return true; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|