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
|
|
|
* returns an array with non-standard holidays from a JSON file |
41
|
|
|
* |
42
|
|
|
* @param string $fileBaseName |
43
|
|
|
* @return mixed |
44
|
|
|
*/ |
45
|
|
|
private function readTypeFromJsonFile($fileBaseName) |
46
|
|
|
{ |
47
|
|
|
$fName = __DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $fileBaseName . '.min.json'; |
48
|
|
|
$fJson = fopen($fName, 'r'); |
49
|
|
|
$jSonContent = fread($fJson, filesize($fName)); |
50
|
|
|
fclose($fJson); |
51
|
|
|
return json_decode($jSonContent, true); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Tichete de alimente |
56
|
|
|
* */ |
57
|
|
|
protected function setFoodTicketsValue($lngDate) |
58
|
|
|
{ |
59
|
|
|
$arrayValues = $this->readTypeFromJsonFile('static')['Meal Ticket Value']; |
60
|
|
|
$valueMealTicket = 0; |
61
|
|
|
$indexArrayValues = 0; |
62
|
|
|
$currentUpperLimitDate = mktime(0, 0, 0, date('n'), 1, date('Y')); |
63
|
|
|
while (($valueMealTicket === 0)) { |
64
|
|
|
$crtVal = $arrayValues[$indexArrayValues]; |
65
|
|
|
$currentLowerLimitDate = mktime(0, 0, 0, $crtVal['Month'], 1, $crtVal['Year']); |
66
|
|
|
if (($lngDate <= $currentUpperLimitDate) && ($lngDate >= $currentLowerLimitDate)) { |
67
|
|
|
$valueMealTicket = $crtVal['Value']; |
68
|
|
|
} |
69
|
|
|
$currentUpperLimitDate = $currentLowerLimitDate; |
70
|
|
|
$indexArrayValues++; |
71
|
|
|
} |
72
|
|
|
return $valueMealTicket; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Deducere personala |
77
|
|
|
* */ |
78
|
|
|
protected function setPersonalDeduction($lngDate, $lngBrutto, $sPersons) |
79
|
|
|
{ |
80
|
|
|
$yrDate = date('Y', $lngDate); |
81
|
|
|
$nReturn = 0; |
82
|
|
|
if ($yrDate == 2016) { |
83
|
|
|
$nReturn = $this->setPersonalDeductionComplex($sPersons, $lngBrutto, [ |
84
|
|
|
'Limit persons' => 3, |
85
|
|
|
'Limit basic amount' => 3500000, |
86
|
|
|
'Limit maximum amount' => 8000000, |
87
|
|
|
'Limit /person amount' => 1000000, |
88
|
|
|
'Limit zero deduction' => 30000000, |
89
|
|
|
'Reduced deduction' => 15000000, |
90
|
|
|
]); |
91
|
|
|
} elseif (($yrDate >= 2005) && ($yr <= 2015)) { |
|
|
|
|
92
|
|
|
$nReturn = $this->setPersonalDeductionComplex($sPersons, $lngBrutto, [ |
93
|
|
|
'Limit persons' => 3, |
94
|
|
|
'Limit basic amount' => 2500000, |
95
|
|
|
'Limit maximum amount' => 6500000, |
96
|
|
|
'Limit /person amount' => 1000000, |
97
|
|
|
'Limit zero deduction' => 30000000, |
98
|
|
|
'Reduced deduction' => 10000000, |
99
|
|
|
]); |
100
|
|
|
} elseif (($yrDate >= 2002) && ($yr <= 2004)) { |
101
|
|
|
$valuesYearly = [ |
102
|
|
|
2002 => 1600000, |
103
|
|
|
2003 => 1800000, |
104
|
|
|
2004 => 2000000, |
105
|
|
|
]; |
106
|
|
|
$nReturn = $valuesYearly[$yrDate]; |
107
|
|
|
} elseif ($yr == 2001) { |
108
|
|
|
$nReturn = $this->setPersonalDeductionSimple2001($lngDate); |
109
|
|
|
} |
110
|
|
View Code Duplication |
if ($lngDate >= mktime(0, 0, 0, 7, 1, 2006)) { |
|
|
|
|
111
|
|
|
$nReturn = round($nReturn, -4); |
112
|
|
|
} |
113
|
|
|
return $nReturn; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
private function setPersonalDeductionComplex($sPersons, $lngBrutto, $inRule) |
117
|
|
|
{ |
118
|
|
|
$nDeduction = $inRule['Limit maximum amount']; |
119
|
|
|
if ($sPersons <= $inRule['Limit persons']) { |
120
|
|
|
$nDeduction = $inRule['Limit basic amount'] + ($sPersons * $inRule['Limit /person amount']); |
121
|
|
|
} |
122
|
|
|
$nReturn = $nDeduction; |
123
|
|
|
if ($lngBrutto >= $inRule['Limit zero deduction']) { |
124
|
|
|
$nReturn = 0; |
125
|
|
|
} elseif ($lngBrutto > $inRule['Reduced deduction']) { |
126
|
|
|
$nReturn = $nDeduction * (1 - ($lngBrutto - $inRule['Reduced deduction']) / $inRule['Reduced deduction']); |
127
|
|
|
} |
128
|
|
|
return $nReturn; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
private function setPersonalDeductionSimple2001($lngDate) |
132
|
|
|
{ |
133
|
|
|
$nReturn = 1300000; |
134
|
|
|
$mnDate = date('n', $lngDate); |
135
|
|
|
if ($mnDate <= 6) { |
136
|
|
|
$nReturn = 1099000; |
137
|
|
|
} elseif ($mnDate <= 9) { |
138
|
|
|
$nReturn = 1273000; |
139
|
|
|
} |
140
|
|
|
return $nReturn; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.