B470   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 135
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 135
ccs 0
cts 17
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 15 2
1
<?php
2
3
namespace NFePHP\EFD\Elements\ICMSIPI;
4
5
use NFePHP\EFD\Common\Element;
6
use NFePHP\EFD\Common\ElementInterface;
7
use \stdClass;
8
9
class B470 extends Element implements ElementInterface
10
{
11
    const REG = 'B470';
12
    const LEVEL = 2;
13
    const PARENT = 'B001';
14
15
    protected $parameters = [
16
        'VL_CONT' => [
17
            'type'     => 'numeric',
18
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
19
            'required' => true,
20
            'info'     => 'A- Valor total referente às prestações de serviço do período',
21
            'format'   => '15v2'
22
        ],
23
        'VL_MAT_TERC' => [
24
            'type'     => 'numeric',
25
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
26
            'required' => true,
27
            'info'     => 'B- Valor total do material fornecido por terceiros na prestação do serviço',
28
            'format'   => '15v2'
29
        ],
30
        'VL_MAT_PROP' => [
31
            'type'     => 'numeric',
32
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
33
            'required' => true,
34
            'info'     => 'C- Valor do material próprio utilizado na prestação do serviço',
35
            'format'   => '15v2'
36
        ],
37
        'VL_SUB' => [
38
            'type'     => 'numeric',
39
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
40
            'required' => true,
41
            'info'     => 'D- Valor total das subempreitadas',
42
            'format'   => '15v2'
43
        ],
44
        'VL_ISNT' => [
45
            'type'     => 'numeric',
46
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
47
            'required' => true,
48
            'info'     => 'E- Valor total das operações isentas ou não-tributadas pelo ISS',
49
            'format'   => '15v2'
50
        ],
51
        'VL_DED_BC' => [
52
            'type'     => 'numeric',
53
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
54
            'required' => true,
55
            'info'     => 'F- Valor total das deduções da base de cálculo (B + C + D + E)',
56
            'format'   => '15v2'
57
        ],
58
        'VL_BC_ISS' => [
59
            'type'     => 'numeric',
60
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
61
            'required' => true,
62
            'info'     => 'G- Valor total da base de cálculo do ISS',
63
            'format'   => '15v2'
64
        ],
65
        'VL_BC_ISS_RT' => [
66
            'type'     => 'numeric',
67
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
68
            'required' => true,
69
            'info'     => 'H- Valor total da base de cálculo de retenção do ISS referente'
70
            .'às prestações do declarante.',
71
            'format'   => '15v2'
72
        ],
73
        'VL_ISS' => [
74
            'type'     => 'numeric',
75
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
76
            'required' => true,
77
            'info'     => 'I- Valor total do ISS destacado',
78
            'format'   => '15v2'
79
        ],
80
        'VL_ISS_RT' => [
81
            'type'     => 'numeric',
82
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
83
            'required' => true,
84
            'info'     => 'J- Valor total do ISS retido pelo tomador nas prestações do declarante',
85
            'format'   => '15v2'
86
        ],
87
        'VL_DED' => [
88
            'type'     => 'numeric',
89
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
90
            'required' => true,
91
            'info'     => 'K- Valor total das deduções do ISS próprio',
92
            'format'   => '15v2'
93
        ],
94
        'VL_ISS_REC' => [
95
            'type'     => 'numeric',
96
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
97
            'required' => true,
98
            'info'     => 'L- Valor total apurado do ISS próprio a recolher (I - J - K)',
99
            'format'   => '15v2'
100
        ],
101
        'VL_ISS_ST' => [
102
            'type'     => 'numeric',
103
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
104
            'required' => true,
105
            'info'     => 'M- Valor total do ISS substituto a recolher pelas aquisições do declarante (tomador)',
106
            'format'   => '15v2'
107
        ],
108
        'VL_ISS_REC_UNI' => [
109
            'type'     => 'numeric',
110
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
111
            'required' => true,
112
            'info'     => 'N- Valor do ISS próprio a recolher pela Sociedade Uniprofissional',
113
            'format'   => '15v2'
114
        ]
115
    ];
116
117
    /**
118
     * Constructor
119
     * @param \stdClass $std
120
     */
121
    public function __construct(\stdClass $std)
122
    {
123
        parent::__construct(self::REG);
124
        $this->std = $this->standarize($std);
125
        $this->postValidation();
126
    }
127
128
    public function postValidation()
129
    {
130
        /*
131
         * Campo 07 (VL_DED_BC) Validação: o valor informado deve ser igual ao somatório dos valores
132
         * dos campos VL_MAT_TERC, VL_MAT_PROP, VL_SUB e VL_ISNT.
133
         */
134
        $somatorio = $this->values->vl_mat_terc
135
                    + $this->values->vl_mat_prop
136
                    + $this->values->vl_sub
137
                    + $this->values->vl_isnt;
138
        if ($this->values->vl_ded_bc != $somatorio) {
139
            throw new \InvalidArgumentException("[" . self::REG . "] O valor informado deve ser igual "
140
            ."ao somatório dos valores dos campos VL_MAT_TERC, VL_MAT_PROP, VL_SUB e VL_ISNT.");
141
        }
142
    }
143
}
144