0
0
Fork 0
mirror of https://github.com/kevinpapst/kimai2.git synced 2025-05-13 05:01:53 +00:00

respect last working day

This commit is contained in:
Kevin Papst 2024-10-11 16:15:14 +02:00
parent b0406708e7
commit 6ff615689b
5 changed files with 29 additions and 6 deletions

View file

@ -1276,7 +1276,17 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
public function getWorkStartingDay(): ?\DateTimeInterface
{
$date = $this->getPreferenceValue(UserPreference::WORK_STARTING_DAY);
return $this->getPreferenceDate('work_start_day');
}
public function setWorkStartingDay(?\DateTimeInterface $date): void
{
$this->setPreferenceValue('work_start_day', $date?->format('Y-m-d'));
}
private function getPreferenceDate(string $prefName): ?\DateTimeInterface
{
$date = $this->getPreferenceValue($prefName);
if ($date === null) {
return null;
@ -1290,9 +1300,14 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas
return ($date instanceof \DateTimeInterface) ? $date : null;
}
public function setWorkStartingDay(?\DateTimeInterface $date): void
public function getLastWorkingDay(): ?\DateTimeInterface
{
$this->setPreferenceValue(UserPreference::WORK_STARTING_DAY, $date?->format('Y-m-d'));
return $this->getPreferenceDate('work_last_day');
}
public function setLastWorkingDay(?\DateTimeInterface $date): void
{
$this->setPreferenceValue('work_last_day', $date?->format('Y-m-d'));
}
public function getPublicHolidayGroup(): null|string

View file

@ -47,7 +47,6 @@ class UserPreference
public const WORK_HOURS_SATURDAY = WorkingTimeCalculatorDay::WORK_HOURS_SATURDAY;
/** @deprecated since 2.22*/
public const WORK_HOURS_SUNDAY = WorkingTimeCalculatorDay::WORK_HOURS_SUNDAY;
public const WORK_STARTING_DAY = 'work_start_day';
public const PUBLIC_HOLIDAY_GROUP = 'public_holiday_group';
public const HOLIDAYS_PER_YEAR = 'holidays';
public const WORK_CONTRACT_TYPE = 'work_contract_type';

View file

@ -102,6 +102,7 @@ final class WorkingTimeService
$stats = null;
$firstDay = $user->getWorkStartingDay();
$lastDay = $user->getLastWorkingDay();
$calculator = $this->getContractMode($user)->getCalculator($user);
foreach ($year->getMonths() as $month) {
@ -119,7 +120,7 @@ final class WorkingTimeService
$dayDate = $day->getDay();
$result = new WorkingTime($user, $dayDate);
if ($firstDay === null || $firstDay <= $dayDate) {
if (($firstDay === null || $firstDay <= $dayDate) && ($lastDay === null || $lastDay >= $dayDate)) {
$result->setExpectedTime($calculator->getWorkHoursForDay($dayDate));
}

View file

@ -154,6 +154,10 @@
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>Bitte senden Sie das Formular erneut ab. Sollte das Problem weiterhin bestehen, laden Sie die bitte die Seite neu.</target>
</trans-unit>
<trans-unit id="G2wt0aW" resname="An absence cannot be booked after the last working day.">
<source>An absence cannot be booked after the last working day.</source>
<target>Eine Abwesenheit kann nicht nach dem letzten Arbeitstag gebucht werden.</target>
</trans-unit>
</body>
</file>
</xliff>

View file

@ -124,7 +124,7 @@
</trans-unit>
<trans-unit id="SZO4xjC" resname="An absence cannot be booked before your first working day.">
<source>An absence cannot be booked before your first working day.</source>
<target>An absence cannot be booked before your first working day.</target>
<target>An absence cannot be booked before the first working day.</target>
</trans-unit>
<trans-unit id="IN37g5N" resname="Not enough holidays left.">
<source>Not enough holidays left.</source>
@ -154,6 +154,10 @@
<source>The CSRF token is invalid. Please try to resubmit the form.</source>
<target>Please try to resubmit the form. If the problem persists, refresh your browser.</target>
</trans-unit>
<trans-unit id="G2wt0aW" resname="An absence cannot be booked after the last working day.">
<source>An absence cannot be booked after the last working day.</source>
<target>An absence cannot be booked after the last working day.</target>
</trans-unit>
</body>
</file>
</xliff>