|
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
|
|
|
* Partilha do ICMS entre a UF de origem e UF de destino ou a UF definida |
|
34
|
|
|
* na legislação |
|
35
|
|
|
* Operação interestadual para consumidor final com partilha |
|
36
|
|
|
* do ICMS devido na operação entre a UF de origem e a UF do destinatário |
|
37
|
|
|
* ou ou a UF definida na legislação. (Ex. UF da concessionária de entrega |
|
38
|
|
|
* do veículos) |
|
39
|
|
|
*/ |
|
40
|
|
|
class Partilha extends Mista |
|
41
|
|
|
{ |
|
42
|
|
|
|
|
43
|
|
|
private $operacao; |
|
44
|
|
|
private $uf; |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
3 |
|
public function __construct($partilha = array()) |
|
47
|
|
|
{ |
|
48
|
3 |
|
parent::__construct($partilha); |
|
49
|
3 |
|
$this->setTributacao('10'); |
|
50
|
3 |
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Percentual para determinação do valor da Base de Cálculo da operação |
|
54
|
|
|
* própria. |
|
55
|
|
|
*/ |
|
56
|
2 |
|
public function getOperacao($normalize = false) |
|
57
|
|
|
{ |
|
58
|
2 |
|
if (!$normalize) { |
|
59
|
1 |
|
return $this->operacao; |
|
60
|
|
|
} |
|
61
|
2 |
|
return Util::toFloat($this->operacao); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
3 |
|
public function setOperacao($operacao) |
|
65
|
|
|
{ |
|
66
|
3 |
|
$this->operacao = $operacao; |
|
67
|
3 |
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Sigla da UF para qual é devido o ICMS ST da operação. |
|
72
|
|
|
*/ |
|
73
|
2 |
|
public function getUF($normalize = false) |
|
74
|
|
|
{ |
|
75
|
2 |
|
if (!$normalize) { |
|
76
|
1 |
|
return $this->uf; |
|
77
|
|
|
} |
|
78
|
2 |
|
return $this->uf; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
3 |
|
public function setUF($uf) |
|
|
|
|
|
|
82
|
|
|
{ |
|
83
|
3 |
|
$this->uf = $uf; |
|
84
|
3 |
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
1 |
|
public function toArray($recursive = false) |
|
88
|
|
|
{ |
|
89
|
1 |
|
$partilha = parent::toArray($recursive); |
|
90
|
1 |
|
$partilha['operacao'] = $this->getOperacao(); |
|
91
|
1 |
|
$partilha['uf'] = $this->getUF(); |
|
92
|
1 |
|
return $partilha; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
3 |
|
public function fromArray($partilha = array()) |
|
96
|
|
|
{ |
|
97
|
3 |
|
if ($partilha instanceof Partilha) { |
|
98
|
1 |
|
$partilha = $partilha->toArray(); |
|
99
|
3 |
|
} elseif (!is_array($partilha)) { |
|
100
|
1 |
|
return $this; |
|
101
|
|
|
} |
|
102
|
3 |
|
parent::fromArray($partilha); |
|
103
|
3 |
|
if (isset($partilha['operacao'])) { |
|
104
|
1 |
|
$this->setOperacao($partilha['operacao']); |
|
105
|
|
|
} else { |
|
106
|
3 |
|
$this->setOperacao(null); |
|
107
|
|
|
} |
|
108
|
3 |
|
if (isset($partilha['uf'])) { |
|
109
|
1 |
|
$this->setUF($partilha['uf']); |
|
110
|
|
|
} else { |
|
111
|
3 |
|
$this->setUF(null); |
|
112
|
|
|
} |
|
113
|
3 |
|
return $this; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
2 |
|
public function getNode($name = null) |
|
117
|
|
|
{ |
|
118
|
2 |
|
$element = parent::getNode(is_null($name)?'ICMSPart':$name); |
|
119
|
2 |
|
$dom = $element->ownerDocument; |
|
|
|
|
|
|
120
|
2 |
|
Util::appendNode($element, 'pBCOp', $this->getOperacao(true)); |
|
121
|
2 |
|
Util::appendNode($element, 'UFST', $this->getUF(true)); |
|
122
|
2 |
|
return $element; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
1 |
|
public function loadNode($element, $name = null) |
|
126
|
|
|
{ |
|
127
|
1 |
|
$name = is_null($name)?'ICMSPart':$name; |
|
128
|
1 |
|
$element = parent::loadNode($element, $name); |
|
129
|
1 |
|
$this->setOperacao( |
|
130
|
1 |
|
Util::loadNode( |
|
131
|
1 |
|
$element, |
|
132
|
1 |
|
'pBCOp', |
|
133
|
1 |
|
'Tag "pBCOp" do campo "Operacao" não encontrada na Partilha' |
|
134
|
|
|
) |
|
135
|
|
|
); |
|
136
|
1 |
|
$this->setUF( |
|
137
|
1 |
|
Util::loadNode( |
|
138
|
1 |
|
$element, |
|
139
|
1 |
|
'UFST', |
|
140
|
1 |
|
'Tag "UFST" do campo "UF" não encontrada na Partilha' |
|
141
|
|
|
) |
|
142
|
|
|
); |
|
143
|
1 |
|
return $element; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.