Skip to content

Commit

Permalink
Fix holidays calculations
Browse files Browse the repository at this point in the history
- Change how we get used/scheduled hours if reference date is in the future
- Update calculation in summary report action to subtract used hours
- Rename variable to match the ui for clarity
  • Loading branch information
dmtrek14 committed Dec 12, 2023
1 parent e20e786 commit 1e9ca97
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions model/facade/action/GetHolidayHoursBaseAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ protected function getHoursSummary(DateTime $referenceDate = NULL): array
//if the reference data is in the future, then usedHours has to be 0 - we are not time travelers
if($referenceDate > new DateTime()){
$userUsedHours[$userVO->getLogin()] = 0;
$userScheduledHours[$userVO->getLogin()] = $vacations;
}
else {
//need to do this because we need to get hours for interval
$userUsedHours[$userVO->getLogin()] = $taskDao->getVacations($userVO, $reportInit, $referenceDate)["add_hours"] ?? 0;
$userScheduledHours[$userVO->getLogin()] = $vacations - $userUsedHours[$userVO->getLogin()];
}

$userScheduledHours[$userVO->getLogin()] = $vacations - $userUsedHours[$userVO->getLogin()];

// The difference is the number of pending holiday hours
$userPendingHolidayHours[$userVO->getLogin()] = $holidayHours - $vacations;
}
Expand Down
2 changes: 1 addition & 1 deletion model/facade/action/GetHolidaySummaryReportAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function doExecute()
'availableHours' => round($summary['availableHours'][$this->user->getLogin()], 2),
'usedHours' => round($usedHours, 2),
'pendingHours' => round($summary['pendingHours'][$this->user->getLogin()], 2),
'plannedHours' => round($summary['usedHours'][$this->user->getLogin()], 2),
'scheduledHours' => round($summary['scheduledHours'][$this->user->getLogin()] - $usedHours, 2),
'percentage' => $summary['availableHours'][$this->user->getLogin()] ? round(($summary['usedHours'][$this->user->getLogin()] / $summary['availableHours'][$this->user->getLogin()]) * 100, 2) : 0,
'hoursDay' => $validJourney,
'holidays' => $leaves,
Expand Down
2 changes: 1 addition & 1 deletion web/holidaySummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<td>{{ row.hoursDay }}</td>
<td>{{ row.availableHours }}</td>
<td>{{ row.usedHours }}</td>
<td>{{ row.plannedHours }}</td>
<td>{{ row.scheduledHours }}</td>
<td>{{ row.pendingHours }}</td>
<td :class="{ 'alert': row.percentage < 50}">{{row.percentage}}</td>
<td v-for="(userWeek, index) in row.holidays" :key="row.user + '-' + index" :class="{ 'highlight': userWeek > 0}">{{userWeek}}</td>
Expand Down
2 changes: 1 addition & 1 deletion web/services/getHolidaySummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
$line["hoursDay"],
$line["availableHours"],
$line["usedHours"],
$line["plannedHours"],
$line["scheduledHours"],
$line["pendingHours"],
$line["percentage"]
),
Expand Down

0 comments on commit 1e9ca97

Please sign in to comment.