|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\EFD\Elements\Contribuicoes; |
|
4
|
|
|
|
|
5
|
|
|
use NFePHP\Common\Keys; |
|
6
|
|
|
use NFePHP\EFD\Common\Element; |
|
7
|
|
|
use NFePHP\EFD\Common\ElementInterface; |
|
8
|
|
|
use \stdClass; |
|
9
|
|
|
|
|
10
|
|
View Code Duplication |
class C800 extends Element implements ElementInterface |
|
|
|
|
|
|
11
|
|
|
{ |
|
12
|
|
|
const REG = 'C800'; |
|
13
|
|
|
const LEVEL = 3; |
|
14
|
|
|
const PARENT = 'C001'; |
|
15
|
|
|
|
|
16
|
|
|
protected $parameters = [ |
|
17
|
|
|
'COD_MOD' => [ |
|
18
|
|
|
'type' => 'string', |
|
19
|
|
|
'regex' => '^(00|01|02|03)$', |
|
20
|
|
|
'required' => false, |
|
21
|
|
|
'info' => 'Código do modelo do documento fiscal, conforme a Tabela 4.1.1', |
|
22
|
|
|
'format' => '' |
|
23
|
|
|
], |
|
24
|
|
|
'COD_SIT' => [ |
|
25
|
|
|
'type' => 'numeric', |
|
26
|
|
|
'regex' => '^(\d{0,2})$', |
|
27
|
|
|
'required' => false, |
|
28
|
|
|
'info' => 'Código da situação do documento fiscal, conforme a Tabela 4.1.2', |
|
29
|
|
|
'format' => '' |
|
30
|
|
|
], |
|
31
|
|
|
'NUM_CFE' => [ |
|
32
|
|
|
'type' => 'numeric', |
|
33
|
|
|
'regex' => '^(\d{0,9})$', |
|
34
|
|
|
'required' => false, |
|
35
|
|
|
'info' => 'Número do Cupom Fiscal Eletrônico', |
|
36
|
|
|
'format' => '' |
|
37
|
|
|
], |
|
38
|
|
|
'DT_DOC' => [ |
|
39
|
|
|
'type' => 'string', |
|
40
|
|
|
'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$', |
|
41
|
|
|
'required' => false, |
|
42
|
|
|
'info' => 'Data da emissão do Cupom Fiscal Eletrônico', |
|
43
|
|
|
'format' => '' |
|
44
|
|
|
], |
|
45
|
|
|
'VL_CFE' => [ |
|
46
|
|
|
'type' => 'numeric', |
|
47
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
48
|
|
|
'required' => false, |
|
49
|
|
|
'info' => 'Valor total do Cupom Fiscal Eletrônico', |
|
50
|
|
|
'format' => '15v2' |
|
51
|
|
|
], |
|
52
|
|
|
'VL_PIS' => [ |
|
53
|
|
|
'type' => 'numeric', |
|
54
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
55
|
|
|
'required' => false, |
|
56
|
|
|
'info' => 'Valor total do PIS', |
|
57
|
|
|
'format' => '15v2' |
|
58
|
|
|
], |
|
59
|
|
|
'VL_COFINS' => [ |
|
60
|
|
|
'type' => 'numeric', |
|
61
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
62
|
|
|
'required' => false, |
|
63
|
|
|
'info' => 'Valor total da COFINS', |
|
64
|
|
|
'format' => '15v2' |
|
65
|
|
|
], |
|
66
|
|
|
'CNPJ_CPF' => [ |
|
67
|
|
|
'type' => 'string', |
|
68
|
|
|
'regex' => '^[0-9]{14}$', |
|
69
|
|
|
'required' => false, |
|
70
|
|
|
'info' => 'CNPJ ou CPF do destinatário', |
|
71
|
|
|
'format' => '' |
|
72
|
|
|
], |
|
73
|
|
|
'NR_SAT' => [ |
|
74
|
|
|
'type' => 'numeric', |
|
75
|
|
|
'regex' => '^(\d{0,9})$', |
|
76
|
|
|
'required' => false, |
|
77
|
|
|
'info' => 'Número de Série do equipamento SAT', |
|
78
|
|
|
'format' => '' |
|
79
|
|
|
], |
|
80
|
|
|
'CHV_CFE' => [ |
|
81
|
|
|
'type' => 'numeric', |
|
82
|
|
|
'regex' => '^([0-9]{44})?$', |
|
83
|
|
|
'required' => false, |
|
84
|
|
|
'info' => 'Chave do Cupom Fiscal Eletrônico', |
|
85
|
|
|
'format' => '' |
|
86
|
|
|
], |
|
87
|
|
|
'VL_DESC' => [ |
|
88
|
|
|
'type' => 'numeric', |
|
89
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
90
|
|
|
'required' => false, |
|
91
|
|
|
'info' => 'Valor total do desconto/exclusão sobre item', |
|
92
|
|
|
'format' => '15v2' |
|
93
|
|
|
], |
|
94
|
|
|
'VL_MERC' => [ |
|
95
|
|
|
'type' => 'numeric', |
|
96
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
97
|
|
|
'required' => false, |
|
98
|
|
|
'info' => 'Valor total das mercadorias e serviços', |
|
99
|
|
|
'format' => '15v2' |
|
100
|
|
|
], |
|
101
|
|
|
'VL_OUT_DA' => [ |
|
102
|
|
|
'type' => 'numeric', |
|
103
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
104
|
|
|
'required' => false, |
|
105
|
|
|
'info' => 'Valor de outras desp. Acessórias (acréscimo)', |
|
106
|
|
|
'format' => '15v2' |
|
107
|
|
|
], |
|
108
|
|
|
'VL_ICMS' => [ |
|
109
|
|
|
'type' => 'numeric', |
|
110
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
111
|
|
|
'required' => false, |
|
112
|
|
|
'info' => 'Valor do ICMS', |
|
113
|
|
|
'format' => '15v2' |
|
114
|
|
|
], |
|
115
|
|
|
'VL_PIS_ST' => [ |
|
116
|
|
|
'type' => 'numeric', |
|
117
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
118
|
|
|
'required' => false, |
|
119
|
|
|
'info' => 'Valor total do PIS retido por subst. trib.', |
|
120
|
|
|
'format' => '15v2' |
|
121
|
|
|
], |
|
122
|
|
|
'VL_COFINS_ST' => [ |
|
123
|
|
|
'type' => 'numeric', |
|
124
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
125
|
|
|
'required' => false, |
|
126
|
|
|
'info' => 'Valor total da COFINS retido por subst. trib.', |
|
127
|
|
|
'format' => '15v2' |
|
128
|
|
|
], |
|
129
|
|
|
|
|
130
|
|
|
]; |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Constructor |
|
134
|
|
|
* @param \stdClass $std |
|
135
|
|
|
*/ |
|
136
|
|
|
public function __construct(\stdClass $std) |
|
137
|
|
|
{ |
|
138
|
|
|
parent::__construct(self::REG); |
|
139
|
|
|
$this->std = $this->standarize($std); |
|
140
|
|
|
$this->postValidation(); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function postValidation() |
|
144
|
|
|
{ |
|
145
|
|
|
if (!empty($this->std->chv_cfe) and !Keys::isValid($this->std->chv_cfe)) { |
|
146
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
147
|
|
|
" Dígito verificador incorreto no campo chave do " . |
|
148
|
|
|
"cupom fiscal eletronica (CHV_CFE)"); |
|
149
|
|
|
} |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|
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.