Skip running time entries in solidtime import

Imported running time entries could give a user a second running time
entry, for example when an export is imported again while a timer runs.
This commit is contained in:
Constantin Graf
2026-10-13 18:04:11 +02:00
parent 332edcb047
commit 0bfeab156c
12 changed files with 63 additions and 12 deletions

View File

@@ -211,6 +211,10 @@ class SolidtimeImporter extends DefaultImporter
// Time entries
foreach ($timeEntriesReader as $timeEntryRow) {
// Running time entries are skipped, since the user could already have a running time entry
if ($timeEntryRow['end'] === '') {
continue;
}
$userId = $this->userImportHelper->getKeyByExternalIdentifier($timeEntryRow['user_id']);
$memberId = $this->memberImportHelper->getKeyByExternalIdentifier($timeEntryRow['member_id']);
$member = $this->memberImportHelper->getModelById($memberId);
@@ -271,19 +275,15 @@ class SolidtimeImporter extends DefaultImporter
}
$timeEntry->start = $start->utc();
if ($timeEntryRow['end'] !== '') {
try {
$end = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $timeEntryRow['end'], 'UTC');
} catch (InvalidFormatException) {
throw new ImportException('End date ("'.$timeEntryRow['end'].'") is invalid');
}
if ($end === null) {
throw new ImportException('End date ("'.$timeEntryRow['end'].'") is invalid');
}
$timeEntry->end = $end->utc();
} else {
$timeEntry->end = null;
try {
$end = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $timeEntryRow['end'], 'UTC');
} catch (InvalidFormatException) {
throw new ImportException('End date ("'.$timeEntryRow['end'].'") is invalid');
}
if ($end === null) {
throw new ImportException('End date ("'.$timeEntryRow['end'].'") is invalid');
}
$timeEntry->end = $end->utc();
if ($timeEntryRow['still_active_email_sent_at'] !== '') {
try {