mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 08:12:17 +01:00
Compare commits
3 Commits
feature/cl
...
7e993a9249
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e993a9249 | ||
|
|
3b43ccf661 | ||
|
|
37a8f43b23 |
@@ -59,7 +59,7 @@ class ReportController extends Controller
|
||||
$filter->addBillable($properties->billable);
|
||||
$filter->addMemberIdsFilter($properties->memberIds?->toArray());
|
||||
$filter->addProjectIdsFilter($properties->projectIds?->toArray());
|
||||
$filter->addTagIdsFilter($properties->tagIds?->toArray());
|
||||
$filter->addTagIdsFilter($properties->tagIds?->toArray(), $properties->tagFilter);
|
||||
$filter->addTaskIdsFilter($properties->taskIds?->toArray());
|
||||
$filter->addClientIdsFilter($properties->clientIds?->toArray());
|
||||
$timeEntriesQuery = $filter->get();
|
||||
|
||||
@@ -96,6 +96,7 @@ class ReportController extends Controller
|
||||
$properties->setClientIds($request->input('properties.client_ids', null));
|
||||
$properties->setProjectIds($request->input('properties.project_ids', null));
|
||||
$properties->setTagIds($request->input('properties.tag_ids', null));
|
||||
$properties->setTagFilter($request->input('properties.tag_filter', null));
|
||||
$properties->setTaskIds($request->input('properties.task_ids', null));
|
||||
$properties->weekStart = $request->has('properties.week_start') ? Weekday::from($request->input('properties.week_start')) : $user->week_start;
|
||||
$timezone = $user->timezone;
|
||||
|
||||
@@ -203,7 +203,7 @@ class TimeEntryController extends Controller
|
||||
$filter->addMemberIdFilter($member);
|
||||
$filter->addMemberIdsFilter($request->input('member_ids'));
|
||||
$filter->addProjectIdsFilter($request->input('project_ids'));
|
||||
$filter->addTagIdsFilter($request->input('tag_ids'));
|
||||
$filter->addTagIdsFilter($request->input('tag_ids'), $request->input('tag_filter'));
|
||||
$filter->addTaskIdsFilter($request->input('task_ids'));
|
||||
$filter->addClientIdsFilter($request->input('client_ids'));
|
||||
$filter->addBillableFilter($request->input('billable'));
|
||||
@@ -559,7 +559,7 @@ class TimeEntryController extends Controller
|
||||
$filter->addMemberIdFilter($member);
|
||||
$filter->addMemberIdsFilter($request->input('member_ids'));
|
||||
$filter->addProjectIdsFilter($request->input('project_ids'));
|
||||
$filter->addTagIdsFilter($request->input('tag_ids'));
|
||||
$filter->addTagIdsFilter($request->input('tag_ids'), $request->input('tag_filter'));
|
||||
$filter->addTaskIdsFilter($request->input('task_ids'));
|
||||
$filter->addClientIdsFilter($request->input('client_ids'));
|
||||
$filter->addBillableFilter($request->input('billable'));
|
||||
|
||||
@@ -124,6 +124,11 @@ class ReportStoreRequest extends BaseFormRequest
|
||||
}
|
||||
},
|
||||
],
|
||||
'properties.tag_filter' => [
|
||||
'nullable',
|
||||
'string',
|
||||
'in:'.TimeEntryFilter::TAG_FILTER_CONTAINS.','.TimeEntryFilter::TAG_FILTER_NOT_CONTAINS,
|
||||
],
|
||||
'properties.task_ids' => [
|
||||
'nullable',
|
||||
'array',
|
||||
|
||||
@@ -139,6 +139,10 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
'tag_filter' => [
|
||||
'string',
|
||||
'in:'.TimeEntryFilter::TAG_FILTER_CONTAINS.','.TimeEntryFilter::TAG_FILTER_NOT_CONTAINS,
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
'array',
|
||||
|
||||
@@ -125,6 +125,10 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
'tag_filter' => [
|
||||
'string',
|
||||
'in:'.TimeEntryFilter::TAG_FILTER_CONTAINS.','.TimeEntryFilter::TAG_FILTER_NOT_CONTAINS,
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
'array',
|
||||
|
||||
@@ -110,6 +110,10 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
'tag_filter' => [
|
||||
'string',
|
||||
'in:'.TimeEntryFilter::TAG_FILTER_CONTAINS.','.TimeEntryFilter::TAG_FILTER_NOT_CONTAINS,
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
'array',
|
||||
|
||||
@@ -103,6 +103,10 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
||||
})->uuid()->validate($attribute, $value, $fail);
|
||||
},
|
||||
],
|
||||
'tag_filter' => [
|
||||
'string',
|
||||
'in:'.TimeEntryFilter::TAG_FILTER_CONTAINS.','.TimeEntryFilter::TAG_FILTER_NOT_CONTAINS,
|
||||
],
|
||||
// Filter by task IDs, task IDs are OR combined
|
||||
'task_ids' => [
|
||||
'array',
|
||||
|
||||
@@ -56,6 +56,8 @@ class DetailedReportResource extends BaseResource
|
||||
'project_ids' => $this->resource->properties->projectIds?->toArray(),
|
||||
/** @var array<string>|null $tags_ids Filter by tag IDs, tag IDs are OR combined */
|
||||
'tag_ids' => $this->resource->properties->tagIds?->toArray(),
|
||||
/** @var string|null $tag_filter Tag filter mode */
|
||||
'tag_filter' => $this->resource->properties->tagFilter,
|
||||
/** @var array<string>|null $task_ids Filter by task IDs, task IDs are OR combined */
|
||||
'task_ids' => $this->resource->properties->taskIds?->toArray(),
|
||||
/** @var string|null $rounding_type Rounding type for time entries */
|
||||
|
||||
@@ -56,6 +56,8 @@ class ReportPropertiesDto implements Castable
|
||||
*/
|
||||
public ?Collection $tagIds = null;
|
||||
|
||||
public ?string $tagFilter = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, string>|null
|
||||
*/
|
||||
@@ -115,6 +117,7 @@ class ReportPropertiesDto implements Castable
|
||||
$dto->clientIds = $data->clientIds !== null ? ReportPropertiesDto::idArrayToCollection($data->clientIds) : null;
|
||||
$dto->projectIds = $data->projectIds !== null ? ReportPropertiesDto::idArrayToCollection($data->projectIds) : null;
|
||||
$dto->tagIds = $data->tagIds !== null ? ReportPropertiesDto::idArrayToCollection($data->tagIds) : null;
|
||||
$dto->tagFilter = isset($data->tagFilter) ? ReportPropertiesDto::tagFilterValue($data->tagFilter) : null;
|
||||
$dto->taskIds = $data->taskIds ? ReportPropertiesDto::idArrayToCollection($data->taskIds) : null;
|
||||
$dto->group = TimeEntryAggregationType::from($data->group);
|
||||
$dto->subGroup = TimeEntryAggregationType::from($data->subGroup);
|
||||
@@ -144,6 +147,7 @@ class ReportPropertiesDto implements Castable
|
||||
'clientIds' => $value->clientIds?->toArray(),
|
||||
'projectIds' => $value->projectIds?->toArray(),
|
||||
'tagIds' => $value->tagIds?->toArray(),
|
||||
'tagFilter' => $value->tagFilter,
|
||||
'taskIds' => $value->taskIds?->toArray(),
|
||||
'group' => $value->group->value,
|
||||
'subGroup' => $value->subGroup->value,
|
||||
@@ -184,6 +188,24 @@ class ReportPropertiesDto implements Castable
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 'contains'|'not_contains'|null
|
||||
*/
|
||||
public static function tagFilterValue(mixed $tagFilter): ?string
|
||||
{
|
||||
if ($tagFilter === null) {
|
||||
return null;
|
||||
}
|
||||
if (! is_string($tagFilter)) {
|
||||
throw new \InvalidArgumentException('The given tag filter is not a string');
|
||||
}
|
||||
if (! in_array($tagFilter, [TimeEntryFilter::TAG_FILTER_CONTAINS, TimeEntryFilter::TAG_FILTER_NOT_CONTAINS], true)) {
|
||||
throw new \InvalidArgumentException('The given tag filter is not valid');
|
||||
}
|
||||
|
||||
return $tagFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed>|null $memberIds
|
||||
*/
|
||||
@@ -216,6 +238,11 @@ class ReportPropertiesDto implements Castable
|
||||
$this->tagIds = $tagIds !== null ? ReportPropertiesDto::idArrayToCollection($tagIds) : null;
|
||||
}
|
||||
|
||||
public function setTagFilter(mixed $tagFilter): void
|
||||
{
|
||||
$this->tagFilter = ReportPropertiesDto::tagFilterValue($tagFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed>|null $taskIds
|
||||
*/
|
||||
|
||||
@@ -116,10 +116,12 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
||||
throw new ImportException('Time entry description is too long');
|
||||
}
|
||||
$timeEntry->description = $record['Description'];
|
||||
if (! in_array($record['Billable'], ['Yes', 'No'], true)) {
|
||||
throw new ImportException('Invalid billable value');
|
||||
if (isset($record['Billable'])) {
|
||||
if (! in_array($record['Billable'], ['Yes', 'No'], true)) {
|
||||
throw new ImportException('Invalid billable value');
|
||||
}
|
||||
$timeEntry->billable = $record['Billable'] === 'Yes';
|
||||
}
|
||||
$timeEntry->billable = $record['Billable'] === 'Yes';
|
||||
$timeEntry->tags = $this->getTags($record['Tags']);
|
||||
$timeEntry->is_imported = true;
|
||||
|
||||
@@ -219,7 +221,6 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
||||
'Group',
|
||||
'Email',
|
||||
'Tags',
|
||||
'Billable',
|
||||
'Start Date',
|
||||
'Start Time',
|
||||
'End Date',
|
||||
|
||||
@@ -14,6 +14,10 @@ class TimeEntryFilter
|
||||
{
|
||||
public const string NONE_VALUE = 'none';
|
||||
|
||||
public const string TAG_FILTER_CONTAINS = 'contains';
|
||||
|
||||
public const string TAG_FILTER_NOT_CONTAINS = 'not_contains';
|
||||
|
||||
/**
|
||||
* @var Builder<TimeEntry>
|
||||
*/
|
||||
@@ -192,15 +196,27 @@ class TimeEntryFilter
|
||||
/**
|
||||
* @param array<string>|null $tagIds
|
||||
*/
|
||||
public function addTagIdsFilter(?array $tagIds): self
|
||||
public function addTagIdsFilter(?array $tagIds, ?string $tagFilter = self::TAG_FILTER_CONTAINS): self
|
||||
{
|
||||
if ($tagIds === null) {
|
||||
return $this;
|
||||
}
|
||||
if ($tagFilter === null) {
|
||||
$tagFilter = self::TAG_FILTER_CONTAINS;
|
||||
}
|
||||
if (! in_array($tagFilter, [self::TAG_FILTER_CONTAINS, self::TAG_FILTER_NOT_CONTAINS], true)) {
|
||||
Log::warning('Invalid tag filter value', ['value' => $tagFilter]);
|
||||
$tagFilter = self::TAG_FILTER_CONTAINS;
|
||||
}
|
||||
$includeNone = in_array(self::NONE_VALUE, $tagIds, true);
|
||||
$tagIds = array_values(array_filter($tagIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
// An empty selection (no tag IDs and not filtering for "none") is no constraint, so apply nothing.
|
||||
// This also prevents the not-contains branch from collapsing into "only entries with null tags".
|
||||
if (count($tagIds) === 0 && ! $includeNone) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($tagIds, $includeNone): void {
|
||||
$tagCondition = function (Builder $builder) use ($tagIds, $includeNone): void {
|
||||
foreach ($tagIds as $tagId) {
|
||||
$builder->orWhereJsonContains('tags', $tagId);
|
||||
}
|
||||
@@ -209,7 +225,18 @@ class TimeEntryFilter
|
||||
$query->whereJsonLength('tags', 0)->orWhereNull('tags');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if ($tagFilter === self::TAG_FILTER_NOT_CONTAINS) {
|
||||
$this->builder->where(function (Builder $builder) use ($tagCondition, $includeNone): void {
|
||||
$builder->whereNot($tagCondition);
|
||||
if (! $includeNone) {
|
||||
$builder->orWhereNull('tags');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$this->builder->where($tagCondition);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import DateRangePicker from '@/packages/ui/src/Input/DateRangePicker.vue';
|
||||
import TagDropdown from '@/packages/ui/src/Tag/TagDropdown.vue';
|
||||
import { useTagsQuery } from '@/utils/useTagsQuery';
|
||||
import { useTagsStore } from '@/utils/useTags';
|
||||
import type { TagFilter } from '@/types/reporting';
|
||||
|
||||
type TimeEntryRoundingType = 'up' | 'down' | 'nearest';
|
||||
|
||||
@@ -22,6 +23,7 @@ const selectedProjects = defineModel<string[]>('selectedProjects', { required: t
|
||||
const selectedTasks = defineModel<string[]>('selectedTasks', { required: true });
|
||||
const selectedClients = defineModel<string[]>('selectedClients', { required: true });
|
||||
const selectedTags = defineModel<string[]>('selectedTags', { required: true });
|
||||
const tagFilter = defineModel<TagFilter>('tagFilter', { required: true });
|
||||
const billable = defineModel<'true' | 'false' | null>('billable', { required: true });
|
||||
const roundingEnabled = defineModel<boolean>('roundingEnabled', { required: true });
|
||||
const roundingType = defineModel<TimeEntryRoundingType>('roundingType', { required: true });
|
||||
@@ -93,6 +95,44 @@ async function createTag(name: string) {
|
||||
title="Tags"
|
||||
:icon="TagIcon" />
|
||||
</template>
|
||||
<template #content-before-list>
|
||||
<div class="mt-2 border-b border-card-background-separator pb-2">
|
||||
<div
|
||||
class="mb-1.5 px-2 text-xs font-medium text-text-tertiary uppercase">
|
||||
Match
|
||||
</div>
|
||||
<div class="space-y-1">
|
||||
<button
|
||||
type="button"
|
||||
class="w-full rounded-md px-2 py-1.5 text-left text-sm font-medium"
|
||||
:class="
|
||||
tagFilter === 'contains'
|
||||
? 'bg-card-background-active text-text-primary'
|
||||
: 'text-text-secondary hover:bg-card-background-active'
|
||||
"
|
||||
@click="
|
||||
tagFilter = 'contains';
|
||||
emit('submit');
|
||||
">
|
||||
Contains
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="w-full rounded-md px-2 py-1.5 text-left text-sm font-medium"
|
||||
:class="
|
||||
tagFilter === 'not_contains'
|
||||
? 'bg-card-background-active text-text-primary'
|
||||
: 'text-text-secondary hover:bg-card-background-active'
|
||||
"
|
||||
@click="
|
||||
tagFilter = 'not_contains';
|
||||
emit('submit');
|
||||
">
|
||||
Does Not Contain
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</TagDropdown>
|
||||
|
||||
<Select v-model="billable" @update:model-value="emit('submit')">
|
||||
|
||||
@@ -49,6 +49,7 @@ import type { ExportFormat } from '@/types/reporting';
|
||||
import { getRandomColorWithSeed } from '@/packages/ui/src/utils/color';
|
||||
import { useProjectsQuery } from '@/utils/useProjectsQuery';
|
||||
import { useAggregatedTimeEntriesQuery } from '@/utils/useAggregatedTimeEntriesQuery';
|
||||
import type { TagFilter } from '@/types/reporting';
|
||||
|
||||
type TimeEntryRoundingType = 'up' | 'down' | 'nearest';
|
||||
|
||||
@@ -67,6 +68,7 @@ const selectedProjects = ref<string[]>([]);
|
||||
const selectedMembers = ref<string[]>([]);
|
||||
const selectedTasks = ref<string[]>([]);
|
||||
const selectedClients = ref<string[]>([]);
|
||||
const tagFilter = ref<TagFilter>('contains');
|
||||
|
||||
const billable = ref<'true' | 'false' | null>(null);
|
||||
const roundingEnabled = ref<boolean>(false);
|
||||
@@ -122,6 +124,7 @@ const filterParams = computed<AggregatedTimeEntriesQueryParams>(() => {
|
||||
task_ids: selectedTasks.value.length > 0 ? selectedTasks.value : undefined,
|
||||
client_ids: selectedClients.value.length > 0 ? selectedClients.value : undefined,
|
||||
tag_ids: selectedTags.value.length > 0 ? selectedTags.value : undefined,
|
||||
tag_filter: selectedTags.value.length > 0 ? tagFilter.value : undefined,
|
||||
billable: billable.value !== null ? billable.value : undefined,
|
||||
member_id: getCurrentRole() === 'employee' ? getCurrentMembershipId() : undefined,
|
||||
rounding_type: roundingEnabled.value ? roundingType.value : undefined,
|
||||
@@ -366,6 +369,7 @@ const tableData = computed(() => {
|
||||
v-model:selected-tasks="selectedTasks"
|
||||
v-model:selected-clients="selectedClients"
|
||||
v-model:selected-tags="selectedTags"
|
||||
v-model:tag-filter="tagFilter"
|
||||
v-model:billable="billable"
|
||||
v-model:rounding-enabled="roundingEnabled"
|
||||
v-model:rounding-type="roundingType"
|
||||
|
||||
@@ -67,6 +67,7 @@ import ReportingFilterBar from '@/Components/Common/Reporting/ReportingFilterBar
|
||||
import { useTimeEntriesReportQuery } from '@/utils/useTimeEntriesReportQuery';
|
||||
import { useTimeEntriesMutations } from '@/utils/useTimeEntriesMutations';
|
||||
import { useOrganizationQuery } from '@/utils/useOrganizationQuery';
|
||||
import type { TagFilter } from '@/types/reporting';
|
||||
|
||||
// TimeEntryRoundingType is now defined in ReportingRoundingControls component
|
||||
type TimeEntryRoundingType = 'up' | 'down' | 'nearest';
|
||||
@@ -84,6 +85,7 @@ const selectedProjects = ref<string[]>([]);
|
||||
const selectedMembers = ref<string[]>([]);
|
||||
const selectedTasks = ref<string[]>([]);
|
||||
const selectedClients = ref<string[]>([]);
|
||||
const tagFilter = ref<TagFilter>('contains');
|
||||
const billable = ref<'true' | 'false' | null>(null);
|
||||
const roundingEnabled = ref<boolean>(false);
|
||||
const roundingType = ref<TimeEntryRoundingType>('nearest');
|
||||
@@ -115,6 +117,7 @@ function getFilterAttributes() {
|
||||
task_ids: selectedTasks.value.length > 0 ? selectedTasks.value : undefined,
|
||||
client_ids: selectedClients.value.length > 0 ? selectedClients.value : undefined,
|
||||
tag_ids: selectedTags.value.length > 0 ? selectedTags.value : undefined,
|
||||
tag_filter: selectedTags.value.length > 0 ? tagFilter.value : undefined,
|
||||
billable: billable.value !== null ? billable.value : undefined,
|
||||
rounding_type: roundingEnabled.value ? roundingType.value : undefined,
|
||||
rounding_minutes: roundingEnabled.value ? roundingMinutes.value : undefined,
|
||||
@@ -337,6 +340,7 @@ async function downloadExport(format: ExportFormat) {
|
||||
v-model:selected-tasks="selectedTasks"
|
||||
v-model:selected-clients="selectedClients"
|
||||
v-model:selected-tags="selectedTags"
|
||||
v-model:tag-filter="tagFilter"
|
||||
v-model:billable="billable"
|
||||
v-model:rounding-enabled="roundingEnabled"
|
||||
v-model:rounding-type="roundingType"
|
||||
|
||||
@@ -448,6 +448,7 @@ const ReportStoreRequest = z
|
||||
client_ids: z.union([z.array(z.string()), z.null()]).optional(),
|
||||
project_ids: z.union([z.array(z.string()), z.null()]).optional(),
|
||||
tag_ids: z.union([z.array(z.string()), z.null()]).optional(),
|
||||
tag_filter: z.enum(['contains', 'not_contains']).optional(),
|
||||
task_ids: z.union([z.array(z.string()), z.null()]).optional(),
|
||||
group: TimeEntryAggregationType,
|
||||
sub_group: TimeEntryAggregationType,
|
||||
@@ -481,6 +482,7 @@ const DetailedReportResource = z
|
||||
client_ids: z.union([z.array(z.string()), z.null()]),
|
||||
project_ids: z.union([z.array(z.string()), z.null()]),
|
||||
tag_ids: z.union([z.array(z.string()), z.null()]),
|
||||
tag_filter: z.union([z.enum(['contains', 'not_contains']), z.null()]),
|
||||
task_ids: z.union([z.array(z.string()), z.null()]),
|
||||
rounding_type: z.union([z.string(), z.null()]),
|
||||
rounding_minutes: z.union([z.number(), z.null()]),
|
||||
@@ -3784,6 +3786,11 @@ Users with the permission `time-entries:view:own` can only use this en
|
||||
type: 'Query',
|
||||
schema: z.array(z.string()).min(1).optional(),
|
||||
},
|
||||
{
|
||||
name: 'tag_filter',
|
||||
type: 'Query',
|
||||
schema: z.enum(['contains', 'not_contains']).optional(),
|
||||
},
|
||||
{
|
||||
name: 'task_ids',
|
||||
type: 'Query',
|
||||
@@ -4165,6 +4172,11 @@ If the group parameters are all set to `null` or are all missing, the
|
||||
type: 'Query',
|
||||
schema: z.array(z.string()).min(1).optional(),
|
||||
},
|
||||
{
|
||||
name: 'tag_filter',
|
||||
type: 'Query',
|
||||
schema: z.enum(['contains', 'not_contains']).optional(),
|
||||
},
|
||||
{
|
||||
name: 'task_ids',
|
||||
type: 'Query',
|
||||
@@ -4359,6 +4371,11 @@ If the group parameters are all set to `null` or are all missing, the
|
||||
type: 'Query',
|
||||
schema: z.array(z.string()).min(1).optional(),
|
||||
},
|
||||
{
|
||||
name: 'tag_filter',
|
||||
type: 'Query',
|
||||
schema: z.enum(['contains', 'not_contains']).optional(),
|
||||
},
|
||||
{
|
||||
name: 'task_ids',
|
||||
type: 'Query',
|
||||
@@ -4487,6 +4504,11 @@ If the group parameters are all set to `null` or are all missing, the
|
||||
type: 'Query',
|
||||
schema: z.array(z.string()).min(1).optional(),
|
||||
},
|
||||
{
|
||||
name: 'tag_filter',
|
||||
type: 'Query',
|
||||
schema: z.enum(['contains', 'not_contains']).optional(),
|
||||
},
|
||||
{
|
||||
name: 'task_ids',
|
||||
type: 'Query',
|
||||
|
||||
@@ -114,6 +114,7 @@ const showCreateTagModal = ref(false);
|
||||
class="w-full rounded-md border border-input-border bg-input-background px-3 py-1.5 text-sm text-text-primary placeholder:text-text-tertiary focus:outline-none"
|
||||
placeholder="Search for a Tag..." />
|
||||
</ComboboxAnchor>
|
||||
<slot name="content-before-list"></slot>
|
||||
<ComboboxContent
|
||||
:dismiss-able="false"
|
||||
position="inline"
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export type ExportFormat = 'xlsx' | 'csv' | 'ods' | 'pdf';
|
||||
export type TagFilter = 'contains' | 'not_contains';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
"Project","Client","Description","Task","User","Group","Email","Tags","Start Date","Start Time","End Date","End Time","Duration (h)","Duration (decimal)","Billable Rate (USD)","Billable Amount (USD)"
|
||||
"Project without Client","","","","Peter Tester","","peter.test@email.test","Development, Backend","03/04/2024","10:23:52 AM","03/04/2024","10:23:52 AM","00:00:00","0.00","0.00","0.00"
|
||||
"Project for Big Company","Big Company","Working hard","Task 1","Peter Tester","","peter.test@email.test","","03/04/2024","10:23 AM","03/04/2024","11:23:01 AM","01:00:01","0.00","0.00","0.00"
|
||||
|
@@ -41,6 +41,30 @@ class ClockifyTimeEntriesImporterTest extends ImporterTestAbstract
|
||||
$this->assertSame(1, $report->clientsCreated);
|
||||
}
|
||||
|
||||
public function test_import_of_test_file_without_billable_works_and_defaults_to_non_billable(): void
|
||||
{
|
||||
// Arrange
|
||||
$organization = Organization::factory()->create();
|
||||
$timezone = 'Europe/Vienna';
|
||||
$importer = new ClockifyTimeEntriesImporter;
|
||||
$importer->init($organization);
|
||||
$data = Storage::disk('testfiles')->get('clockify_time_entries_import_test_4.csv');
|
||||
|
||||
// Act
|
||||
$importer->importData($data, $timezone);
|
||||
$report = $importer->getReport();
|
||||
|
||||
// Assert
|
||||
$testScenario = $this->checkTestScenarioAfterImportExcludingTimeEntries(false, true);
|
||||
$this->checkTimeEntries($testScenario, false, true);
|
||||
$this->assertSame(2, $report->timeEntriesCreated);
|
||||
$this->assertSame(2, $report->tagsCreated);
|
||||
$this->assertSame(1, $report->tasksCreated);
|
||||
$this->assertSame(1, $report->usersCreated);
|
||||
$this->assertSame(2, $report->projectsCreated);
|
||||
$this->assertSame(1, $report->clientsCreated);
|
||||
}
|
||||
|
||||
public function test_import_of_test_with_special_characters_description_succeeds(): void
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -26,7 +26,7 @@ class ImporterTestAbstract extends TestCase
|
||||
/**
|
||||
* @return object{user1: User, project1: Project, project2: Project, tag1: Tag, tag2: Tag}
|
||||
*/
|
||||
protected function checkTestScenarioAfterImportExcludingTimeEntries(bool $detailed = false): object
|
||||
protected function checkTestScenarioAfterImportExcludingTimeEntries(bool $detailed = false, bool $billableDefault = false): object
|
||||
{
|
||||
$users = User::all();
|
||||
$this->assertCount(2, $users);
|
||||
@@ -80,12 +80,12 @@ class ImporterTestAbstract extends TestCase
|
||||
$this->assertSame('#ef5350', $project1->color);
|
||||
$this->assertSame(null, $project1->billable_rate);
|
||||
// Project for Big Company
|
||||
$this->assertSame(true, $project2->is_billable);
|
||||
$this->assertSame(! $billableDefault, $project2->is_billable);
|
||||
$this->assertSame(false, $project2->is_public);
|
||||
$this->assertSame('#ec407a', $project2->color);
|
||||
$this->assertSame(10001, $project2->billable_rate);
|
||||
// Project (Archived)
|
||||
$this->assertSame(true, $project3->is_billable);
|
||||
$this->assertSame(! $billableDefault, $project3->is_billable);
|
||||
$this->assertSame(true, $project3->is_public);
|
||||
$this->assertSame('#6a407f', $project3->color);
|
||||
$this->assertSame(null, $project3->billable_rate);
|
||||
@@ -176,7 +176,7 @@ class ImporterTestAbstract extends TestCase
|
||||
/**
|
||||
* @param object{user1: User, project1: Project, project2: Project, tag1: Tag, tag2: Tag} $testScenario
|
||||
*/
|
||||
protected function checkTimeEntries(object $testScenario, bool $secondRun = false): void
|
||||
protected function checkTimeEntries(object $testScenario, bool $secondRun = false, bool $billableDefault = false): void
|
||||
{
|
||||
$timeEntries = TimeEntry::all();
|
||||
if ($secondRun) {
|
||||
@@ -197,7 +197,7 @@ class ImporterTestAbstract extends TestCase
|
||||
$this->assertSame('Working hard', $timeEntry2->description);
|
||||
$this->assertSame('2024-03-04 09:23:00', $timeEntry2->start->toDateTimeString());
|
||||
$this->assertSame('2024-03-04 10:23:01', $timeEntry2->end->toDateTimeString());
|
||||
$this->assertTrue($timeEntry2->billable);
|
||||
$this->assertSame(! $billableDefault, $timeEntry2->billable);
|
||||
$this->assertTrue($timeEntry2->is_imported);
|
||||
$this->assertSame([], $timeEntry2->tags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user