A100   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 172
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 172
ccs 0
cts 14
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 8 3
1
<?php
2
3
namespace NFePHP\EFD\Elements\Contribuicoes;
4
5
use NFePHP\Common\Keys;
6
use NFePHP\EFD\Common\Element;
7
use NFePHP\EFD\Common\ElementInterface;
8
use \stdClass;
9
10
class A100 extends Element implements ElementInterface
11
{
12
    const REG = 'A100';
13
    const LEVEL = 2;
14
    const PARENT = 'A000';
15
16
    protected $parameters = [
17
        'IND_OPER' => [
18
            'type' => 'string',
19
            'regex' => '^(0|1)$',
20
            'required' => false,
21
            'info' => 'Indicador do tipo de operação:',
22
            'format' => ''
23
        ],
24
        'IND_EMIT' => [
25
            'type' => 'string',
26
            'regex' => '^.{1}$',
27
            'required' => false,
28
            'info' => 'Indicador do emitente do documento fiscal: 0 - Emissão Própria; 1 - Emissão de Terceiros',
29
            'format' => ''
30
        ],
31
        'COD_PART' => [
32
            'type' => 'string',
33
            'regex' => '^.{0,60}$',
34
            'required' => false,
35
            'info' => 'Código do participante (campo 02 do Registro 0150):
36
             - do emitente do documento, no caso de emissão de terceiros; 
37
             - do adquirente, no caso de serviços prestados.',
38
            'format' => ''
39
        ],
40
        'COD_SIT' => [
41
            'type' => 'numeric',
42
            'regex' => '^(00|02)$',
43
            'required' => false,
44
            'info' => 'Código da situação do documento fiscal: 00 – Documento regular 02 – Documento cancelado',
45
            'format' => ''
46
        ],
47
        'SER' => [
48
            'type' => 'string',
49
            'regex' => '^.{0,20}$',
50
            'required' => false,
51
            'info' => 'Série do documento fiscal',
52
            'format' => ''
53
        ],
54
        'SUB' => [
55
            'type' => 'string',
56
            'regex' => '^.{0,20}$',
57
            'required' => false,
58
            'info' => 'Subsérie do documento fiscal',
59
            'format' => ''
60
        ],
61
        'NUM_DOC' => [
62
            'type' => 'string',
63
            'regex' => '^.{0,60}$',
64
            'required' => false,
65
            'info' => 'Número do documento fiscal ou documento internacional equivalente',
66
            'format' => ''
67
        ],
68
        'CHV_NFSE' => [
69
            'type' => 'numeric',
70
            'regex' => '^([0-9]{44})?$',
71
            'required' => false,
72
            'info' => 'Chave/Código de Verificação da nota fiscal de serviço eletrônica',
73
            'format' => ''
74
        ],
75
        'DT_DOC' => [
76
            'type' => 'string',
77
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
78
            'required' => false,
79
            'info' => 'Data da emissão do documento fiscal',
80
            'format' => ''
81
        ],
82
        'DT_EXE_SERV' => [
83
            'type' => 'string',
84
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
85
            'required' => false,
86
            'info' => 'Data de Execução / Conclusão do Serviço',
87
            'format' => ''
88
        ],
89
        'VL_DOC' => [
90
            'type' => 'numeric',
91
            'regex' => '^\d+(\.\d*)?|\.\d+$',
92
            'required' => false,
93
            'info' => 'Valor total do documento',
94
            'format' => '15v2'
95
        ],
96
        'IND_PGTO' => [
97
            'type' => 'string',
98
            'regex' => '^(0|1|9)$',
99
            'required' => false,
100
            'info' => 'Indicador do tipo de pagamento: 0- À vista; 1- A prazo; 9- Sem pagamento.',
101
            'format' => ''
102
        ],
103
        'VL_DESC' => [
104
            'type' => 'numeric',
105
            'regex' => '^\d+(\.\d*)?|\.\d+$',
106
            'required' => false,
107
            'info' => 'Valor total do desconto',
108
            'format' => '15v2'
109
        ],
110
        'VL_BC_PIS' => [
111
            'type' => 'numeric',
112
            'regex' => '^\d+(\.\d*)?|\.\d+$',
113
            'required' => false,
114
            'info' => 'Valor da base de cálculo do PIS/PASEP',
115
            'format' => '15v2'
116
        ],
117
        'VL_PIS' => [
118
            'type' => 'numeric',
119
            'regex' => '^\d+(\.\d*)?|\.\d+$',
120
            'required' => false,
121
            'info' => 'Valor total do PIS',
122
            'format' => '15v2'
123
        ],
124
        'VL_BC_COFINS' => [
125
            'type' => 'numeric',
126
            'regex' => '^\d+(\.\d*)?|\.\d+$',
127
            'required' => false,
128
            'info' => 'Valor da base de cálculo da COFINS',
129
            'format' => '15v2'
130
        ],
131
        'VL_COFINS' => [
132
            'type' => 'numeric',
133
            'regex' => '^\d+(\.\d*)?|\.\d+$',
134
            'required' => false,
135
            'info' => 'Valor total da COFINS',
136
            'format' => '15v2'
137
        ],
138
        'VL_PIS_RET' => [
139
            'type' => 'numeric',
140
            'regex' => '^\d+(\.\d*)?|\.\d+$',
141
            'required' => false,
142
            'info' => 'Valor total do PIS retido na fonte',
143
            'format' => '15v2'
144
        ],
145
        'VL_COFINS_RET' => [
146
            'type' => 'numeric',
147
            'regex' => '^\d+(\.\d*)?|\.\d+$',
148
            'required' => false,
149
            'info' => 'Valor total da COFINS retido na fonte.',
150
            'format' => '15v2'
151
        ],
152
        'VL_ISS' => [
153
            'type' => 'numeric',
154
            'regex' => '^\d+(\.\d*)?|\.\d+$',
155
            'required' => false,
156
            'info' => 'Valor do ISS',
157
            'format' => '15v2'
158
        ],
159
160
    ];
161
162
    /**
163
     * Constructor
164
     * @param \stdClass $std
165
     */
166
    public function __construct(\stdClass $std)
167
    {
168
        parent::__construct(self::REG);
169
        $this->std = $this->standarize($std);
170
        $this->postValidation();
171
    }
172
173
    public function postValidation()
174
    {
175
        if ($this->std->chv_nfse and !Keys::isValid($this->std->chv_nfse)) {
176
            throw new \InvalidArgumentException("[" . self::REG . "] " .
177
                " Dígito verificador incorreto no campo campo chave da " .
178
                "nota fiscal de serviço eletronica (CHAVE_NFSE)");
179
        }
180
    }
181
}
182