mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-14 16:53:17 +01:00
add billable rate restriction for free organizations
This commit is contained in:
@@ -119,7 +119,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
||||
$timeEntry->task_id = $taskId;
|
||||
$timeEntry->project_id = $projectId;
|
||||
$timeEntry->client_id = $clientId;
|
||||
$timeEntry->organization_id = $this->organization->id;
|
||||
$timeEntry->organization()->associate($this->organization);
|
||||
if (strlen($record['Description']) > 5000) {
|
||||
throw new ImportException('Time entry description is too long');
|
||||
}
|
||||
|
||||
@@ -126,6 +126,8 @@ abstract class DefaultImporter implements ImporterContract
|
||||
if ($project->billable_rate === 0) {
|
||||
$project->billable_rate = null;
|
||||
}
|
||||
// Note: Prevents a query per project for the billable rate restriction (see Project::booted)
|
||||
$project->setRelation('organization', $this->organization);
|
||||
});
|
||||
$this->projectMemberImportHelper = new ImportDatabaseHelper(ProjectMember::class, ['project_id', 'member_id'], true, function (Builder $builder): Builder {
|
||||
/** @var Builder<ProjectMember> $builder */
|
||||
@@ -140,6 +142,11 @@ abstract class DefaultImporter implements ImporterContract
|
||||
if ($projectMember->billable_rate === 0) {
|
||||
$projectMember->billable_rate = null;
|
||||
}
|
||||
// Note: Prevents queries per project member for the billable rate restriction (see ProjectMember::booted)
|
||||
$project = $this->projectImportHelper->getModelById($projectMember->project_id);
|
||||
if ($project !== null) {
|
||||
$projectMember->setRelation('project', $project->setRelation('organization', $this->organization));
|
||||
}
|
||||
});
|
||||
$this->tagImportHelper = new ImportDatabaseHelper(Tag::class, ['name', 'organization_id'], true, function (Builder $builder): Builder {
|
||||
/** @var Builder<Tag> $builder */
|
||||
|
||||
@@ -129,7 +129,7 @@ class GenericTimeEntriesImporter extends DefaultImporter
|
||||
$timeEntry->task_id = $taskId;
|
||||
$timeEntry->project_id = $projectId;
|
||||
$timeEntry->client_id = $clientId;
|
||||
$timeEntry->organization_id = $this->organization->id;
|
||||
$timeEntry->organization()->associate($this->organization);
|
||||
$timeEntry->description = $record['description'];
|
||||
if (! in_array($record['billable'], ['true', 'false'], true)) {
|
||||
throw new ImportException('Invalid billable value');
|
||||
|
||||
@@ -107,7 +107,7 @@ class HarvestTimeEntriesImporter extends DefaultImporter
|
||||
$timeEntry->task_id = $taskId;
|
||||
$timeEntry->project_id = $projectId;
|
||||
$timeEntry->client_id = $clientId;
|
||||
$timeEntry->organization_id = $this->organization->id;
|
||||
$timeEntry->organization()->associate($this->organization);
|
||||
if (strlen($record['Notes']) > 5000) {
|
||||
throw new ImportException('Time entry note is too long');
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ class SolidtimeImporter extends DefaultImporter
|
||||
$timeEntry->task_id = $taskId;
|
||||
$timeEntry->project_id = $projectId;
|
||||
$timeEntry->client_id = $clientId;
|
||||
$timeEntry->organization_id = $this->organization->id;
|
||||
$timeEntry->organization()->associate($this->organization);
|
||||
if (strlen($timeEntryRow['description']) > 5000) {
|
||||
throw new ImportException('Time entry description is too long');
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class TogglTimeEntriesImporter extends DefaultImporter
|
||||
$timeEntry->task_id = $taskId;
|
||||
$timeEntry->project_id = $projectId;
|
||||
$timeEntry->client_id = $clientId;
|
||||
$timeEntry->organization_id = $this->organization->id;
|
||||
$timeEntry->organization()->associate($this->organization);
|
||||
$timeEntry->description = $record['Description'];
|
||||
if (! in_array($record['Billable'], ['Yes', 'No'], true)) {
|
||||
throw new ImportException('Invalid billable value');
|
||||
|
||||
Reference in New Issue
Block a user