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
|
|
|
* Tributada pelo Simples Nacional sem permissão de crédito e com cobrança |
34
|
|
|
* do ICMS por substituição tributária |
35
|
|
|
*/ |
36
|
|
|
class Parcial extends \NFe\Entity\Imposto\ICMS\Parcial |
37
|
|
|
{ |
38
|
|
|
|
39
|
11 |
|
public function __construct($parcial = array()) |
40
|
|
|
{ |
41
|
11 |
|
parent::__construct($parcial); |
42
|
11 |
|
$this->setTributacao('202'); |
43
|
11 |
|
} |
44
|
|
|
|
45
|
5 |
|
public function toArray() |
46
|
|
|
{ |
47
|
5 |
|
$parcial = parent::toArray(); |
48
|
5 |
|
return $parcial; |
49
|
|
|
} |
50
|
|
|
|
51
|
11 |
|
public function fromArray($parcial = array()) |
52
|
|
|
{ |
53
|
11 |
|
if ($parcial instanceof Parcial) { |
54
|
1 |
|
$parcial = $parcial->toArray(); |
55
|
11 |
|
} elseif (!is_array($parcial)) { |
56
|
1 |
|
return $this; |
57
|
|
|
} |
58
|
11 |
|
parent::fromArray($parcial); |
59
|
11 |
|
return $this; |
60
|
|
|
} |
61
|
|
|
|
62
|
4 |
|
public function getNode($name = null) |
63
|
|
|
{ |
64
|
4 |
|
$dom = new \DOMDocument('1.0', 'UTF-8'); |
65
|
4 |
|
$element = $dom->createElement(is_null($name)?'IMCSSN202':$name); |
66
|
4 |
|
Util::appendNode($element, 'orig', $this->getOrigem(true)); |
67
|
4 |
|
Util::appendNode($element, 'CSOSN', $this->getTributacao(true)); |
68
|
4 |
|
Util::appendNode($element, 'modBCST', $this->getModalidade(true)); |
69
|
4 |
|
Util::appendNode($element, 'pMVAST', $this->getMargem(true)); |
70
|
4 |
|
Util::appendNode($element, 'pRedBCST', $this->getReducao(true)); |
71
|
4 |
|
Util::appendNode($element, 'vBCST', $this->getBase(true)); |
72
|
4 |
|
Util::appendNode($element, 'pICMSST', $this->getAliquota(true)); |
73
|
4 |
|
Util::appendNode($element, 'vICMSST', $this->getValor(true)); |
74
|
4 |
|
return $element; |
75
|
|
|
} |
76
|
|
|
|
77
|
2 |
|
public function loadNode($element, $name = null) |
78
|
|
|
{ |
79
|
2 |
|
$name = is_null($name)?'IMCSSN202':$name; |
80
|
2 |
|
if ($element->tagName != $name) { |
81
|
|
|
$_fields = $element->getElementsByTagName($name); |
82
|
|
|
if ($_fields->length == 0) { |
83
|
|
|
throw new \Exception('Tag "'.$name.'" não encontrada', 404); |
84
|
|
|
} |
85
|
|
|
$element = $_fields->item(0); |
86
|
|
|
} |
87
|
2 |
|
$this->setOrigem( |
88
|
2 |
|
Util::loadNode( |
89
|
2 |
|
$element, |
90
|
2 |
|
'orig', |
91
|
|
|
'Tag "orig" do campo "Origem" não encontrada' |
92
|
2 |
|
) |
93
|
2 |
|
); |
94
|
2 |
|
$this->setTributacao( |
95
|
2 |
|
Util::loadNode( |
96
|
2 |
|
$element, |
97
|
2 |
|
'CSOSN', |
98
|
|
|
'Tag "CSOSN" do campo "Tributacao" não encontrada' |
99
|
2 |
|
) |
100
|
2 |
|
); |
101
|
2 |
|
$this->setModalidade( |
102
|
2 |
|
Util::loadNode( |
103
|
2 |
|
$element, |
104
|
2 |
|
'modBCST', |
105
|
|
|
'Tag "modBCST" do campo "Modalidade" não encontrada' |
106
|
2 |
|
) |
107
|
2 |
|
); |
108
|
2 |
|
$this->setMargem( |
109
|
2 |
|
Util::loadNode( |
110
|
2 |
|
$element, |
111
|
2 |
|
'pMVAST', |
112
|
|
|
'Tag "pMVAST" do campo "Margem" não encontrada' |
113
|
2 |
|
) |
114
|
2 |
|
); |
115
|
2 |
|
$this->setReducao( |
116
|
2 |
|
Util::loadNode( |
117
|
2 |
|
$element, |
118
|
2 |
|
'pRedBCST', |
119
|
|
|
'Tag "pRedBCST" do campo "Reducao" não encontrada' |
120
|
2 |
|
) |
121
|
2 |
|
); |
122
|
2 |
|
$this->setBase( |
123
|
2 |
|
Util::loadNode( |
124
|
2 |
|
$element, |
125
|
2 |
|
'vBCST', |
126
|
|
|
'Tag "vBCST" do campo "Base" não encontrada' |
127
|
2 |
|
) |
128
|
2 |
|
); |
129
|
2 |
|
$this->setAliquota( |
130
|
2 |
|
Util::loadNode( |
131
|
2 |
|
$element, |
132
|
2 |
|
'pICMSST', |
133
|
|
|
'Tag "pICMSST" do campo "Aliquota" não encontrada' |
134
|
2 |
|
) |
135
|
2 |
|
); |
136
|
2 |
|
return $element; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|