D600::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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 D600 extends Element implements ElementInterface
9
{
10
    const REG = 'D600';
11
    const LEVEL = 3;
12
    const PARENT = 'D001';
13
14
    protected $parameters = [
15
        'COD_MOD' => [
16
            'type' => 'string',
17
            'regex' => '^(21|22)$',
18
            'required' => false,
19
            'info' => 'Código do modelo do documento fiscal, conforme a Tabela 4.1.1. ',
20
            'format' => ''
21
        ],
22
        'COD_MUN' => [
23
            'type' => 'numeric',
24
            'regex' => '^(\d{7})$',
25
            'required' => false,
26
            'info' => 'Código do município dos terminais faturados, conforme a tabela IBGE ',
27
            'format' => ''
28
        ],
29
        'SER' => [
30
            'type' => 'string',
31
            'regex' => '^.{0,4}$',
32
            'required' => false,
33
            'info' => 'Série do documento fiscal ',
34
            'format' => ''
35
        ],
36
        'SUB' => [
37
            'type' => 'numeric',
38
            'regex' => '^(\d{0,3})$',
39
            'required' => false,
40
            'info' => 'Subsérie do documento fiscal ',
41
            'format' => ''
42
        ],
43
        'IND_REC' => [
44
            'type' => 'numeric',
45
            'regex' => '^\d$',
46
            'required' => false,
47
            'info' => 'Indicador do tipo de receita ' .
48
                ' 0- Receita própria - serviços prestados ' .
49
                ' 1- Receita própria - cobrança de débitos ' .
50
                ' 2- Receita própria - venda de serviço pré-pago – faturamento de períodos anteriores ' .
51
                ' 3- Receita própria - venda de serviço pré-pago – ',
52
            'format' => ''
53
        ],
54
        'QTD_CONS' => [
55
            'type' => 'numeric',
56
            'regex' => '^([0-9]+)$',
57
            'required' => false,
58
            'info' => 'Quantidade de documentos consolidados neste registro ',
59
            'format' => ''
60
        ],
61
        'DT_DOC_INI' => [
62
            'type' => 'string',
63
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
64
            'required' => false,
65
            'info' => 'Data Inicial dos documentos consolidados no período ',
66
            'format' => ''
67
        ],
68
        'DT_DOC_FIN' => [
69
            'type' => 'string',
70
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
71
            'required' => false,
72
            'info' => 'Data Final dos documentos consolidados no período ',
73
            'format' => ''
74
        ],
75
        'VL_DOC' => [
76
            'type' => 'numeric',
77
            'regex' => '^\d+(\.\d*)?|\.\d+$',
78
            'required' => false,
79
            'info' => 'Valor total acumulado dos documentos fiscais ',
80
            'format' => '15v2'
81
        ],
82
        'VL_DESC' => [
83
            'type' => 'numeric',
84
            'regex' => '^\d+(\.\d*)?|\.\d+$',
85
            'required' => false,
86
            'info' => 'Valor acumulado dos descontos ',
87
            'format' => '15v2'
88
        ],
89
        'VL_SERV' => [
90
            'type' => 'numeric',
91
            'regex' => '^\d+(\.\d*)?|\.\d+$',
92
            'required' => false,
93
            'info' => 'Valor acumulado das prestações de serviços tributados pelo ICMS ',
94
            'format' => '15v2'
95
        ],
96
        'VL_SERV_NT' => [
97
            'type' => 'numeric',
98
            'regex' => '^\d+(\.\d*)?|\.\d+$',
99
            'required' => false,
100
            'info' => 'Valor acumulado dos serviços não-tributados pelo ICMS ',
101
            'format' => '15v2'
102
        ],
103
        'VL_TERC' => [
104
            'type' => 'numeric',
105
            'regex' => '^\d+(\.\d*)?|\.\d+$',
106
            'required' => false,
107
            'info' => 'Valores cobrados em nome de terceiros ',
108
            'format' => '15v2'
109
        ],
110
        'VL_DA' => [
111
            'type' => 'numeric',
112
            'regex' => '^\d+(\.\d*)?|\.\d+$',
113
            'required' => false,
114
            'info' => 'Valor acumulado das despesas acessórias ',
115
            'format' => '15v2'
116
        ],
117
        'VL_BC_ICMS' => [
118
            'type' => 'numeric',
119
            'regex' => '^\d+(\.\d*)?|\.\d+$',
120
            'required' => false,
121
            'info' => 'Valor acumulado da base de cálculo do ICMS ',
122
            'format' => '15v2'
123
        ],
124
        'VL_ICMS' => [
125
            'type' => 'numeric',
126
            'regex' => '^\d+(\.\d*)?|\.\d+$',
127
            'required' => false,
128
            'info' => 'Valor acumulado do ICMS ',
129
            'format' => '15v2'
130
        ],
131
        'VL_PIS' => [
132
            'type' => 'numeric',
133
            'regex' => '^\d+(\.\d*)?|\.\d+$',
134
            'required' => false,
135
            'info' => 'Valor do PIS/PASEP ',
136
            'format' => '15v2'
137
        ],
138
        'VL_COFINS' => [
139
            'type' => 'numeric',
140
            'regex' => '^\d+(\.\d*)?|\.\d+$',
141
            'required' => false,
142
            'info' => 'Valor da COFINS ',
143
            'format' => '15v2'
144
        ],
145
146
    ];
147
148
    /**
149
     * Constructor
150
     * @param \stdClass $std
151
     */
152
    public function __construct(\stdClass $std)
153
    {
154
        parent::__construct(self::REG);
155
        $this->std = $this->standarize($std);
156
        $this->postValidation();
157
    }
158
159
    public function postValidation()
160
    {
161
        if ($this->values->vl_doc <= 0) {
162
            throw new \InvalidArgumentException("[" . self::REG . "] " .
163
                "O campo VL_DOC deve ser maior do que 0");
164
        }
165
    }
166
}
167