Release 1.19.7 (#3286)

* fix isWeekend() test for sunday fdow
* re-use the pattern for optgroup title
* prevent method on null
* composer update
* pre-select an option if it is the only available one
* added command to stop all active timesheets
This commit is contained in:
Kevin Papst
2022-05-07 23:47:32 +02:00
committed by GitHub
parent 100f8a5165
commit c8098b2e00
31 changed files with 818 additions and 484 deletions

View File

@@ -223,10 +223,11 @@ final class TimesheetService
* But also to check that all required data is set.
*
* @param Timesheet $timesheet
* @param bool $validate
* @throws ValidationException for already stopped timesheets
* @throws ValidationFailedException
*/
public function stopTimesheet(Timesheet $timesheet): void
public function stopTimesheet(Timesheet $timesheet, bool $validate = true): void
{
if (null !== $timesheet->getEnd()) {
// timesheet already stopped, nothing to do. in previous version, this method did throw a:
@@ -242,7 +243,9 @@ final class TimesheetService
$timesheet->setBegin($begin);
$timesheet->setEnd($now);
$this->validateTimesheet($timesheet);
if ($validate) {
$this->validateTimesheet($timesheet);
}
$this->dispatcher->dispatch(new TimesheetStopPreEvent($timesheet));
$this->repository->save($timesheet);
@@ -328,4 +331,17 @@ final class TimesheetService
{
return $this->trackingModeService->getActiveMode();
}
public function stopAll(): int
{
$activeEntries = $this->repository->getActiveEntries();
$counter = 0;
foreach ($activeEntries as $timesheet) {
$this->stopTimesheet($timesheet, false);
$counter++;
}
return $counter;
}
}