|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\EFD\Elements\Contribuicoes; |
|
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
|
|
|
'IND_NAT_RET' => [ |
|
17
|
|
|
'type' => 'numeric', |
|
18
|
|
|
'regex' => '^(1|2|3|4|5|9|1|2|3|4|5|9|1|2|3|4|5|9)$', |
|
19
|
|
|
'required' => false, |
|
20
|
|
|
'info' => 'Indicador de Natureza da Retenção na Fonte', |
|
21
|
|
|
'format' => '' |
|
22
|
|
|
], |
|
23
|
|
|
'PR_REC_RET' => [ |
|
24
|
|
|
'type' => 'numeric', |
|
25
|
|
|
'regex' => '^(\d{0,6})$', |
|
26
|
|
|
'required' => false, |
|
27
|
|
|
'info' => 'Período do Recebimento e da Retenção (MM/AAAA) ', |
|
28
|
|
|
'format' => '' |
|
29
|
|
|
], |
|
30
|
|
|
'VL_RET_APU' => [ |
|
31
|
|
|
'type' => 'numeric', |
|
32
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
33
|
|
|
'required' => false, |
|
34
|
|
|
'info' => 'Valor Total da Retenção ', |
|
35
|
|
|
'format' => '15v2' |
|
36
|
|
|
], |
|
37
|
|
|
'VL_RET_DED' => [ |
|
38
|
|
|
'type' => 'numeric', |
|
39
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
40
|
|
|
'required' => false, |
|
41
|
|
|
'info' => 'Valor da Retenção deduzida da Contribuição devida no período da escrituração e em ' . |
|
42
|
|
|
'períodos anteriores. ', |
|
43
|
|
|
'format' => '15v2' |
|
44
|
|
|
], |
|
45
|
|
|
'VL_RET_PER' => [ |
|
46
|
|
|
'type' => 'numeric', |
|
47
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
48
|
|
|
'required' => false, |
|
49
|
|
|
'info' => 'Valor da Retenção utilizada mediante Pedido de Restituição. ', |
|
50
|
|
|
'format' => '15v2' |
|
51
|
|
|
], |
|
52
|
|
|
'VL_RET_DCOMP' => [ |
|
53
|
|
|
'type' => 'numeric', |
|
54
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
55
|
|
|
'required' => false, |
|
56
|
|
|
'info' => 'Valor da Retenção utilizada mediante Declaração de Compensação. ', |
|
57
|
|
|
'format' => '15v2' |
|
58
|
|
|
], |
|
59
|
|
|
'SLD_RET' => [ |
|
60
|
|
|
'type' => 'numeric', |
|
61
|
|
|
'regex' => '^\d+(\.\d*)?|\.\d+$', |
|
62
|
|
|
'required' => false, |
|
63
|
|
|
'info' => 'Saldo de Retenção a utilizar em períodos de apuração futuros (04 – 05 - 06 - 07). ', |
|
64
|
|
|
'format' => '15v2' |
|
65
|
|
|
], |
|
66
|
|
|
|
|
67
|
|
|
]; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Constructor |
|
71
|
|
|
* @param \stdClass $std |
|
72
|
|
|
*/ |
|
73
|
|
|
public function __construct(\stdClass $std) |
|
74
|
|
|
{ |
|
75
|
|
|
parent::__construct(self::REG); |
|
76
|
|
|
$this->std = $this->standarize($std); |
|
77
|
|
|
$this->postValidation(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
View Code Duplication |
public function postValidation() |
|
|
|
|
|
|
81
|
|
|
{ |
|
82
|
|
|
$calculo = $this->values->vl_ret_apu- |
|
83
|
|
|
$this->values->vl_ret_ded- |
|
84
|
|
|
$this->values->vl_ret_per- |
|
85
|
|
|
$this->values->vl_ret_dcomp; |
|
86
|
|
|
if (number_format($this->values->sld_ret, 2)!==number_format($calculo, 2)) { |
|
87
|
|
|
throw new \InvalidArgumentException("[" . self::REG . "] " . |
|
88
|
|
|
"O valor do campo SLD_RET deverá ser igual a |
|
89
|
|
|
VL_RET_APU - VL_RET_DED - VL_RET_PER - VL_RET_DCOMP. "); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
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.