Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b185accdbb | ||
| a4bda53f57 |
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.1.79'
|
app.version: '0.1.80'
|
||||||
|
|||||||
@@ -294,17 +294,28 @@ final readonly class EmployeeRttSummaryProvider implements ProviderInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Week spans two months — split proportionally by daily worked minutes
|
// Week spans two months — split proportionally by daily worked minutes
|
||||||
$monthMinutes = [];
|
$monthMinutes = [];
|
||||||
|
$monthWeekdays = [];
|
||||||
foreach ($detail->dailyMinutes as $date => $mins) {
|
foreach ($detail->dailyMinutes as $date => $mins) {
|
||||||
$m = (int) new DateTimeImmutable($date)->format('n');
|
$m = (int) new DateTimeImmutable($date)->format('n');
|
||||||
$monthMinutes[$m] = ($monthMinutes[$m] ?? 0) + $mins;
|
$monthMinutes[$m] = ($monthMinutes[$m] ?? 0) + $mins;
|
||||||
|
$isoDay = (int) new DateTimeImmutable($date)->format('N');
|
||||||
|
if ($isoDay < 6) {
|
||||||
|
$monthWeekdays[$m] = ($monthWeekdays[$m] ?? 0) + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$totalWorked = array_sum($monthMinutes);
|
$totalWorked = array_sum($monthMinutes);
|
||||||
|
$totalWeekdays = array_sum($monthWeekdays);
|
||||||
|
|
||||||
foreach ([$startMonth, $endMonth] as $month) {
|
foreach ([$startMonth, $endMonth] as $month) {
|
||||||
$portion = $monthMinutes[$month] ?? 0;
|
if ($totalWorked > 0) {
|
||||||
$ratio = $totalWorked > 0 ? $portion / $totalWorked : 0.0;
|
$ratio = ($monthMinutes[$month] ?? 0) / $totalWorked;
|
||||||
|
} elseif ($totalWeekdays > 0) {
|
||||||
|
$ratio = ($monthWeekdays[$month] ?? 0) / $totalWeekdays;
|
||||||
|
} else {
|
||||||
|
$ratio = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
$result[] = new EmployeeRttWeekSummary(
|
$result[] = new EmployeeRttWeekSummary(
|
||||||
month: $month,
|
month: $month,
|
||||||
|
|||||||
Reference in New Issue
Block a user