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\PIS\ST; |
29
|
|
|
|
30
|
|
|
use NFe\Common\Util; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Este grupo só deve ser informado se o produto for sujeito a PIS por ST, |
34
|
|
|
* CST = 05, a informação deste grupo não desobriga a informação do grupo |
35
|
|
|
* PIS. |
36
|
|
|
*/ |
37
|
|
|
class Aliquota extends \NFe\Entity\Imposto\PIS\Aliquota |
38
|
|
|
{ |
39
|
|
|
|
40
|
3 |
|
public function __construct($aliquota = array()) |
41
|
|
|
{ |
42
|
3 |
|
parent::__construct($aliquota); |
43
|
3 |
|
$this->setGrupo(self::GRUPO_PISST); |
44
|
3 |
|
} |
45
|
|
|
|
46
|
1 |
|
public function toArray() |
47
|
|
|
{ |
48
|
1 |
|
$aliquota = parent::toArray(); |
49
|
1 |
|
return $aliquota; |
50
|
|
|
} |
51
|
|
|
|
52
|
3 |
|
public function fromArray($aliquota = array()) |
53
|
|
|
{ |
54
|
3 |
|
if ($aliquota instanceof Aliquota) { |
55
|
1 |
|
$aliquota = $aliquota->toArray(); |
56
|
3 |
|
} elseif (!is_array($aliquota)) { |
57
|
1 |
|
return $this; |
58
|
|
|
} |
59
|
3 |
|
parent::fromArray($aliquota); |
60
|
3 |
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
2 |
|
public function getNode($name = null) |
64
|
|
|
{ |
65
|
2 |
|
$element = parent::getNode(is_null($name)?'PISST':$name); |
66
|
2 |
|
$item = $element->getElementsByTagName('CST')->item(0); |
67
|
2 |
|
$element->removeChild($item); |
68
|
2 |
|
return $element; |
69
|
|
|
} |
70
|
|
|
|
71
|
1 |
|
public function loadNode($element, $name = null) |
72
|
|
|
{ |
73
|
1 |
|
$name = is_null($name)?'PISST':$name; |
74
|
1 |
|
if ($element->tagName != $name) { |
75
|
|
|
$_fields = $element->getElementsByTagName($name); |
76
|
|
|
if ($_fields->length == 0) { |
77
|
|
|
throw new \Exception('Tag "'.$name.'" não encontrada', 404); |
78
|
|
|
} |
79
|
|
|
$element = $_fields->item(0); |
80
|
|
|
} |
81
|
1 |
|
$this->setBase( |
82
|
1 |
|
Util::loadNode( |
83
|
1 |
|
$element, |
84
|
1 |
|
'vBC', |
85
|
|
|
'Tag "vBC" do campo "Base" não encontrada' |
86
|
1 |
|
) |
87
|
1 |
|
); |
88
|
1 |
|
$this->setAliquota( |
89
|
1 |
|
Util::loadNode( |
90
|
1 |
|
$element, |
91
|
1 |
|
'pPIS', |
92
|
|
|
'Tag "pPIS" do campo "Aliquota" não encontrada' |
93
|
1 |
|
) |
94
|
1 |
|
); |
95
|
1 |
|
return $element; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|