B030   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 109
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 109
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 11 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 B030 extends Element implements ElementInterface
10
{
11
    const REG = 'B030';
12
    const LEVEL = 2;
13
    const PARENT = 'B001';
14
15
    protected $parameters = [
16
        'COD_MOD' => [
17
            'type'     => 'string',
18
            'regex'    => '^.{2}$',
19
            'required' => true,
20
            'info'     => 'Código do modelo do documento fiscal, conforme a Tabela 4.1.3',
21
            'format'   => ''
22
        ],
23
        'SER' => [
24
            'type'     => 'string',
25
            'regex'    => '^.{1,3}$',
26
            'required' => false,
27
            'info'     => 'Série do documento fiscal',
28
            'format'   => ''
29
        ],
30
        'NUM_DOC_INI' => [
31
            'type'     => 'integer',
32
            'regex'    => '^([1-9])([0-9]{1,8}|)$',
33
            'required' => true,
34
            'info'     => 'Número do primeiro documento fiscal emitido no dia',
35
            'format'   => ''
36
        ],
37
        'NUM_DOC_FIN' => [
38
            'type'     => 'integer',
39
            'regex'    => '^\d{1,9}$',
40
            'required' => true,
41
            'info'     => 'Número do último documento fiscal emitido no dia',
42
            'format'   => ''
43
        ],
44
        'DT_DOC' => [
45
            'type'     => 'integer',
46
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
47
            'required' => true,
48
            'info'     => 'Data da emissão dos documentos fiscais',
49
            'format'   => ''
50
        ],
51
        'QTD_CANC' => [
52
            'type'     => 'integer',
53
            'regex'    => '^\d+$',
54
            'required' => true,
55
            'info'     => 'Quantidade de documentos cancelados',
56
            'format'   => ''
57
        ],
58
        'VL_CONT' => [
59
            'type'     => 'numeric',
60
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
61
            'required' => true,
62
            'info'     => 'Valor contábil (valor total acumulado dos documentos)',
63
            'format'   => '15v2'
64
        ],
65
        'VL_ISNT_ISS' => [
66
            'type'     => 'numeric',
67
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
68
            'required' => true,
69
            'info'     => 'Valor acumulado das operações isentas ou não-tributadas pelo ISS',
70
            'format'   => '15v2'
71
        ],
72
        'VL_BC_ISS' => [
73
            'type'     => 'numeric',
74
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
75
            'required' => true,
76
            'info'     => 'Valor acumulado da base de cálculo do ISS',
77
            'format'   => '15v2'
78
        ],
79
        'VL_ISS' => [
80
            'type'     => 'numeric',
81
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
82
            'required' => true,
83
            'info'     => 'Valor acumulado do ISS destacado',
84
            'format'   => '15v2'
85
        ],
86
        'COD_INF_OBS' => [
87
            'type'     => 'string',
88
            'regex'    => '^.{1,60}$',
89
            'required' => false,
90
            'info'     => 'Código da observação do lançamento fiscal (campo 02 do Registro 0460)',
91
            'format'   => ''
92
        ]
93
    ];
94
95
    /**
96
     * Constructor
97
     * @param \stdClass $std
98
     */
99
    public function __construct(\stdClass $std)
100
    {
101
        parent::__construct(self::REG);
102
        $this->std = $this->standarize($std);
103
        $this->postValidation();
104
    }
105
106
    public function postValidation()
107
    {
108
        /*
109
         * Campo 05 (NUM_DOC_FIN) Validação: o valor tem de ser maior ou igual ao
110
         * valor informado no campo NUM_DOC_INI.
111
         */
112
        if ($this->std->num_doc_fin < $this->std->num_doc_ini) {
113
            throw new \InvalidArgumentException("[" . self::REG . "] O valor informado no campo NUM_DOC_FIN "
114
            ."tem de ser maior ou igual ao valor informado no campo NUM_DOC_INI.");
115
        }
116
    }
117
}
118