Version 2.0.1 (#3853)

* configure email validation mode to fix deprecation message
* allow to use non brand icon in saml provider
* new method getCalculatedDuration()
* getRawData() by id
* only stop entries if new one is running
* fix validator tampering with timesheet duration
* fix allow setting null as customer
* bump packages
This commit is contained in:
Kevin Papst
2023-02-18 14:19:16 +01:00
committed by GitHub
parent 75aea7c51b
commit e474087257
20 changed files with 253 additions and 363 deletions

View File

@@ -73,10 +73,24 @@ final class TimesheetBudgetUsedValidator extends ConstraintValidator
return;
}
$id = $timesheet->getId();
// when changing the date via the calendar and/or the API, the duration will not be reset by the
// duration calculator (which runs after validation!) so we manually reset the duration before
$timesheet->setDuration(null);
$duration = $timesheet->getDuration();
// ------------------------------------------------------------------------
// Old solution (buggy) - duration MAY NOT BE RESET!
// this will cause the timesheet to be deleted in the Weekly-QuickEntry-Flow
// ------------------------------------------------------------------------
// $timesheet->setDuration(null);
// $duration = $timesheet->getDuration();
// another possible solution is cloning the timesheet
// $timesheet = clone $timesheet;
// $timesheet->setDuration(null);
// $duration = $timesheet->getDuration();
$duration = $timesheet->getCalculatedDuration();
$timeRate = $this->rateService->calculate($timesheet);
$rate = $timeRate->getRate();
@@ -89,8 +103,8 @@ final class TimesheetBudgetUsedValidator extends ConstraintValidator
$customerRate = $rate;
$monthWasChanged = false;
if ($timesheet->getId() !== null) {
$rawData = $this->timesheetRepository->getRawData($timesheet);
if ($id !== null) {
$rawData = $this->timesheetRepository->getRawData($id);
$activityId = (int) $rawData['activity'];
$projectId = (int) $rawData['project'];

View File

@@ -39,9 +39,12 @@ final class TimesheetLongRunningValidator extends ConstraintValidator
return;
}
/** @var int $duration */
$duration = $timesheet->getCalculatedDuration();
// one year is currently the maximum that can be logged (which is already not logically)
// the database column could hold more data, but let's limit it here
if ($timesheet->getDuration() > 31536000) {
if ($duration > 31536000) {
$this->context->buildViolation($constraint->maximumMessage)
->setTranslationDomain('validators')
->atPath('duration')
@@ -57,7 +60,6 @@ final class TimesheetLongRunningValidator extends ConstraintValidator
return;
}
$duration = $timesheet->getEnd()->getTimestamp() - $timesheet->getBegin()->getTimestamp();
// float on purpose, because one second more than the configured minutes is already too long
$minutes = $duration / 60;

View File

@@ -45,7 +45,7 @@ final class TimesheetZeroDurationValidator extends ConstraintValidator
$duration = 0;
if ($timesheet->getEnd() !== null && $timesheet->getBegin() !== null) {
$duration = $timesheet->getEnd()->getTimestamp() - $timesheet->getBegin()->getTimestamp();
$duration = $timesheet->getCalculatedDuration();
}
if ($duration <= 0) {