|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* The MIT License (MIT) |
|
6
|
|
|
* |
|
7
|
|
|
* Copyright (c) 2015 Daniel Popiniuc |
|
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
|
|
|
|
|
29
|
|
|
namespace danielgp\salariu; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Description of Bonuses |
|
33
|
|
|
* |
|
34
|
|
|
* @author E303778 |
|
35
|
|
|
*/ |
|
36
|
|
|
trait Bonuses |
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Tichete de alimente |
|
41
|
|
|
* */ |
|
42
|
|
|
protected function setFoodTicketsValue($lngDate, $arySettingMealTickets) |
|
43
|
|
|
{ |
|
44
|
|
|
$valueMealTicket = 0; |
|
45
|
|
|
$indexArrayValues = 0; |
|
46
|
|
|
$currentUpperLimitDate = mktime(0, 0, 0, date('n'), 1, date('Y')); |
|
47
|
|
|
while (($valueMealTicket === 0)) { |
|
48
|
|
|
$crtVal = $arySettingMealTickets[$indexArrayValues]; |
|
49
|
|
|
$currentLowerLimitDate = mktime(0, 0, 0, $crtVal['Month'], 1, $crtVal['Year']); |
|
50
|
|
|
if (($lngDate <= $currentUpperLimitDate) && ($lngDate >= $currentLowerLimitDate)) { |
|
51
|
|
|
$valueMealTicket = $crtVal['Value']; |
|
52
|
|
|
} |
|
53
|
|
|
$currentUpperLimitDate = $currentLowerLimitDate; |
|
54
|
|
|
$indexArrayValues++; |
|
55
|
|
|
} |
|
56
|
|
|
return $valueMealTicket; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Deducere personala |
|
61
|
|
|
* */ |
|
62
|
|
|
protected function setPersonalDeduction($lngDate, $lngBrutto, $sPersons, $cValues) |
|
63
|
|
|
{ |
|
64
|
|
|
$yrDate = date('Y', $lngDate); |
|
65
|
|
|
$nReturn = 0; |
|
66
|
|
|
if ($yrDate >= 2005) { |
|
67
|
|
|
$nReturn = $this->setPersonalDeductionComplex2016($sPersons, $lngBrutto, $yrDate, $cValues); |
|
68
|
|
|
} elseif ($yrDate >= 2001) { |
|
69
|
|
|
$valuesYearly = [ |
|
70
|
|
|
2001 => $this->setPersonalDeductionSimple2001($lngDate), |
|
71
|
|
|
2002 => 1600000, |
|
72
|
|
|
2003 => 1800000, |
|
73
|
|
|
2004 => 2000000, |
|
74
|
|
|
]; |
|
75
|
|
|
$nReturn = $valuesYearly[$yrDate]; |
|
76
|
|
|
} |
|
77
|
|
|
return (($lngDate >= mktime(0, 0, 0, 7, 1, 2006)) ? round($nReturn, -4) : $nReturn); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
private function setPersonalDeductionComplex($sPersons, $lngBrutto, $inRule) |
|
81
|
|
|
{ |
|
82
|
|
|
$nDeduction = $inRule['Limit maximum amount']; |
|
83
|
|
|
if ($sPersons <= $inRule['Limit persons']) { |
|
84
|
|
|
$nDeduction = $inRule['Limit basic amount'] + ($sPersons * $inRule['Limit /person amount']); |
|
85
|
|
|
} |
|
86
|
|
|
$nReturn = $nDeduction; |
|
87
|
|
|
if ($lngBrutto >= $inRule['Limit zero deduction']) { |
|
88
|
|
|
$nReturn = 0; |
|
89
|
|
|
} elseif ($lngBrutto > $inRule['Reduced deduction']) { |
|
90
|
|
|
$nReturn = $nDeduction * (1 - ($lngBrutto - $inRule['Reduced deduction']) / $inRule['Reduced deduction']); |
|
91
|
|
|
} |
|
92
|
|
|
return $nReturn; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
private function setPersonalDeductionComplex2016($sPersons, $lngBrutto, $yrDate, $cValues) |
|
96
|
|
|
{ |
|
97
|
|
|
$inRule = $cValues[2005]; |
|
98
|
|
|
if ($yrDate == 2016) { |
|
99
|
|
|
$inRule = $cValues[2016]; |
|
100
|
|
|
} |
|
101
|
|
|
return $this->setPersonalDeductionComplex($sPersons, $lngBrutto, $inRule); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
private function setPersonalDeductionSimple2001($lngDate) |
|
105
|
|
|
{ |
|
106
|
|
|
$nReturn = 1300000; |
|
107
|
|
|
$mnDate = date('n', $lngDate); |
|
108
|
|
|
if ($mnDate <= 6) { |
|
109
|
|
|
$nReturn = 1099000; |
|
110
|
|
|
} elseif ($mnDate <= 9) { |
|
111
|
|
|
$nReturn = 1273000; |
|
112
|
|
|
} |
|
113
|
|
|
return $nReturn; |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|