|
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; |
|
29
|
|
|
|
|
30
|
|
|
use NFe\Common\Util; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Grupo de informação do ICMSST devido para a UF de destino, nas operações |
|
34
|
|
|
* interestaduais de produtos que tiveram retenção antecipada de ICMS por |
|
35
|
|
|
* ST na UF do remetente. Repasse via Substituto Tributário. |
|
36
|
|
|
*/ |
|
37
|
|
|
class Substituto extends Cobrado |
|
38
|
|
|
{ |
|
39
|
|
|
|
|
40
|
3 |
|
public function __construct($substituto = array()) |
|
41
|
|
|
{ |
|
42
|
3 |
|
parent::__construct($substituto); |
|
43
|
3 |
|
$this->setTributacao('41'); |
|
44
|
3 |
|
$this->setNormal(new Cobrado()); |
|
45
|
3 |
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
public function toArray($recursive = false) |
|
48
|
|
|
{ |
|
49
|
1 |
|
$substituto = parent::toArray($recursive); |
|
50
|
1 |
|
return $substituto; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
3 |
|
public function fromArray($substituto = array()) |
|
54
|
|
|
{ |
|
55
|
3 |
|
if ($substituto instanceof Substituto) { |
|
56
|
1 |
|
$substituto = $substituto->toArray(); |
|
57
|
3 |
|
} elseif (!is_array($substituto)) { |
|
58
|
1 |
|
return $this; |
|
59
|
|
|
} |
|
60
|
3 |
|
parent::fromArray($substituto); |
|
61
|
3 |
|
return $this; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
2 |
|
public function getNode($name = null) |
|
65
|
|
|
{ |
|
66
|
2 |
|
$element = parent::getNode(is_null($name)?'ICMSST':$name); |
|
67
|
2 |
|
$dom = $element->ownerDocument; |
|
|
|
|
|
|
68
|
2 |
|
Util::appendNode($element, 'vBCSTDest', $this->getNormal()->getBase(true)); |
|
69
|
2 |
|
Util::appendNode($element, 'vICMSSTDest', $this->getNormal()->getValor(true)); |
|
70
|
2 |
|
return $element; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
1 |
|
public function loadNode($element, $name = null) |
|
74
|
|
|
{ |
|
75
|
1 |
|
$name = is_null($name)?'ICMSST':$name; |
|
76
|
1 |
|
$element = parent::loadNode($element, $name); |
|
77
|
1 |
|
$this->getNormal()->setBase( |
|
78
|
1 |
|
Util::loadNode( |
|
79
|
1 |
|
$element, |
|
80
|
1 |
|
'vBCSTDest', |
|
81
|
1 |
|
'Tag "vBCSTDest" do campo "Normal.Base" não encontrada no Substituto' |
|
82
|
|
|
) |
|
83
|
|
|
); |
|
84
|
1 |
|
$this->getNormal()->setValor( |
|
85
|
1 |
|
Util::loadNode( |
|
86
|
1 |
|
$element, |
|
87
|
1 |
|
'vICMSSTDest', |
|
88
|
1 |
|
'Tag "vICMSSTDest" do campo "Normal.Valor" não encontrada no Substituto' |
|
89
|
|
|
) |
|
90
|
|
|
); |
|
91
|
1 |
|
return $element; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.