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 Z1320 extends Element implements ElementInterface |
10
|
|
|
{ |
11
|
|
|
const REG = '1320'; |
12
|
|
|
const LEVEL = 4; |
13
|
|
|
const PARENT = '1310'; |
14
|
|
|
|
15
|
|
|
protected $parameters = [ |
16
|
|
|
'NUM_BICO' => [ |
17
|
|
|
'type' => 'integer', |
18
|
|
|
'regex' => '^\d+$', |
19
|
|
|
'required' => true, |
20
|
|
|
'info' => 'Bico Ligado à Bomba', |
21
|
|
|
'format' => '' |
22
|
|
|
], |
23
|
|
|
'NR_INTERV' => [ |
24
|
|
|
'type' => 'integer', |
25
|
|
|
'regex' => '^\d+$', |
26
|
|
|
'required' => false, |
27
|
|
|
'info' => 'Número da intervenção', |
28
|
|
|
'format' => '' |
29
|
|
|
], |
30
|
|
|
'MOT_INTERV' => [ |
31
|
|
|
'type' => 'string', |
32
|
|
|
'regex' => '^.{1,50}$', |
33
|
|
|
'required' => false, |
34
|
|
|
'info' => 'Motivo da Intervenção', |
35
|
|
|
'format' => '' |
36
|
|
|
], |
37
|
|
|
'NOM_INTERV' => [ |
38
|
|
|
'type' => 'string', |
39
|
|
|
'regex' => '^.{1,30}$', |
40
|
|
|
'required' => false, |
41
|
|
|
'info' => 'Nome do Interventor', |
42
|
|
|
'format' => '' |
43
|
|
|
], |
44
|
|
|
'CNPJ_INTERV' => [ |
45
|
|
|
'type' => 'integer', |
46
|
|
|
'regex' => '^[0-9]{14}$', |
47
|
|
|
'required' => false, |
48
|
|
|
'info' => 'CNPJ da empresa responsável pela intervenção', |
49
|
|
|
'format' => '' |
50
|
|
|
], |
51
|
|
|
'CPF_INTERV' => [ |
52
|
|
|
'type' => 'integer', |
53
|
|
|
'regex' => '^[0-9]{11}$', |
54
|
|
|
'required' => false, |
55
|
|
|
'info' => 'CPF do técnico responsável pela intervenção', |
56
|
|
|
'format' => '' |
57
|
|
|
], |
58
|
|
|
'VAL_FECHA' => [ |
59
|
|
|
'type' => 'numeric', |
60
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
61
|
|
|
'required' => true, |
62
|
|
|
'info' => 'Valor da leitura final do contador, no fechamento do bico.', |
63
|
|
|
'format' => '15v3' |
64
|
|
|
], |
65
|
|
|
'VAL_ABERT' => [ |
66
|
|
|
'type' => 'numeric', |
67
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
68
|
|
|
'required' => true, |
69
|
|
|
'info' => 'Valor da leitura inicial do contador, na abertura do bico.', |
70
|
|
|
'format' => '15v3' |
71
|
|
|
], |
72
|
|
|
'VOL_AFERI' => [ |
73
|
|
|
'type' => 'numeric', |
74
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
75
|
|
|
'required' => false, |
76
|
|
|
'info' => 'Aferições da Bomba, em litros', |
77
|
|
|
'format' => '15v3' |
78
|
|
|
], |
79
|
|
|
'VOL_VENDAS' => [ |
80
|
|
|
'type' => 'numeric', |
81
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
82
|
|
|
'required' => true, |
83
|
|
|
'info' => 'Vendas (08 – 09 - 10 ) do bico , em litros', |
84
|
|
|
'format' => '15v3' |
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
|
|
|
/* |
102
|
|
|
* Campo 11 (VOL_VENDAS) Preenchimento: informar o volume de vendas por bico, ligado ao tanque, |
103
|
|
|
* que corresponde ao valor fornecido no campo VAL_FECHA menos a soma do campo VAL_ABERT com |
104
|
|
|
* o campo VOL_AFERI. |
105
|
|
|
*/ |
106
|
|
|
$diferenca = $this->values->val_fecha - $this->values->val_abert - $this->values->vol_aferi; |
107
|
|
|
if ($this->std->vol_vendas != number_format($diferenca, 3, ',', '')) { |
108
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] Informar o volume de vendas por bico, " |
109
|
|
|
."ligado ao tanque, que corresponde ao valor fornecido no campo VAL_FECHA menos a soma do campo " |
110
|
|
|
."VAL_ABERT com o campo VOL_AFERI."); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
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.