D500   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 179
ccs 0
cts 13
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 7 2
1
<?php
2
3
namespace NFePHP\EFD\Elements\Contribuicoes;
4
5
use NFePHP\EFD\Common\Element;
6
use NFePHP\EFD\Common\ElementInterface;
7
8
class D500 extends Element implements ElementInterface
9
{
10
    const REG = 'D500';
11
    const LEVEL = 3;
12
    const PARENT = 'D001';
13
14
    protected $parameters = [
15
        'IND_OPER' => [
16
            'type' => 'string',
17
            'regex' => '^(0)$',
18
            'required' => false,
19
            'info' => 'Indicador do tipo de operação ' .
20
                ' 0- Aquisição ',
21
            'format' => ''
22
        ],
23
        'IND_EMIT' => [
24
            'type' => 'string',
25
            'regex' => '^(0|1)$',
26
            'required' => false,
27
            'info' => 'Indicador do emitente do documento fiscal ' .
28
                ' 0- Emissão própria ' .
29
                ' 1- Terceiros ',
30
            'format' => ''
31
        ],
32
        'COD_PART' => [
33
            'type' => 'string',
34
            'regex' => '^.{0,60}$',
35
            'required' => false,
36
            'info' => 'Código do participante prestador do serviço (campo 02 do Registro 0150). ',
37
            'format' => ''
38
        ],
39
        'COD_MOD' => [
40
            'type' => 'string',
41
            'regex' => '^(21|22)$',
42
            'required' => false,
43
            'info' => 'Código do modelo do documento fiscal, conforme a Tabela 4.1.1. ',
44
            'format' => ''
45
        ],
46
        'COD_SIT' => [
47
            'type' => 'numeric',
48
            'regex' => '^(0)([0-8]{1})$',
49
            'required' => false,
50
            'info' => 'Çódigo da situação do documento fiscal, conforme a Tabela 4.1.2. ',
51
            'format' => ''
52
        ],
53
        'SER' => [
54
            'type' => 'string',
55
            'regex' => '^.{0,4}$',
56
            'required' => false,
57
            'info' => 'Série do documento fiscal ',
58
            'format' => ''
59
        ],
60
        'SUB' => [
61
            'type' => 'numeric',
62
            'regex' => '^(\d{0,3})$',
63
            'required' => false,
64
            'info' => 'Subsérie do documento fiscal ',
65
            'format' => ''
66
        ],
67
        'NUM_DOC' => [
68
            'type' => 'numeric',
69
            'regex' => '^(\d{0,9})$',
70
            'required' => false,
71
            'info' => 'Número do documento fiscal ',
72
            'format' => ''
73
        ],
74
        'DT_DOC' => [
75
            'type' => 'string',
76
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
77
            'required' => false,
78
            'info' => 'Data da emissão do documento fiscal ',
79
            'format' => ''
80
        ],
81
        'DT_A_P' => [
82
            'type' => 'string',
83
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
84
            'required' => false,
85
            'info' => 'Data da entrada (aquisição) ',
86
            'format' => ''
87
        ],
88
        'VL_DOC' => [
89
            'type' => 'numeric',
90
            'regex' => '^\d+(\.\d*)?|\.\d+$',
91
            'required' => false,
92
            'info' => 'Valor total do documento fiscal ',
93
            'format' => '15v2'
94
        ],
95
        'VL_DESC' => [
96
            'type' => 'numeric',
97
            'regex' => '^\d+(\.\d*)?|\.\d+$',
98
            'required' => false,
99
            'info' => 'Valor total do desconto ',
100
            'format' => '15v2'
101
        ],
102
        'VL_SERV' => [
103
            'type' => 'numeric',
104
            'regex' => '^\d+(\.\d*)?|\.\d+$',
105
            'required' => false,
106
            'info' => 'Valor da prestação de serviços ',
107
            'format' => '15v2'
108
        ],
109
        'VL_SERV_NT' => [
110
            'type' => 'numeric',
111
            'regex' => '^\d+(\.\d*)?|\.\d+$',
112
            'required' => false,
113
            'info' => 'Valor total dos serviços não-tributados pelo ICMS ',
114
            'format' => '15v2'
115
        ],
116
        'VL_TERC' => [
117
            'type' => 'numeric',
118
            'regex' => '^\d+(\.\d*)?|\.\d+$',
119
            'required' => false,
120
            'info' => 'Valores cobrados em nome de terceiros ',
121
            'format' => '15v2'
122
        ],
123
        'VL_DA' => [
124
            'type' => 'numeric',
125
            'regex' => '^\d+(\.\d*)?|\.\d+$',
126
            'required' => false,
127
            'info' => 'Valor de outras despesas indicadas no documento fiscal ',
128
            'format' => '15v2'
129
        ],
130
        'VL_BC_ICMS' => [
131
            'type' => 'numeric',
132
            'regex' => '^\d+(\.\d*)?|\.\d+$',
133
            'required' => false,
134
            'info' => 'Valor da base de cálculo do ICMS ',
135
            'format' => '15v2'
136
        ],
137
        'VL_ICMS' => [
138
            'type' => 'numeric',
139
            'regex' => '^\d+(\.\d*)?|\.\d+$',
140
            'required' => false,
141
            'info' => 'Valor do ICMS ',
142
            'format' => '15v2'
143
        ],
144
        'COD_INF' => [
145
            'type' => 'string',
146
            'regex' => '^.{0,6}$',
147
            'required' => false,
148
            'info' => 'Código da informação complementar (campo 02 do Registro 0450) ',
149
            'format' => ''
150
        ],
151
        'VL_PIS' => [
152
            'type' => 'numeric',
153
            'regex' => '^\d+(\.\d*)?|\.\d+$',
154
            'required' => false,
155
            'info' => 'Valor do PIS/PASEP ',
156
            'format' => '15v2'
157
        ],
158
        'VL_COFINS' => [
159
            'type' => 'numeric',
160
            'regex' => '^\d+(\.\d*)?|\.\d+$',
161
            'required' => false,
162
            'info' => 'Valor da COFINS ',
163
            'format' => '15v2'
164
        ],
165
166
    ];
167
168
    /**
169
     * Constructor
170
     * @param \stdClass $std
171
     */
172
    public function __construct(\stdClass $std)
173
    {
174
        parent::__construct(self::REG);
175
        $this->std = $this->standarize($std);
176
        $this->postValidation();
177
    }
178
179
    public function postValidation()
180
    {
181
        if ($this->values->vl_doc <= 0) {
182
            throw new \InvalidArgumentException("[" . self::REG . "] " .
183
                "O campo VL_DOC deve ser maior do que 0");
184
        }
185
    }
186
}
187