1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MIT License |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2016 MZ Desenvolvimento de Sistemas LTDA |
6
|
|
|
* |
7
|
|
|
* @author Francimar Alves <[email protected]> |
8
|
|
|
* |
9
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
10
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
11
|
|
|
* in the Software without restriction, including without limitation the rights |
12
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
14
|
|
|
* furnished to do so, subject to the following conditions: |
15
|
|
|
* |
16
|
|
|
* The above copyright notice and this permission notice shall be included in all |
17
|
|
|
* copies or substantial portions of the Software. |
18
|
|
|
* |
19
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
25
|
|
|
* SOFTWARE. |
26
|
|
|
* |
27
|
|
|
*/ |
28
|
|
|
namespace NFe\Entity\Imposto\ICMS\Simples; |
29
|
|
|
|
30
|
|
|
use NFe\Common\Util; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* ICMS cobrado anteriormente por substituição tributária (substituído) ou |
34
|
|
|
* por antecipação |
35
|
|
|
*/ |
36
|
|
|
class Cobrado extends Generico |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
private $valor; |
40
|
|
|
|
41
|
4 |
|
public function __construct($cobrado = array()) |
42
|
|
|
{ |
43
|
4 |
|
parent::__construct($cobrado); |
44
|
4 |
|
$this->setTributacao('500'); |
45
|
4 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Valor base para cálculo do imposto |
49
|
|
|
*/ |
50
|
2 |
|
public function getBase($normalize = false) |
51
|
|
|
{ |
52
|
2 |
|
if (!$normalize) { |
53
|
2 |
|
return is_null($this->getValor())?0.00:parent::getBase($normalize); |
54
|
|
|
} |
55
|
|
|
return Util::toCurrency($this->getBase()); |
56
|
|
|
} |
57
|
|
|
|
58
|
2 |
|
public function getValor($normalize = false) |
59
|
|
|
{ |
60
|
2 |
|
if (!$normalize) { |
61
|
2 |
|
return $this->valor; |
62
|
|
|
} |
63
|
|
|
return Util::toCurrency($this->valor); |
64
|
|
|
} |
65
|
|
|
|
66
|
4 |
|
public function setValor($valor) |
67
|
|
|
{ |
68
|
4 |
|
$this->valor = $valor; |
69
|
4 |
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
public function toArray($recursive = false) |
73
|
|
|
{ |
74
|
1 |
|
$cobrado = parent::toArray($recursive); |
75
|
1 |
|
$cobrado['valor'] = $this->getValor(); |
76
|
1 |
|
return $cobrado; |
77
|
|
|
} |
78
|
|
|
|
79
|
4 |
|
public function fromArray($cobrado = array()) |
80
|
|
|
{ |
81
|
4 |
|
if ($cobrado instanceof Cobrado) { |
82
|
1 |
|
$cobrado = $cobrado->toArray(); |
83
|
4 |
|
} elseif (!is_array($cobrado)) { |
84
|
1 |
|
return $this; |
85
|
|
|
} |
86
|
4 |
|
parent::fromArray($cobrado); |
87
|
4 |
|
if (isset($cobrado['valor'])) { |
88
|
|
|
$this->setValor($cobrado['valor']); |
89
|
|
|
} else { |
90
|
4 |
|
$this->setValor(null); |
91
|
|
|
} |
92
|
4 |
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
2 |
|
public function getNode($name = null) |
96
|
|
|
{ |
97
|
2 |
|
$element = parent::getNode(is_null($name)?'ICMSSN500':$name); |
98
|
2 |
|
$dom = $element->ownerDocument; |
|
|
|
|
99
|
2 |
|
if (is_null($this->getValor())) { |
100
|
2 |
|
return $element; |
101
|
|
|
} |
102
|
|
|
Util::appendNode($element, 'vBCSTRet', $this->getBase(true)); |
103
|
|
|
Util::appendNode($element, 'vICMSSTRet', $this->getValor(true)); |
104
|
|
|
return $element; |
105
|
|
|
} |
106
|
|
|
|
107
|
2 |
|
public function loadNode($element, $name = null) |
108
|
|
|
{ |
109
|
2 |
|
$name = is_null($name)?'ICMSSN500':$name; |
110
|
2 |
|
$element = parent::loadNode($element, $name); |
111
|
2 |
|
$this->setBase(Util::loadNode($element, 'vBCSTRet')); |
112
|
2 |
|
$this->setValor(Util::loadNode($element, 'vICMSSTRet')); |
113
|
2 |
|
return $element; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.