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
|
|
|
{ |
45
|
|
|
$this->txLvl['casP'] = $this->setValuesFromJson($lngDate, $nPercentages); |
46
|
|
|
$this->txLvl['casP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues); |
47
|
|
|
$nReturn = $this->txLvl['casP_base'] * $this->txLvl['casP'] / 100; |
48
|
|
|
if ($lngDate > 20060701) { |
49
|
|
|
$nReturn = ceil($nReturn / pow(10, 4)) * pow(10, 4); |
50
|
|
|
} |
51
|
|
|
$this->txLvl['cas'] = round($nReturn, 0); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* baza CAS |
56
|
|
|
* |
57
|
|
|
* http://www.lapensie.com/forum/salariul-mediu-brut.php |
58
|
|
|
* */ |
59
|
|
|
private function setHealthFndTxBs($lngDate, $lngBrutto, $nValues) |
60
|
|
|
{ |
61
|
|
|
$crtValues = $nValues[substr($lngDate, 0, 4)]; |
62
|
|
|
$base = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary']); |
63
|
|
|
if ($lngDate >= 20170201) { |
64
|
|
|
$base = $lngBrutto; |
65
|
|
|
} |
66
|
|
|
if (array_key_exists('Month Secondary Value', $crtValues)) { |
67
|
|
|
if (substr($lngDate, 4, 2) >= $crtValues['Month Secondary Value']) { |
68
|
|
|
$base = min($lngBrutto, $crtValues['Multiplier'] * $crtValues['Monthly Average Salary Secondary']); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
return $base; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Sanatate |
76
|
|
|
* */ |
77
|
|
|
protected function setHealthTax($lngDate, $lngBrutto, $nPercentages, $nValues) |
78
|
|
|
{ |
79
|
|
|
$this->txLvl['sntP'] = $this->setValuesFromJson($lngDate, $nPercentages); |
80
|
|
|
$nReturn = round($lngBrutto * $this->txLvl['sntP'] / 100, 0); |
81
|
|
|
if ($lngDate >= 20170101) { |
82
|
|
|
$this->txLvl['sntP_base'] = $this->setHealthFndTxBs($lngDate, $lngBrutto, $nValues); |
83
|
|
|
$nReturn = round($this->txLvl['sntP_base'] * $this->txLvl['sntP'] / 100, 0); |
84
|
|
|
} |
85
|
|
|
$this->txLvl['snt'] = (($lngDate > 20060701) ? round($nReturn, -4) : $nReturn); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
private function setValuesFromJson($lngDate, $nValues) |
89
|
|
|
{ |
90
|
|
|
$crtValues = $nValues[substr($lngDate, 0, 4)]; |
91
|
|
|
$nReturn = $crtValues['Value']; |
92
|
|
|
if (array_key_exists('Month Secondary Value', $crtValues)) { |
93
|
|
|
if (date('n', $lngDate) >= $crtValues['Month Secondary Value']) { |
94
|
|
|
$nReturn = $crtValues['Secondary Value']; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
return $nReturn; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|