Release 1.30.8 (#3854)
* fix weekly timesheets can delete wrong records * pin phpunit to prevent deprecations
This commit is contained in:
@@ -1579,7 +1579,7 @@ final class KimaiImporterCommand extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($oldRecord['end']) || $oldRecord['end'] === 0) {
|
||||
if (empty($oldRecord['end'])) {
|
||||
$io->error('Cannot import running timesheet record, skipping: ' . $oldRecord['timeEntryID']);
|
||||
$failed++;
|
||||
continue;
|
||||
|
||||
@@ -17,11 +17,11 @@ class Constants
|
||||
/**
|
||||
* The current release version
|
||||
*/
|
||||
public const VERSION = '1.30.7';
|
||||
public const VERSION = '1.30.8';
|
||||
/**
|
||||
* The current release: major * 10000 + minor * 100 + patch
|
||||
*/
|
||||
public const VERSION_ID = 13007;
|
||||
public const VERSION_ID = 13008;
|
||||
/**
|
||||
* The current release status, either "stable" or "dev"
|
||||
*/
|
||||
|
||||
@@ -95,14 +95,12 @@ class TeamFixtures extends Fixture
|
||||
$team->setName($faker->company . ' ' . $i);
|
||||
$team->addTeamlead($allUsers[array_rand($allUsers)]);
|
||||
|
||||
if ($userCount > 0) {
|
||||
$userKeys = array_rand($allUsers, $userCount);
|
||||
if (!\is_array($userKeys)) {
|
||||
$userKeys = [$userKeys];
|
||||
}
|
||||
foreach ($userKeys as $userKey) {
|
||||
$team->addUser($allUsers[$userKey]);
|
||||
}
|
||||
$userKeys = array_rand($allUsers, $userCount);
|
||||
if (!\is_array($userKeys)) {
|
||||
$userKeys = [$userKeys];
|
||||
}
|
||||
foreach ($userKeys as $userKey) {
|
||||
$team->addUser($allUsers[$userKey]);
|
||||
}
|
||||
|
||||
if ($projectCount > 0) {
|
||||
|
||||
@@ -437,12 +437,21 @@ class Timesheet implements EntityWithMetaFields, ExportItemInterface
|
||||
{
|
||||
// only auto calculate if manually set duration is null - the result is important for eg. validations
|
||||
if ($calculate && $this->duration === null && $this->begin !== null && $this->end !== null) {
|
||||
return $this->end->getTimestamp() - $this->begin->getTimestamp();
|
||||
return $this->getCalculatedDuration();
|
||||
}
|
||||
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
public function getCalculatedDuration(): ?int
|
||||
{
|
||||
if ($this->begin !== null && $this->end !== null) {
|
||||
return $this->end->getTimestamp() - $this->begin->getTimestamp();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return Timesheet
|
||||
|
||||
@@ -81,8 +81,20 @@ final class TimesheetBudgetUsedValidator extends ConstraintValidator
|
||||
|
||||
// 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();
|
||||
|
||||
Reference in New Issue
Block a user