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