fixed restart timesheet with tags with active record (#1622)

This commit is contained in:
Kevin Papst
2020-04-07 17:30:39 +02:00
committed by GitHub
parent 9e1e1a7a96
commit 5e7b0c7826
5 changed files with 39 additions and 20 deletions

View File

@@ -57,7 +57,7 @@ final class TimesheetService
}
/**
* Calls prepareNewTimesheet() automatically.
* Calls prepareNewTimesheet() automatically if $request is not null.
*
* @param User $user
* @param Request|null $request
@@ -96,21 +96,20 @@ final class TimesheetService
throw new \InvalidArgumentException('Cannot create timesheet, already persisted');
}
if (null === $timesheet->getEnd()) {
if (!$this->auth->isGranted('start', $timesheet)) {
throw new AccessDeniedHttpException('You are not allowed to start this timesheet record');
}
$this->repository->stopActiveEntries(
$timesheet->getUser(),
$this->configuration->getActiveEntriesHardLimit()
);
if (null === $timesheet->getEnd() && !$this->auth->isGranted('start', $timesheet)) {
throw new AccessDeniedHttpException('You are not allowed to start this timesheet record');
}
$this->repository->save($timesheet);
$this->repository->add($timesheet, $this->configuration->getActiveEntriesHardLimit());
return $timesheet;
}
public function updateTimesheet(Timesheet $timesheet)
{
return $this->repository->save($timesheet);
}
public function stopTimesheet(Timesheet $timesheet)
{
return $this->repository->stopRecording($timesheet);