|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* The MIT License |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright 2018 Daniel Popiniuc |
|
7
|
|
|
* |
|
8
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
9
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
10
|
|
|
* in the Software without restriction, including without limitation the rights |
|
11
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
12
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
13
|
|
|
* furnished to do so, subject to the following conditions: |
|
14
|
|
|
* |
|
15
|
|
|
* The above copyright notice and this permission notice shall be included in |
|
16
|
|
|
* all copies or substantial portions of the Software. |
|
17
|
|
|
* |
|
18
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
19
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
20
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
21
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
22
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
23
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
24
|
|
|
* THE SOFTWARE. |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace danielgp\salariu; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Description of Taxation |
|
31
|
|
|
* |
|
32
|
|
|
* @author E303778 |
|
33
|
|
|
*/ |
|
34
|
|
|
trait TaxationHealth |
|
35
|
|
|
{ |
|
36
|
|
|
|
|
37
|
|
|
protected $txLvl; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* CAS |
|
41
|
|
|
* |
|
42
|
|
|
* */ |
|
43
|
|
|
private function setHealthFundTax($lngDate, $lngBrutto, $nPercentages, $nValues) { |
|
44
|
|
|
$this->txLvl['casP'] = $this->setValuesFromJson($lngDate, $nPercentages); |
|
45
|
|
|
$this->txLvl['casP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues); |
|
46
|
|
|
$nReturn = $this->txLvl['casP_base'] * $this->txLvl['casP'] / 100; |
|
47
|
|
|
if ($lngDate > 20060701) { |
|
48
|
|
|
$nReturn = ceil($nReturn / pow(10, 4)) * pow(10, 4); |
|
49
|
|
|
} |
|
50
|
|
|
$this->txLvl['cas'] = round($nReturn, 0); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* baza CAS |
|
55
|
|
|
* |
|
56
|
|
|
* http://www.lapensie.com/forum/salariul-mediu-brut.php |
|
57
|
|
|
* */ |
|
58
|
|
|
private function setHealthFndTxBs($lngDate, $lngBrutto, $nValues) { |
|
59
|
|
|
$crtValues = $nValues[substr($lngDate, 0, 4)]; |
|
60
|
|
|
$base = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary']); |
|
61
|
|
|
if ($lngDate >= 20170201) { |
|
62
|
|
|
$base = $lngBrutto; |
|
63
|
|
|
} |
|
64
|
|
|
if (array_key_exists('Month Secondary Value', $crtValues)) { |
|
65
|
|
|
if (substr($lngDate, 4, 2) >= $crtValues['Month Secondary Value']) { |
|
66
|
|
|
$base = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary Secondary']); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
return $base; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Sanatate |
|
74
|
|
|
* */ |
|
75
|
|
|
protected function setHealthTax($lngDate, $lngBrutto, $nPercentages, $nValues) { |
|
76
|
|
|
$this->txLvl['sntP'] = $this->setValuesFromJson($lngDate, $nPercentages); |
|
77
|
|
|
$nReturn = round($lngBrutto * $this->txLvl['sntP'] / 100, 0); |
|
78
|
|
|
if ($lngDate >= 20170101) { |
|
79
|
|
|
$this->txLvl['sntP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues); |
|
80
|
|
|
$nReturn = round($this->txLvl['sntP_base'] * $this->txLvl['sntP'] / 100, 0); |
|
81
|
|
|
} |
|
82
|
|
|
$this->txLvl['snt'] = (($lngDate > 20060701) ? round($nReturn, -4) : $nReturn); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
private function setValuesFromJson($lngDate, $nValues) { |
|
86
|
|
|
$crtValues = $nValues[substr($lngDate, 0, 4)]; |
|
87
|
|
|
$nReturn = $crtValues['Value']; |
|
88
|
|
|
if (array_key_exists('Month Secondary Value', $crtValues)) { |
|
89
|
|
|
if (date('n', $lngDate) >= $crtValues['Month Secondary Value']) { |
|
90
|
|
|
$nReturn = $crtValues['Secondary Value']; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
return $nReturn; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|