|
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 Z1310 extends Element implements ElementInterface |
|
10
|
|
|
{ |
|
11
|
|
|
const REG = '1310'; |
|
12
|
|
|
const LEVEL = 3; |
|
13
|
|
|
const PARENT = '1300'; |
|
14
|
|
|
|
|
15
|
|
|
protected $parameters = [ |
|
16
|
|
|
'NUM_TANQUE' => [ |
|
17
|
|
|
'type' => 'string', |
|
18
|
|
|
'regex' => '^.{1,3}$', |
|
19
|
|
|
'required' => true, |
|
20
|
|
|
'info' => 'Tanque que armazena o combustível.', |
|
21
|
|
|
'format' => '' |
|
22
|
|
|
], |
|
23
|
|
|
'ESTQ_ABERT' => [ |
|
24
|
|
|
'type' => 'numeric', |
|
25
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
26
|
|
|
'required' => true, |
|
27
|
|
|
'info' => 'Estoque no inicio do dia, em litros', |
|
28
|
|
|
'format' => '15v3' |
|
29
|
|
|
], |
|
30
|
|
|
'VOL_ENTR' => [ |
|
31
|
|
|
'type' => 'numeric', |
|
32
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
33
|
|
|
'required' => true, |
|
34
|
|
|
'info' => 'Volume Recebido no dia (em litros)', |
|
35
|
|
|
'format' => '15v3' |
|
36
|
|
|
], |
|
37
|
|
|
'VOL_DISP' => [ |
|
38
|
|
|
'type' => 'numeric', |
|
39
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
40
|
|
|
'required' => true, |
|
41
|
|
|
'info' => 'Volume Disponível (03 + 04), em litros', |
|
42
|
|
|
'format' => '15v3' |
|
43
|
|
|
], |
|
44
|
|
|
'VOL_SAIDAS' => [ |
|
45
|
|
|
'type' => 'numeric', |
|
46
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
47
|
|
|
'required' => true, |
|
48
|
|
|
'info' => 'Volume Total das Saídas, em litros', |
|
49
|
|
|
'format' => '15v3' |
|
50
|
|
|
], |
|
51
|
|
|
'ESTQ_ESCR' => [ |
|
52
|
|
|
'type' => 'numeric', |
|
53
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
54
|
|
|
'required' => true, |
|
55
|
|
|
'info' => 'Estoque Escritural(05 – 06), litros', |
|
56
|
|
|
'format' => '15v3' |
|
57
|
|
|
], |
|
58
|
|
|
'VAL_AJ_PERDA' => [ |
|
59
|
|
|
'type' => 'numeric', |
|
60
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
61
|
|
|
'required' => true, |
|
62
|
|
|
'info' => 'Valor da Perda, em litros', |
|
63
|
|
|
'format' => '15v3' |
|
64
|
|
|
], |
|
65
|
|
|
'VAL_AJ_GANHO' => [ |
|
66
|
|
|
'type' => 'numeric', |
|
67
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
68
|
|
|
'required' => true, |
|
69
|
|
|
'info' => 'Valor do ganho, em litros', |
|
70
|
|
|
'format' => '15v3' |
|
71
|
|
|
], |
|
72
|
|
|
'FECH_FISICO' => [ |
|
73
|
|
|
'type' => 'numeric', |
|
74
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
75
|
|
|
'required' => true, |
|
76
|
|
|
'info' => 'Volume aferido no tanque, em litros. Estoque de fechamento físico do tanque.', |
|
77
|
|
|
'format' => '15v3' |
|
78
|
|
|
] |
|
79
|
|
|
]; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Constructor |
|
83
|
|
|
* @param \stdClass $std |
|
84
|
|
|
*/ |
|
85
|
|
|
public function __construct(\stdClass $std) |
|
86
|
|
|
{ |
|
87
|
|
|
parent::__construct(self::REG); |
|
88
|
|
|
$this->std = $this->standarize($std); |
|
89
|
|
|
$this->postValidation(); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function postValidation() |
|
93
|
|
|
{ |
|
94
|
|
|
/* |
|
95
|
|
|
* Campo 05 (VOL_DISP) Preenchimento: informar o volume disponível, que corresponde |
|
96
|
|
|
* à soma dos campos ESTQ_ABERT e VOL_ENTR, para o tanque especificado no campo NUM_TANQUE. |
|
97
|
|
|
*/ |
|
98
|
|
|
$somatorio = $this->values->estq_abert + $this->values->vol_entr; |
|
99
|
|
|
if ($this->values->vol_disp != $somatorio) { |
|
100
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] Informar o volume disponível, " |
|
101
|
|
|
."que corresponde à soma dos campos ESTQ_ABERT e VOL_ENTR, para o tanque especificado " |
|
102
|
|
|
."no campo NUM_TANQUE"); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/* |
|
106
|
|
|
* Campo 07 (ESTQ_ESCR) Preenchimento: informar o estoque escritural, que corresponde ao valor |
|
107
|
|
|
* constante no campo VOL_DISP menos o valor constante no campo VOL_SAIDAS, para o tanque |
|
108
|
|
|
* especificado no campo NUM_TANQUE. |
|
109
|
|
|
*/ |
|
110
|
|
|
$diferenca = $this->values->vol_disp - $this->values->vol_saidas; |
|
111
|
|
|
if ($this->values->estq_escr != $diferenca) { |
|
112
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] Informar o estoque escritural, " |
|
113
|
|
|
."que corresponde ao valor constante no campo VOL_DISP menos o valor constante no campo " |
|
114
|
|
|
."VOL_SAIDAS, para o tanque especificado no campo NUM_TANQUE."); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|