1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Gbbs\NfeCalculos; |
6
|
|
|
|
7
|
|
|
use Exception; |
8
|
|
|
|
9
|
|
|
class PIS |
10
|
|
|
{ |
11
|
|
|
private $CST; |
12
|
|
|
public $vBC; |
13
|
|
|
public $pPIS; |
14
|
|
|
public $vPIS; |
15
|
|
|
public $pRedBC; |
16
|
|
|
public $Desconto; |
17
|
|
|
public $vAliqProd; |
18
|
|
|
public $qBCProd; |
19
|
|
|
public $REIDE; |
20
|
|
|
public $SUFRAMA; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param PIS $PIS |
24
|
|
|
* @return PIS|mixed |
25
|
|
|
* @throws Exception |
26
|
|
|
*/ |
27
|
|
|
public static function calcular(PIS $PIS) |
28
|
|
|
{ |
29
|
|
|
/* Operação Tributável com Alíquota Básica */ |
30
|
|
|
if ($PIS->getCST() === '01') { |
31
|
|
|
return self::calcaPIS($PIS); |
32
|
|
|
} elseif ($PIS->getCST() === '02') { |
33
|
|
|
throw new Exception('Not implemented'); |
34
|
|
|
// return self::calcaPIS($PIS); |
35
|
|
|
} elseif ($PIS->getCST() === '03') { |
36
|
|
|
throw new Exception('Not implemented'); |
37
|
|
|
// return self::calcAliqCST03($PIS); |
38
|
|
|
} elseif ($PIS->getCST() === '04') { |
39
|
|
|
throw new Exception('Not implemented'); |
40
|
|
|
// return self::calcIsento($PIS); |
41
|
|
|
} elseif ($PIS->getCST() === '05') { |
42
|
|
|
throw new Exception('Not implemented'); |
43
|
|
|
// return self::calcIsento($PIS); |
44
|
|
|
} elseif ($PIS->getCST() === '06') { |
45
|
|
|
throw new Exception('Not implemented'); |
46
|
|
|
// return self::calcIsento($PIS); |
47
|
|
|
} elseif ($PIS->getCST() === '07') { |
48
|
|
|
throw new Exception('Not implemented'); |
49
|
|
|
// return self::calcIsentoDesconto($PIS); |
50
|
|
|
} elseif ($PIS->getCST() === '08') { |
51
|
|
|
throw new Exception('Not implemented'); |
52
|
|
|
// return self::calcIsento($PIS); |
53
|
|
|
} elseif ($PIS->getCST() === '09') { |
54
|
|
|
throw new Exception('Not implemented'); |
55
|
|
|
// return self::calcIsento($PIS); |
56
|
|
|
} elseif ($PIS->getCST() === '49') { |
57
|
|
|
throw new Exception('Not implemented'); |
58
|
|
|
// return self::calcIsento($PIS); |
59
|
|
|
} elseif ($PIS->getCST() === '50') { |
60
|
|
|
throw new Exception('Not implemented'); |
61
|
|
|
// return self::calcaPIS($PIS); |
62
|
|
|
} elseif ($PIS->getCST() === '51') { |
63
|
|
|
throw new Exception('Not implemented'); |
64
|
|
|
// return self::calcaPIS($PIS); |
65
|
|
|
} elseif ($PIS->getCST() === '52') { |
66
|
|
|
throw new Exception('Not implemented'); |
67
|
|
|
// return self::calcaPIS($PIS); |
68
|
|
|
} elseif ($PIS->getCST() === '53') { |
69
|
|
|
throw new Exception('Not implemented'); |
70
|
|
|
// return self::calcaPIS($PIS); |
71
|
|
|
} elseif ($PIS->getCST() === '54') { |
72
|
|
|
throw new Exception('Not implemented'); |
73
|
|
|
// return self::calcaPIS($PIS); |
74
|
|
|
} elseif ($PIS->getCST() === '55') { |
75
|
|
|
throw new Exception('Not implemented'); |
76
|
|
|
// return self::calcaPIS($PIS); |
77
|
|
|
} elseif ($PIS->getCST() === '56') { |
78
|
|
|
throw new Exception('Not implemented'); |
79
|
|
|
// return self::calcaPIS($PIS); |
80
|
|
|
} elseif ($PIS->getCST() === '60') { |
81
|
|
|
throw new Exception('Not implemented'); |
82
|
|
|
// return self::calcaPIS($PIS); |
83
|
|
|
} elseif ($PIS->getCST() === '61') { |
84
|
|
|
throw new Exception('Not implemented'); |
85
|
|
|
// return self::calcaPIS($PIS); |
86
|
|
|
} elseif ($PIS->getCST() === '62') { |
87
|
|
|
throw new Exception('Not implemented'); |
88
|
|
|
// return self::calcaPIS($PIS); |
89
|
|
|
} elseif ($PIS->getCST() === '63') { |
90
|
|
|
throw new Exception('Not implemented'); |
91
|
|
|
// return self::calcaPIS($PIS); |
92
|
|
|
} elseif ($PIS->getCST() === '64') { |
93
|
|
|
throw new Exception('Not implemented'); |
94
|
|
|
// return self::calcaPIS($PIS); |
95
|
|
|
} elseif ($PIS->getCST() === '65') { |
96
|
|
|
throw new Exception('Not implemented'); |
97
|
|
|
// return self::calcaPIS($PIS); |
98
|
|
|
} elseif ($PIS->getCST() === '66') { |
99
|
|
|
throw new Exception('Not implemented'); |
100
|
|
|
// return self::calcaPIS($PIS); |
101
|
|
|
} elseif ($PIS->getCST() === '67') { |
102
|
|
|
throw new Exception('Not implemented'); |
103
|
|
|
// return self::calcaPIS($PIS); |
104
|
|
|
} elseif ($PIS->getCST() === '70') { |
105
|
|
|
throw new Exception('Not implemented'); |
106
|
|
|
// return self::calcIsento($PIS); |
107
|
|
|
} elseif ($PIS->getCST() === '71') { |
108
|
|
|
throw new Exception('Not implemented'); |
109
|
|
|
// return self::calcaPIS($PIS); |
110
|
|
|
} elseif ($PIS->getCST() === '72') { |
111
|
|
|
throw new Exception('Not implemented'); |
112
|
|
|
// return self::calcaPIS($PIS); |
113
|
|
|
} elseif ($PIS->getCST() === '73') { |
114
|
|
|
throw new Exception('Not implemented'); |
115
|
|
|
// return self::calcaPIS($PIS); |
116
|
|
|
} elseif ($PIS->getCST() === '74') { |
117
|
|
|
throw new Exception('Not implemented'); |
118
|
|
|
// return self::calcaPIS($PIS); |
119
|
|
|
} elseif ($PIS->getCST() === '75') { |
120
|
|
|
throw new Exception('Not implemented'); |
121
|
|
|
// return self::calcaPIS($PIS); |
122
|
|
|
} elseif ($PIS->getCST() === '98') { |
123
|
|
|
throw new Exception('Not implemented'); |
124
|
|
|
// return self::calcaPIS($PIS); |
125
|
|
|
} elseif ($PIS->getCST() === '99') { |
126
|
|
|
throw new Exception('Not implemented'); |
127
|
|
|
// return self::calcIsento($PIS); |
128
|
|
|
} |
129
|
|
|
throw new Exception('Erro ao calcular PIS' . print_r($PIS, true)); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
// private static function calcIsento($PIS) |
133
|
|
|
// { |
134
|
|
|
// $PIS->pPIS = 0.65; |
135
|
|
|
// if ($PIS->REIDE === 1 || $PIS->SUFRAMA === 1) { |
136
|
|
|
// $PIS->Desconto = $PIS->vBC * ($PIS->pPIS / 100); |
137
|
|
|
// } else { |
138
|
|
|
// $PIS->Desconto = 0; |
139
|
|
|
// } |
140
|
|
|
// $PIS->vPIS = '0'; |
141
|
|
|
// $PIS->vBC = '0'; |
142
|
|
|
// $PIS->pPIS = '0'; |
143
|
|
|
// |
144
|
|
|
// return $PIS; |
145
|
|
|
// } |
146
|
|
|
|
147
|
|
|
private static function calcaPIS($PIS) |
148
|
|
|
{ |
149
|
|
|
$PIS->pPIS = 0.65; |
150
|
|
|
if ($PIS->REIDE === 1 || $PIS->SUFRAMA === 1) { |
151
|
|
|
$PIS->Desconto = $PIS->vBC * ($PIS->pPIS / 100); |
152
|
|
|
} else { |
153
|
|
|
$PIS->Desconto = 0; |
154
|
|
|
} |
155
|
|
|
$PIS->pRedBC = 0; |
156
|
|
|
$PIS->vPIS = (($PIS->vBC - ($PIS->vBC * ($PIS->pRedBC / 100))) * ($PIS->pPIS / 100)); |
157
|
|
|
return $PIS; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
// private static function calcIsentoDesconto($PIS) |
161
|
|
|
// { |
162
|
|
|
// $PIS->pPIS = 0.65; |
163
|
|
|
// if ($PIS->REIDE === 1 || $PIS->SUFRAMA === 1) { |
164
|
|
|
// $PIS->Desconto = $PIS->vBC * ($PIS->pPIS / 100); |
165
|
|
|
// } else { |
166
|
|
|
// $PIS->Desconto = 0; |
167
|
|
|
// } |
168
|
|
|
// $PIS->vPIS = '0'; |
169
|
|
|
// $PIS->vBC = '0'; |
170
|
|
|
// $PIS->pPIS = '0'; |
171
|
|
|
// $PIS->vPIS = '0'; |
172
|
|
|
// |
173
|
|
|
// return $PIS; |
174
|
|
|
// } |
175
|
|
|
// |
176
|
|
|
// private static function calcAliqCST03($PIS) |
177
|
|
|
// { |
178
|
|
|
// $PIS->vBC = 0; |
179
|
|
|
// $PIS->pPIS = 0; |
180
|
|
|
// $PIS->vPIS = round((($PIS->vAliqProd) * ($PIS->qBCProd)), 2); |
181
|
|
|
// return $PIS; |
182
|
|
|
// } |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return string |
186
|
|
|
*/ |
187
|
|
|
public function getCST(): string |
188
|
|
|
{ |
189
|
|
|
return $this->CST; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param string $CST |
194
|
|
|
*/ |
195
|
|
|
public function setCST(string $CST): void |
196
|
|
|
{ |
197
|
|
|
$this->CST = $CST; |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
|