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 Z1300 extends Element implements ElementInterface |
10
|
|
|
{ |
11
|
|
|
const REG = '1300'; |
12
|
|
|
const LEVEL = 2; |
13
|
|
|
const PARENT = '1001'; |
14
|
|
|
|
15
|
|
|
protected $parameters = [ |
16
|
|
|
'COD_ITEM' => [ |
17
|
|
|
'type' => 'string', |
18
|
|
|
'regex' => '^.{1,60}$', |
19
|
|
|
'required' => true, |
20
|
|
|
'info' => 'Código do Produto, constante do registro 0200', |
21
|
|
|
'format' => '' |
22
|
|
|
], |
23
|
|
|
'DT_FECH' => [ |
24
|
|
|
'type' => 'integer', |
25
|
|
|
'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$', |
26
|
|
|
'required' => true, |
27
|
|
|
'info' => 'Data do fechamento da movimentação', |
28
|
|
|
'format' => '' |
29
|
|
|
], |
30
|
|
|
'ESTQ_ABERT' => [ |
31
|
|
|
'type' => 'numeric', |
32
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
33
|
|
|
'required' => true, |
34
|
|
|
'info' => 'Estoque no início do dia, em litros', |
35
|
|
|
'format' => '15v3' |
36
|
|
|
], |
37
|
|
|
'VOL_ENTR' => [ |
38
|
|
|
'type' => 'numeric', |
39
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
40
|
|
|
'required' => true, |
41
|
|
|
'info' => 'Volume Recebido no dia (em litros)', |
42
|
|
|
'format' => '15v3' |
43
|
|
|
], |
44
|
|
|
'VOL_DISP' => [ |
45
|
|
|
'type' => 'numeric', |
46
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
47
|
|
|
'required' => true, |
48
|
|
|
'info' => 'Volume Disponível (04 + 05), em litros', |
49
|
|
|
'format' => '15v3' |
50
|
|
|
], |
51
|
|
|
'VOL_SAIDAS' => [ |
52
|
|
|
'type' => 'numeric', |
53
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
54
|
|
|
'required' => true, |
55
|
|
|
'info' => 'Volume Total das Saídas, em litros', |
56
|
|
|
'format' => '15v3' |
57
|
|
|
], |
58
|
|
|
'ESTQ_ESCR' => [ |
59
|
|
|
'type' => 'numeric', |
60
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
61
|
|
|
'required' => true, |
62
|
|
|
'info' => 'Estoque Escritural (06 – 07), litros', |
63
|
|
|
'format' => '15v3' |
64
|
|
|
], |
65
|
|
|
'VAL_AJ_PERDA' => [ |
66
|
|
|
'type' => 'numeric', |
67
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
68
|
|
|
'required' => true, |
69
|
|
|
'info' => 'Valor da Perda, em litros', |
70
|
|
|
'format' => '15v3' |
71
|
|
|
], |
72
|
|
|
'VAL_AJ_GANHO' => [ |
73
|
|
|
'type' => 'numeric', |
74
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
75
|
|
|
'required' => true, |
76
|
|
|
'info' => 'Valor do ganho, em litros', |
77
|
|
|
'format' => '15v3' |
78
|
|
|
], |
79
|
|
|
'FECH_FISICO' => [ |
80
|
|
|
'type' => 'numeric', |
81
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
82
|
|
|
'required' => true, |
83
|
|
|
'info' => 'Estoque de Fechamento, 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
|
|
|
public function postValidation() |
100
|
|
|
{ |
101
|
|
|
/* |
102
|
|
|
* Campo 06 (VOL_DISP) Preenchimento: informar o volume disponível, que corresponde |
103
|
|
|
* à soma dos campos ESTQ_ABERT e VOL_ENTR. |
104
|
|
|
*/ |
105
|
|
|
$somatorio = $this->values->estq_abert + $this->values->vol_entr; |
106
|
|
|
if ($this->std->vol_disp != number_format($somatorio, 3, ',', '')) { |
107
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] Informar o volume " |
108
|
|
|
."disponível, que corresponde à soma dos campos ESTQ_ABERT e VOL_ENTR."); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/* |
112
|
|
|
* Campo 08 (ESTQ_ESCR) Preenchimento: informar o estoque escritural, que corresponde |
113
|
|
|
* ao valor constante no campo VOL_DISP |
114
|
|
|
* menos o valor constante no campo VOL_SAIDAS. |
115
|
|
|
*/ |
116
|
|
|
$diferenca = $this->values->vol_disp - $this->values->vol_saidas; |
117
|
|
|
if ($this->std->estq_escr != number_format($diferenca, 3, ',', '')) { |
118
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] Informar o estoque " |
119
|
|
|
."escritural, que corresponde ao valor constante no campo VOL_DISP menos o " |
120
|
|
|
."valor constante no campo VOL_SAIDAS."); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|