Z1500   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 157
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 157
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A postValidation() 0 9 3
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 Z1500 extends Element implements ElementInterface
10
{
11
    const REG = '1500';
12
    const LEVEL = 2;
13
    const PARENT = '1001';
14
15
    protected $parameters = [
16
        'PER_APU_CRED' => [
17
            'type' => 'numeric',
18
            'regex' => '^(\d{0,6})$',
19
            'required' => false,
20
            'info' => 'Período de Apuração do Crédito (MM/AAAA) ',
21
            'format' => ''
22
        ],
23
        'ORIG_CRED' => [
24
            'type' => 'numeric',
25
            'regex' => '^(01|02)$',
26
            'required' => false,
27
            'info' => 'Indicador da origem do crédito ' .
28
                ' 01 – Crédito decorrente de operações próprias ' .
29
                ' 02 – Crédito transferido por pessoa jurídica sucedida. ',
30
            'format' => ''
31
        ],
32
        'CNPJ_SUC' => [
33
            'type' => 'string',
34
            'regex' => '^[0-9]{14}$',
35
            'required' => false,
36
            'info' => 'CNPJ da pessoa jurídica cedente do crédito (se ORIG_CRED = 02). ',
37
            'format' => ''
38
        ],
39
        'COD_CRED' => [
40
            'type' => 'numeric',
41
            'regex' => '^(\d{3})$',
42
            'required' => false,
43
            'info' => 'Código do Tipo do Crédito, conforme Tabela 4.3.6. ',
44
            'format' => ''
45
        ],
46
        'VL_CRED_APU' => [
47
            'type' => 'numeric',
48
            'regex' => '^\d+(\.\d*)?|\.\d+$',
49
            'required' => false,
50
            'info' => 'Valor Total do crédito apurado na Escrituração Fiscal Digital (Registro M500) ou em ' .
51
                'demonstrativo DACON (Fichas 16A e 16B) de período anterior. ',
52
            'format' => '15v2'
53
        ],
54
        'VL_CRED_EXT_APU' => [
55
            'type' => 'numeric',
56
            'regex' => '^\d+(\.\d*)?|\.\d+$',
57
            'required' => false,
58
            'info' => 'Valor de Crédito Extemporâneo Apurado (Registro 1501), referente a Período Anterior, ' .
59
                'Informado no Campo 02 – PER_APU_CRED ',
60
            'format' => '15v2'
61
        ],
62
        'VL_TOT_CRED_APU' => [
63
            'type' => 'numeric',
64
            'regex' => '^\d+(\.\d*)?|\.\d+$',
65
            'required' => false,
66
            'info' => 'Valor Total do Crédito Apurado (06 + 07) ',
67
            'format' => '15v2'
68
        ],
69
        'VL_CRED_DESC_PA_ANT' => [
70
            'type' => 'numeric',
71
            'regex' => '^\d+(\.\d*)?|\.\d+$',
72
            'required' => false,
73
            'info' => 'Valor do Crédito utilizado mediante Desconto, em Período(s) Anterior(es) ',
74
            'format' => '15v2'
75
        ],
76
        'VL_CRED_PER_PA_ANT' => [
77
            'type' => 'numeric',
78
            'regex' => '^\d+(\.\d*)?|\.\d+$',
79
            'required' => false,
80
            'info' => 'Valor do Crédito utilizado mediante Pedido de Ressarcimento, em Período(s) Anterior(es). ',
81
            'format' => '15v2'
82
        ],
83
        'VL_CRED_DCOMP_PA_ANT' => [
84
            'type' => 'numeric',
85
            'regex' => '^\d+(\.\d*)?|\.\d+$',
86
            'required' => false,
87
            'info' => 'Valor do Crédito utilizado mediante Declaração de Compensação Intermediária ' .
88
                '(Crédito de Exportação), em Período(s) Anterior(es) ',
89
            'format' => '15v2'
90
        ],
91
        'SD_CRED_DISP_EFD' => [
92
            'type' => 'numeric',
93
            'regex' => '^\d+(\.\d*)?|\.\d+$',
94
            'required' => false,
95
            'info' => 'Saldo do Crédito Disponível para Utilização neste Período de Escrituração ' .
96
                '(08-09-10-11) ',
97
            'format' => '15v2'
98
        ],
99
        'VL_CRED_DESC_EFD' => [
100
            'type' => 'numeric',
101
            'regex' => '^\d+(\.\d*)?|\.\d+$',
102
            'required' => false,
103
            'info' => 'Valor do Crédito descontado neste período de escrituração ',
104
            'format' => '15v2'
105
        ],
106
        'VL_CRED_PER_EFD' => [
107
            'type' => 'numeric',
108
            'regex' => '^\d+(\.\d*)?|\.\d+$',
109
            'required' => false,
110
            'info' => 'Valor do Crédito objeto de Pedido de Ressarcimento (PER) neste período de escrituração ',
111
            'format' => '15v2'
112
        ],
113
        'VL_CRED_DCOMP_EFD' => [
114
            'type' => 'numeric',
115
            'regex' => '^\d+(\.\d*)?|\.\d+$',
116
            'required' => false,
117
            'info' => 'Valor do Crédito utilizado mediante Declaração de Compensação Intermediária neste ' .
118
                'período de escrituração ',
119
            'format' => '15v2'
120
        ],
121
        'VL_CRED_TRANS' => [
122
            'type' => 'numeric',
123
            'regex' => '^\d+(\.\d*)?|\.\d+$',
124
            'required' => false,
125
            'info' => 'Valor do crédito transferido em evento de cisão, fusão ou incorporação ',
126
            'format' => '15v2'
127
        ],
128
        'VL_CRED_OUT' => [
129
            'type' => 'numeric',
130
            'regex' => '^\d+(\.\d*)?|\.\d+$',
131
            'required' => false,
132
            'info' => 'Valor do crédito utilizado por outras formas ',
133
            'format' => '15v2'
134
        ],
135
        'SLD_CRED_FIM' => [
136
            'type' => 'numeric',
137
            'regex' => '^\d+(\.\d*)?|\.\d+$',
138
            'required' => false,
139
            'info' => 'Saldo de créditos a utilizar em período de apuração futuro (12-13-14-15-16-17). ',
140
            'format' => '15v2'
141
        ],
142
143
    ];
144
145
    /**
146
     * Constructor
147
     * @param \stdClass $std
148
     */
149
    public function __construct(\stdClass $std)
150
    {
151
        parent::__construct(self::REG);
152
        $this->std = $this->standarize($std);
153
        $this->postValidation();
154
    }
155
156
    public function postValidation()
157
    {
158
        if ($this->std->vl_cred_per_efd and
159
            !in_array($this->std->cod_cred, [201, 202, 203, 204, 208, 301, 302, 303, 304, 307,308])) {
160
            throw new \InvalidArgumentException("[" . self::REG . "] " .
161
                "O valor do campo VL_CRED_PER_EFD deverá ser informado apenas se o campo 
162
                COD_CRED for igual a 201, 202, 203, 204, 208, 301, 302, 303, 304, 307 ou 308");
163
        }
164
    }
165
}
166