|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
// |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* |
|
7
|
|
|
* The MIT License (MIT) |
|
8
|
|
|
* |
|
9
|
|
|
* Copyright (c) 2017 Daniel Popiniuc |
|
10
|
|
|
* |
|
11
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
12
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
13
|
|
|
* in the Software without restriction, including without limitation the rights |
|
14
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
15
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
16
|
|
|
* furnished to do so, subject to the following conditions: |
|
17
|
|
|
* |
|
18
|
|
|
* The above copyright notice and this permission notice shall be included in all |
|
19
|
|
|
* copies or substantial portions of the Software. |
|
20
|
|
|
* |
|
21
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
22
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
23
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
24
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
25
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
26
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
27
|
|
|
* SOFTWARE. |
|
28
|
|
|
* |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
namespace danielgp\salariu; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Description of Taxation |
|
35
|
|
|
* |
|
36
|
|
|
* @author E303778 |
|
37
|
|
|
*/ |
|
38
|
|
|
trait Taxation |
|
39
|
|
|
{ |
|
40
|
|
|
|
|
41
|
|
|
private $txLvl; |
|
42
|
|
|
|
|
43
|
|
|
private function getIncomeTaxBaseAdjustments(\Symfony\Component\HttpFoundation\Request $tCSG, $rest, $inMny) |
|
44
|
|
|
{ |
|
45
|
|
|
$restFinal = $rest + round($inMny['Food Tickets Value'], -4); |
|
46
|
|
|
$val = $tCSG->get('gbns'); |
|
47
|
|
|
$taxMinAmount = 0; |
|
48
|
|
|
if ($inMny['inDate'] >= 20160101) { |
|
49
|
|
|
$taxMinAmount = 150 * ($val || 0); |
|
50
|
|
|
} |
|
51
|
|
|
if ($inMny['inDate'] >= 20101001) { |
|
52
|
|
|
$restFinal += round(min($val, $val - $taxMinAmount) * pow(10, 4), -4); |
|
53
|
|
|
} |
|
54
|
|
|
return $restFinal; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
private function getIncomeTaxValue(\Symfony\Component\HttpFoundation\Request $tCSG, $inMny) |
|
58
|
|
|
{ |
|
59
|
|
|
$rest = $inMny['lngBase'] - array_sum($inMny['Deductions']) + round($tCSG->get('afet') * pow(10, 4), -4); |
|
60
|
|
|
if ($inMny['inDate'] >= 20100701) { |
|
61
|
|
|
$rest = $this->getIncomeTaxBaseAdjustments($tCSG, $rest, $inMny); |
|
62
|
|
|
} |
|
63
|
|
|
return $this->setIncomeTax($inMny['inDate'], $rest, $inMny['Income Tax']); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* CAS |
|
68
|
|
|
* |
|
69
|
|
|
* */ |
|
70
|
|
|
private function setHealthFundTax($lngDate, $lngBrutto, $nPercentages, $nValues) |
|
71
|
|
|
{ |
|
72
|
|
|
$this->txLvl['casP'] = $this->setValuesFromJson($lngDate, $nPercentages); |
|
73
|
|
|
$this->txLvl['casP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues); |
|
74
|
|
|
$nReturn = $this->txLvl['casP_base'] * $this->txLvl['casP'] / 100; |
|
75
|
|
|
if ($lngDate > 20060701) { |
|
76
|
|
|
$nReturn = ceil($nReturn / pow(10, 4)) * pow(10, 4); |
|
77
|
|
|
} |
|
78
|
|
|
$this->txLvl['cas'] = round($nReturn, 0); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* baza CAS |
|
83
|
|
|
* |
|
84
|
|
|
* http://www.lapensie.com/forum/salariul-mediu-brut.php |
|
85
|
|
|
* */ |
|
86
|
|
|
private function setHealthFndTxBs($lngDate, $lngBrutto, $nValues) |
|
87
|
|
|
{ |
|
88
|
|
|
$crtValues = $nValues[substr($lngDate, 0, 4)]; |
|
89
|
|
|
$base = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary']); |
|
90
|
|
|
if ($lngDate >= 20170201) { |
|
91
|
|
|
$base = $lngBrutto; |
|
92
|
|
|
} |
|
93
|
|
|
if (array_key_exists('Month Secondary Value', $crtValues)) { |
|
94
|
|
|
if (substr($lngDate, 4, 2) >= $crtValues['Month Secondary Value']) { |
|
95
|
|
|
$base = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary Secondary']); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
return $base; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Sanatate |
|
103
|
|
|
* */ |
|
104
|
|
|
protected function setHealthTax($lngDate, $lngBrutto, $nPercentages, $nValues) |
|
105
|
|
|
{ |
|
106
|
|
|
$this->txLvl['sntP'] = $this->setValuesFromJson($lngDate, $nPercentages); |
|
107
|
|
|
$nReturn = round($lngBrutto * $this->txLvl['sntP'] / 100, 0); |
|
108
|
|
|
if ($lngDate >= 20170101) { |
|
109
|
|
|
$this->txLvl['sntP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues); |
|
110
|
|
|
$nReturn = round($this->txLvl['sntP_base'] * $this->txLvl['sntP'] / 100, 0); |
|
111
|
|
|
} |
|
112
|
|
|
$this->txLvl['snt'] = (($lngDate > 20060701) ? round($nReturn, -4) : $nReturn); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Impozit pe salariu |
|
117
|
|
|
* */ |
|
118
|
|
|
protected function setIncomeTax($lngDate, $lngTaxBase, $nValues) |
|
119
|
|
|
{ |
|
120
|
|
|
$this->txLvl['inTaxP'] = '16'; |
|
121
|
|
|
$this->txLvl['inTaxP_base'] = $lngTaxBase; |
|
122
|
|
|
$nReturn = $lngTaxBase * 16 / 100; |
|
123
|
|
|
$yrDate = (int) substr($lngDate, 0, 4); |
|
124
|
|
|
if (in_array($yrDate, [2002, 2003, 2004])) { |
|
125
|
|
|
$nReturn = $this->setIncomeTaxFromJson($lngTaxBase, $nValues[$yrDate]); |
|
126
|
|
|
} elseif ($yrDate == 2001) { |
|
127
|
|
|
$nReturn = $this->setIncomeTax2001($lngDate, $lngTaxBase, $nValues); |
|
128
|
|
|
} |
|
129
|
|
|
return (($lngDate >= 20060701) ? round($nReturn, -4) : $nReturn); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Impozit pe salariu |
|
134
|
|
|
* */ |
|
135
|
|
|
private function setIncomeTax2001($lngDate, $lngTaxBase, $nValues) |
|
136
|
|
|
{ |
|
137
|
|
|
$nReturn = 0; |
|
138
|
|
|
$mnth = substr($lngDate, 4, 2); |
|
139
|
|
|
if ($mnth <= 6) { |
|
140
|
|
|
$nReturn = $this->setIncomeTaxFromJson($lngTaxBase, $nValues["2001-06"]); |
|
141
|
|
|
} elseif ($mnth <= 9) { |
|
142
|
|
|
$nReturn = $this->setIncomeTaxFromJson($lngTaxBase, $nValues["2001-09"]); |
|
143
|
|
|
} elseif ($mnth > 9) { |
|
144
|
|
|
$nReturn = $this->setIncomeTaxFromJson($lngTaxBase, $nValues["2001-12"]); |
|
145
|
|
|
} |
|
146
|
|
|
return $nReturn; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
private function setIncomeTaxFromJson($lngTaxBase, $nValues) |
|
150
|
|
|
{ |
|
151
|
|
|
$nReturn = 0; |
|
152
|
|
|
$howMany = count($nValues); |
|
153
|
|
|
for ($counter = 0; $counter <= $howMany; $counter++) { |
|
154
|
|
|
if (($lngTaxBase <= $nValues[$counter]['Upper Limit Value'])) { |
|
155
|
|
|
$sLbl = [ |
|
156
|
|
|
'BDP' => $nValues[$counter]['Base Deducted Percentage'], |
|
157
|
|
|
'BDV' => $nValues[$counter]['Base Deduction Value'], |
|
158
|
|
|
'TFV' => $nValues[$counter]['Tax Free Value'], |
|
159
|
|
|
]; |
|
160
|
|
|
$nReturn = $sLbl['TFV'] + ($lngTaxBase - $sLbl['BDV']) * $sLbl['BDP'] / 100; |
|
161
|
|
|
$this->txLvl['inTaxP'] = 'fx+' . $sLbl['BDP']; |
|
162
|
|
|
$counter = $howMany; |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
return $nReturn; |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Somaj |
|
170
|
|
|
* */ |
|
171
|
|
|
protected function setUnemploymentTax($lngDate, $lngBase) |
|
172
|
|
|
{ |
|
173
|
|
|
$yrDate = substr($lngDate, 0, 4); |
|
174
|
|
|
$this->txLvl['smjP'] = 0.5; |
|
175
|
|
|
if ($yrDate <= 2007) { |
|
176
|
|
|
$this->txLvl['smjP'] = 1; |
|
177
|
|
|
} |
|
178
|
|
|
$nReturn = round($lngBase * $this->txLvl['smjP'] / 100, 0); |
|
179
|
|
|
$this->txLvl['smj'] = (($lngDate >= 20060701) ? round($nReturn, -4) : $nReturn); |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
/** |
|
183
|
|
|
* Media zilelor lucratoare (pt. calcularea suplimentarelor) |
|
184
|
|
|
* astfel incat acestea sa nu fie mai valoroase sau nu functie |
|
185
|
|
|
* de numarul zilelor din luna respectiva |
|
186
|
|
|
* |
|
187
|
|
|
* @param string $lngDate |
|
188
|
|
|
* @param array $stdAvgWrkngHrs |
|
189
|
|
|
* @param boolean $bCEaster |
|
190
|
|
|
* @return int |
|
191
|
|
|
*/ |
|
192
|
|
|
protected function setMonthlyAverageWorkingHours($lngDate, $stdAvgWrkngHrs, $bCEaster = false) |
|
193
|
|
|
{ |
|
194
|
|
|
$nReturn = $stdAvgWrkngHrs[substr($lngDate, 0, 4)]; |
|
195
|
|
|
if ($bCEaster) { |
|
196
|
|
|
$nReturn = ($nReturn * 12 - 8) / 12; |
|
197
|
|
|
} |
|
198
|
|
|
return $nReturn; |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
private function setValuesFromJson($lngDate, $nValues) |
|
202
|
|
|
{ |
|
203
|
|
|
$crtValues = $nValues[substr($lngDate, 0, 4)]; |
|
204
|
|
|
$nReturn = $crtValues['Value']; |
|
205
|
|
|
if (array_key_exists('Month Secondary Value', $crtValues)) { |
|
206
|
|
|
if (date('n', $lngDate) >= $crtValues['Month Secondary Value']) { |
|
207
|
|
|
$nReturn = $crtValues['Secondary Value']; |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
return $nReturn; |
|
211
|
|
|
} |
|
212
|
|
|
} |
|
213
|
|
|
|