Compare commits

..

2 Commits

Author SHA1 Message Date
Constantin Graf
d4030011ca Fixed text for clockify import 2025-05-16 12:51:37 +02:00
Constantin Graf
c73d10e282 Fixed bugs in current organization; Add database consistency checks; Add foreign key 2025-05-16 12:51:27 +02:00
28 changed files with 175 additions and 811 deletions

View File

@@ -23,7 +23,6 @@ use Filament\Tables;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
@@ -208,14 +207,6 @@ class UserResource extends Resource
}),
])
->bulkActions([
Tables\Actions\BulkAction::make('Resend verification email')
->icon('heroicon-o-paper-airplane')
->action(function (Collection $records): void {
foreach ($records as $user) {
/** @var User $user */
$user->sendEmailVerificationNotification();
}
}),
]);
}

View File

@@ -148,8 +148,6 @@ class ReportController extends Controller
$report->share_secret = null;
$report->public_until = null;
}
} elseif ($report->is_public && $request->has('public_until')) {
$report->public_until = $request->getPublicUntil();
}
$report->save();

View File

@@ -226,7 +226,6 @@ class TimeEntryController extends Controller
'start' => $request->getStart()->timezone($timezone),
'end' => $request->getEnd()->timezone($timezone),
'localization' => $localizationService,
'showBillableRate' => $showBillableRate,
]);
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-index/pdf-footer.blade.php'));
if ($footerViewFile === false) {
@@ -429,7 +428,6 @@ class TimeEntryController extends Controller
'end' => $request->getEnd()->timezone($timezone),
'debug' => $debug,
'localization' => $localizationService,
'showBillableRate' => $showBillableRate,
]);
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-aggregate/pdf-footer.blade.php'));
if ($footerViewFile === false) {
@@ -458,7 +456,7 @@ class TimeEntryController extends Controller
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
} else {
Excel::store(
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup, $showBillableRate),
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup),
$path,
config('filesystems.private'),
$format->getExportPackageType(),

View File

@@ -8,7 +8,9 @@ use Illuminate\Foundation\Http\FormRequest;
class BaseFormRequest extends FormRequest
{
/**
* @param bool $bigInt
* @return list<string>
*/
protected function moneyRules(bool $bigInt = false): array

View File

@@ -46,8 +46,6 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
private TimeEntryAggregationType $subGroup;
private bool $showBillableRate;
/**
* @param array{
* grouped_type: string|null,
@@ -68,14 +66,13 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
* cost: int|null
* } $data
*/
public function __construct(array $data, ExportFormat $exportFormat, string $currency, TimeEntryAggregationType $group, TimeEntryAggregationType $subGroup, bool $showBillableRate)
public function __construct(array $data, ExportFormat $exportFormat, string $currency, TimeEntryAggregationType $group, TimeEntryAggregationType $subGroup)
{
$this->data = $data;
$this->exportFormat = $exportFormat;
$this->currency = $currency;
$this->group = $group;
$this->subGroup = $subGroup;
$this->showBillableRate = $showBillableRate;
}
public function view(): View
@@ -86,7 +83,6 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
'group' => $this->group,
'subGroup' => $this->subGroup,
'exportFormat' => $this->exportFormat,
'showBillableRate' => $this->showBillableRate,
]);
}

View File

@@ -230,9 +230,7 @@ test('test that format settings are reflected in the dashboard', async ({
await expect(page.getByText('0.00€')).toBeVisible();
// check that 00:00 is displayed
await expect(
page.getByText('0:00 h', { exact: true }).nth(0)
).toBeVisible();
await expect(page.getByText('0:00', { exact: true }).nth(0)).toBeVisible();
// check that 0h 00min is not displayed
await expect(
page.getByText('0h 00min', { exact: true }).nth(0)

View File

@@ -102,7 +102,7 @@ test('test that updating billable rate works with existing time entries', async
await page.getByRole('row').first().getByRole('button').click();
await page.getByRole('menuitem').getByText('Edit').first().click();
await page.getByText('Non-Billable').click();
await page.getByText('Non-Billable').click();
await page.getByText('Custom Rate').click();
await page
.getByPlaceholder('Billable Rate')
@@ -136,49 +136,6 @@ test('test that updating billable rate works with existing time entries', async
).toBeVisible();
});
test('test that creating and updating project time estimate works', async ({ page }) => {
const newProjectName = 'New Project ' + Math.floor(1 + Math.random() * 10000);
const timeEstimate = '10';
await goToProjectsOverview(page);
await page.getByRole('button', { name: 'Create Project' }).click();
await page.getByLabel('Project Name').fill(newProjectName);
await page.getByLabel('Time Estimated').fill(timeEstimate);
await Promise.all([
page.getByRole('button', { name: 'Create Project' }).click(),
page.waitForResponse(
async (response) =>
response.url().includes('/projects') &&
response.request().method() === 'POST' &&
response.status() === 201 &&
(await response.json()).data.estimated_time === parseInt(timeEstimate) * 60 * 60
),
]);
// Check that time estimate is displayed in the projects table
await expect(page.getByTestId('project_table')).toContainText(timeEstimate + 'h');
// Edit project to remove time estimate
await page.getByRole('row').first().getByRole('button').click();
await page.getByRole('menuitem').getByText('Edit').first().click();
await page.getByLabel('Time Estimated').fill('');
await Promise.all([
page.getByRole('button', { name: 'Update Project' }).click(),
page.waitForResponse(
async (response) =>
response.url().includes('/projects') &&
response.request().method() === 'PUT' &&
response.status() === 200 &&
(await response.json()).data.estimated_time === null
),
]);
// Check that time estimate is no longer displayed
await expect(page.getByTestId('project_table')).not.toContainText(timeEstimate + 'h');
});
// Create new project with new Client
// Create new project with existing Client

View File

@@ -15,7 +15,6 @@ import { api } from '@/packages/api/src';
import { Checkbox } from '@/packages/ui/src';
import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
import { useNotificationsStore } from '@/utils/notification';
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
const show = defineModel('show', { default: false });
const saving = ref(false);
@@ -48,14 +47,10 @@ const report = ref({
const { handleApiRequestNotifications } = useNotificationsStore();
async function submit() {
const { public_until, ...reportProperties } = report.value;
await handleApiRequestNotifications(
() =>
createReportMutation.mutateAsync({
...reportProperties,
public_until: public_until
? getLocalizedDayJs(public_until).utc().format()
: null,
...report.value,
properties: { ...props.properties },
}),
'Success',
@@ -108,16 +103,13 @@ async function submit() {
<div
v-if="report.is_public"
class="flex items-center space-x-4">
<div class="w-full">
<div>
<InputLabel for="public_until" value="Expires at" />
<div class="text-text-tertiary font-medium">
(optional)
</div>
</div>
<DatePicker
id="public_until"
v-model="report.public_until"
size="input"></DatePicker>
<DatePicker id="public_until"></DatePicker>
</div>
</div>
</div>

View File

@@ -13,7 +13,6 @@ import { Checkbox } from '@/packages/ui/src';
import DatePicker from '@/packages/ui/src/Input/DatePicker.vue';
import { useNotificationsStore } from '@/utils/notification';
import type { Report } from '@/packages/api/src';
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
const show = defineModel('show', { default: false });
const saving = ref(false);
@@ -65,15 +64,8 @@ watch(
const { handleApiRequestNotifications } = useNotificationsStore();
async function submit() {
const { public_until, ...reportProperties } = report.value;
await handleApiRequestNotifications(
() =>
updateReportMutation.mutateAsync({
...reportProperties,
public_until: public_until
? getLocalizedDayJs(public_until).utc().format()
: null,
}),
() => updateReportMutation.mutateAsync(report.value),
'Success',
'Error',
() => {
@@ -126,10 +118,7 @@ async function submit() {
v-if="report.is_public"
class="flex items-center space-x-4">
<InputLabel for="public_until" value="Expires at" />
<DatePicker
id="public_until"
v-model="report.public_until"
size="input"></DatePicker>
<DatePicker id="public_until"></DatePicker>
</div>
</div>
</div>

View File

@@ -5,7 +5,6 @@ import { h, ref } from 'vue';
import type { CreateReportBodyProperties } from '@/packages/api/src';
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
import UpgradeModal from '@/Components/Common/UpgradeModal.vue';
import { canCreateReports } from '@/utils/permissions';
defineProps<{
reportProperties: CreateReportBodyProperties;
}>();
@@ -34,10 +33,7 @@ function onSaveReportClick() {
<strong>Sharable Reports</strong> is only available in solidtime
Professional.
</UpgradeModal>
<SecondaryButton
v-if="canCreateReports()"
:icon="SaveIcon"
@click="onSaveReportClick"
<SecondaryButton :icon="SaveIcon" @click="onSaveReportClick"
>Save Report</SecondaryButton
>
</template>

View File

@@ -107,10 +107,6 @@ function getFilterAttributes(): AggregatedTimeEntriesQueryParams {
: undefined,
tag_ids: selectedTags.value.length > 0 ? selectedTags.value : undefined,
billable: billable.value !== null ? billable.value : undefined,
member_id:
getCurrentRole() === 'employee'
? getCurrentMembershipId()
: undefined,
};
return params;
}

View File

@@ -119,8 +119,7 @@ function deleteSelected() {
</script>
<template>
<AppLayout title="Dashboard" data-testid="time_view">
<TimeEntryCreateModal
<TimeEntryCreateModal
v-model:show="showManualTimeEntryModal"
:enable-estimated-time="isAllowedToPerformPremiumAction()"
:create-project="createProject"
@@ -131,6 +130,7 @@ function deleteSelected() {
:tasks
:tags
:clients></TimeEntryCreateModal>
<AppLayout title="Dashboard" data-testid="time_view">
<MainContainer
class="pt-5 lg:pt-8 pb-4 lg:pb-6">
<div

View File

@@ -11,10 +11,9 @@ const emit = defineEmits(['submit']);
<div class="pt-6">
<div class="flex items-center space-x-1 mb-2">
<ClockIcon class="text-text-quaternary w-4"></ClockIcon>
<InputLabel for="time-estimated" value="Time Estimated" />
<InputLabel for="billable" value="Time Estimated" />
</div>
<DurationInput
id="time-estimated"
v-model="model"
class="max-w-[150px]"
@submit="emit('submit')"></DurationInput>

View File

@@ -1,96 +1,76 @@
<script setup lang="ts">
import { ref, watch } from 'vue';
import {
Popover,
PopoverContent,
PopoverTrigger,
} from '@/Components/ui/popover';
import { Button, type ButtonVariants } from '@/Components/ui/button';
import { Calendar } from '@/Components/ui/calendar';
import { CalendarIcon } from 'lucide-vue-next';
import { formatDateLocalized } from '@/packages/ui/src/utils/time';
import { parseDate, type DateValue } from '@internationalized/date';
import { computed, inject, type ComputedRef } from 'vue';
import { type Organization } from '@/packages/api/src';
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
getDayJsInstance,
getLocalizedDayJs,
} from '@/packages/ui/src/utils/time';
import { twMerge } from 'tailwind-merge';
const props = defineProps<{
class?: string;
tabindex?: string;
size: ButtonVariants['size'];
}>();
const model = defineModel<string | null>();
const emit = defineEmits<{
changed: [string];
}>();
const handleChange = (date: DateValue | undefined) => {
if (!date) {
model.value = null;
return;
}
const dayjs = model.value
? getLocalizedDayJs(model.value)
: getLocalizedDayJs();
model.value = dayjs
.year(date.year)
.month(date.month - 1) // CalendarDate uses 1-based months
.date(date.day)
.format();
emit('changed', model.value);
};
const date = computed(() => {
return model.value
? parseDate(getLocalizedDayJs(model.value).format('YYYY-MM-DD'))
: undefined;
// This has to be a localized timestamp, not UTC
const model = defineModel<string | null>({
default: null,
});
const organization = inject<ComputedRef<Organization>>('organization');
const tempDate = ref(getLocalizedDayJs(model.value).format('YYYY-MM-DD'));
watch(model, (value) => {
tempDate.value = getLocalizedDayJs(value).format('YYYY-MM-DD');
});
function updateDate(event: Event) {
const target = event.target as HTMLInputElement;
const newValue = target.value;
const newDate = getDayJsInstance()(newValue);
if (newDate.isValid()) {
model.value = getLocalizedDayJs(model.value)
.set('year', newDate.year())
.set('month', newDate.month())
.set('date', newDate.date())
.format();
emit('changed', model.value);
}
}
const datePicker = ref<HTMLInputElement | null>(null);
function updateTempValue(event: Event) {
const target = event.target as HTMLInputElement;
tempDate.value = target.value;
}
const emit = defineEmits(['changed']);
</script>
<template>
<Popover>
<PopoverTrigger as-child>
<Button
variant="input"
:size="size"
:class="[
size === 'sm' ? 'gap-1.5' : 'gap-2',
'w-full justify-center text-left font-normal',
!model && 'text-muted-foreground',
props.class,
]"
:tabindex="tabindex">
<CalendarIcon
:class="[
size === 'xs'
? 'h-3 w-3'
: size === 'sm'
? 'h-3 w-3'
: size === 'lg'
? 'h-4.5 w-4.5'
: 'h-4 w-4',
]" />
<span class="text-center">
{{
model
? formatDateLocalized(
model,
organization?.date_format
)
: 'Pick a date'
}}
</span>
</Button>
</PopoverTrigger>
<PopoverContent class="w-auto p-0">
<Calendar
mode="single"
:model-value="date"
:initial-focus="true"
@update:model-value="handleChange" />
</PopoverContent>
</Popover>
<div class="flex items-center text-text-secondary">
<input
id="start"
ref="datePicker"
:tabindex="tabindex"
:class="
twMerge(
'bg-input-background border text-text-primary border-input-border focus-visible:outline-0 focus-visible:border-input-border-active focus-visible:ring-0 rounded-md',
props.class
)
"
type="date"
name="trip-start"
:value="tempDate"
@change="updateTempValue"
@blur="updateDate"
@keydown.enter="updateDate" />
</div>
</template>
<style scoped>
input::-webkit-calendar-picker-indicator {
filter: invert(1);
opacity: 0.2;
}
</style>

View File

@@ -2,10 +2,6 @@
import { computed, ref } from 'vue';
import { TextInput } from '@/packages/ui/src';
defineProps<{
id?: string;
}>();
const model = defineModel<number | null>({
default: null,
});
@@ -20,8 +16,6 @@ function updateDuration() {
const hours = parseInt(temporaryCustomTimerEntry.value);
if (!isNaN(hours)) {
model.value = hours * 60 * 60;
} else {
model.value = null;
}
temporaryCustomTimerEntry.value = '';
}
@@ -60,7 +54,6 @@ function updateAndSubmit() {
<template>
<div class="relative">
<TextInput
:id="id"
v-model="currentTime"
class="w-full overflow-hidden pr-14"
placeholder="0"

View File

@@ -5,7 +5,6 @@ import { twMerge } from 'tailwind-merge';
const props = defineProps<{
name?: string;
class?: string;
id?: string;
}>();
const input = ref<HTMLInputElement | null>(null);
@@ -22,7 +21,6 @@ const model = defineModel();
<template>
<input
:id="id"
ref="input"
v-model="model"
:class="

View File

@@ -1,18 +1,15 @@
<script setup lang="ts">
import { ref, watch, inject, type ComputedRef } from 'vue';
import { getLocalizedDayJs, formatTime } from '@/packages/ui/src/utils/time';
import { ref, watch } from 'vue';
import { getLocalizedDayJs } from '@/packages/ui/src/utils/time';
import { useFocus } from '@vueuse/core';
import { TextInput } from '@/packages/ui/src';
import { twMerge } from 'tailwind-merge';
import type { Organization } from '@/packages/api/src';
// This has to be a localized timestamp, not UTC
const model = defineModel<string | null>({
default: null,
});
const organization = inject<ComputedRef<Organization>>('organization');
const props = withDefaults(
defineProps<{
size?: 'base' | 'large';
@@ -27,95 +24,62 @@ const props = withDefaults(
function updateTime(event: Event) {
const target = event.target as HTMLInputElement;
const newValue = target.value.trim();
// Get current hours and minutes for comparison
const currentTime = model.value ? getLocalizedDayJs(model.value) : null;
const currentHours = currentTime?.hour() ?? 0;
const currentMinutes = currentTime?.minute() ?? 0;
// Handle AM/PM format
const amPmMatch = newValue.match(/^(\d{1,2}):?(\d{2})?\s*(AM|PM|am|pm)$/);
if (amPmMatch) {
let hours = amPmMatch[1];
const minutes = amPmMatch[2] ?? '00';
const period = amPmMatch[3];
hours = parseInt(hours).toString();
if (period.toUpperCase() === 'PM' && hours !== '12') {
hours = (parseInt(hours) + 12).toString();
} else if (period.toUpperCase() === 'AM' && hours === '12') {
hours = '0';
}
const newHours = parseInt(hours);
const newMinutes = parseInt(minutes);
if (newHours !== currentHours || newMinutes !== currentMinutes) {
model.value = getLocalizedDayJs(model.value)
.set('hours', newHours)
.set('minutes', newMinutes)
.set('seconds', 0)
.format();
emit('changed', model.value);
}
return;
}
// Handle existing formats
if (newValue.split(':').length === 2) {
const [hours, minutes] = newValue.split(':');
if (!isNaN(parseInt(hours)) && !isNaN(parseInt(minutes))) {
const newHours = Math.min(parseInt(hours), 23);
const newMinutes = Math.min(parseInt(minutes), 59);
if (newHours !== currentHours || newMinutes !== currentMinutes) {
model.value = getLocalizedDayJs(model.value)
.set('hours', newHours)
.set('minutes', newMinutes)
.set('seconds', 0)
.format();
emit('changed', model.value);
}
model.value = getLocalizedDayJs(model.value)
.set('hours', Math.min(parseInt(hours), 23))
.set('minutes', Math.min(parseInt(minutes), 59))
.format();
emit('changed', model.value);
}
}
// check if input is only numbers
else if (/^\d+$/.test(newValue)) {
let newHours = currentHours;
let newMinutes = currentMinutes;
if (newValue.length === 4) {
// parse 1300 to 13:00
newHours = Math.min(parseInt(newValue.slice(0, 2)), 23);
newMinutes = Math.min(parseInt(newValue.slice(2, 4)), 59);
const [hours, minutes] = [
newValue.slice(0, 2),
newValue.slice(2, 4),
];
model.value = getLocalizedDayJs(model.value)
.set('hours', Math.min(parseInt(hours), 23))
.set('minutes', Math.min(parseInt(minutes), 59))
.format();
emit('changed', model.value);
} else if (newValue.length === 3) {
// parse 130 to 01:30
newHours = Math.min(parseInt(newValue.slice(0, 1)), 23);
newMinutes = Math.min(parseInt(newValue.slice(1, 3)), 59);
const [hours, minutes] = [
newValue.slice(0, 1),
newValue.slice(1, 3),
];
model.value = getLocalizedDayJs(model.value)
.set('hours', Math.min(parseInt(hours), 23))
.set('minutes', Math.min(parseInt(minutes), 59))
.format();
emit('changed', model.value);
} else if (newValue.length === 2) {
// parse 13 to 13:00
newHours = Math.min(parseInt(newValue), 23);
newMinutes = 0;
model.value = getLocalizedDayJs(model.value)
.set('hours', Math.min(parseInt(newValue), 23))
.set('minutes', 0)
.format();
emit('changed', model.value);
} else if (newValue.length === 1) {
// parse 1 to 01:00
newHours = Math.min(parseInt(newValue), 23);
newMinutes = 0;
}
if (newHours !== currentHours || newMinutes !== currentMinutes) {
model.value = getLocalizedDayJs(model.value)
.set('hours', newHours)
.set('minutes', newMinutes)
.set('seconds', 0)
.set('hours', Math.min(parseInt(newValue), 23))
.set('minutes', 0)
.format();
emit('changed', model.value);
}
}
inputValue.value = getLocalizedDayJs(model.value).format('HH:mm');
}
watch(model, (value) => {
inputValue.value = value
? formatTime(value, organization?.value?.time_format || '24-hours')
: null;
inputValue.value = value ? getLocalizedDayJs(value).format('HH:mm') : null;
});
const timeInput = ref<HTMLInputElement | null>(null);
@@ -124,12 +88,7 @@ const emit = defineEmits(['changed']);
useFocus(timeInput, { initialValue: props.focus });
const inputValue = ref(
model.value
? formatTime(
model.value,
organization?.value?.time_format || '24-hours'
)
: null
model.value ? getLocalizedDayJs(model.value).format('HH:mm') : null
);
</script>
@@ -139,7 +98,7 @@ const inputValue = ref(
ref="timeInput"
v-model="inputValue"
:class="
twMerge('text-center w-28 px-3 py-2', size === 'large' && 'w-28')
twMerge('text-center w-24 px-3 py-2', size === 'large' && 'w-28')
"
data-testid="time_picker_input"
type="text"

View File

@@ -52,22 +52,26 @@ watch(focused, (newValue, oldValue) => {
</script>
<template>
<form
<div
ref="dropdownContent"
class="grid grid-cols-2 divide-x divide-card-background-separator text-center py-2">
<div class="px-2">
<div class="font-semibold text-text-primary text-sm pb-2">
Start
</div>
<div
class="px-2"
@keydown.enter.prevent="nextTick(() => emit('close'))">
<div class="font-semibold text-text-primary text-sm pb-2">Start</div>
<div class="space-y-2">
<TimePickerSimple
v-model="tempStart"
data-testid="time_entry_range_start"
tabindex="0"
:focus
@keydown.enter.prevent="nextTick(() => emit('close'))"
@keydown.exact.tab.shift.stop.prevent="emit('close')"
@changed="updateTimeEntry"></TimePickerSimple>
<DatePicker
v-model="tempStart"
class="text-xs text-text-tertiary max-w-24 px-1.5 py-1.5"
@changed="updateTimeEntry"
@blur.stop.prevent="emit('close')"></DatePicker>
</div>
</div>
<div class="px-2">
@@ -76,31 +80,16 @@ watch(focused, (newValue, oldValue) => {
<TimePickerSimple
v-model="tempEnd"
data-testid="time_entry_range_end"
@keydown.enter.prevent="nextTick(() => emit('close'))"
@changed="updateTimeEntry"></TimePickerSimple>
<DatePicker
v-model="tempEnd"
class="text-xs text-text-tertiary max-w-24 px-1.5 py-1.5"
@changed="updateTimeEntry"></DatePicker>
</div>
<div v-else class="text-text-secondary">-- : --</div>
<div tabindex="0" @focusin="emit('close')"></div>
</div>
<div class="px-2 pt-2">
<DatePicker
v-model="tempStart"
size="sm"
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"
@changed="updateTimeEntry"></DatePicker>
</div>
<div class="px-2 pt-2">
<DatePicker
v-if="tempEnd !== null"
v-model="tempEnd"
size="sm"
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"
@changed="updateTimeEntry"></DatePicker>
</div>
<div
tabindex="0"
class="focus-visible:outline-none"
@focusin="emit('close')"></div>
</form>
</div>
</template>
<style></style>

View File

@@ -29,7 +29,7 @@ import DurationHumanInput from '@/packages/ui/src/Input/DurationHumanInput.vue';
import { InformationCircleIcon } from '@heroicons/vue/20/solid';
import type { Tag, Task } from '@/packages/api/src';
import TimePickerSimple from '@/packages/ui/src/Input/TimePickerSimple.vue';
import TimePickerSimple from "@/packages/ui/src/Input/TimePickerSimple.vue";
const show = defineModel('show', { default: false });
const saving = ref(false);
@@ -148,7 +148,9 @@ type BillableOption = {
<div class="flex-1 min-w-0">
<TimeTrackerProjectTaskDropdown
v-model:project="timeEntry.project_id"
v-model:task="timeEntry.task_id"
v-model:task="
timeEntry.task_id
"
:clients
:create-project
:create-client
@@ -158,9 +160,7 @@ type BillableOption = {
class="bg-input-background"
:projects="projects"
:tasks="tasks"
:enable-estimated-time="
enableEstimatedTime
"></TimeTrackerProjectTaskDropdown>
:enable-estimated-time="enableEstimatedTime"></TimeTrackerProjectTaskDropdown>
</div>
<div class="flex items-center space-x-2">
<div class="flex-col">
@@ -242,33 +242,37 @@ type BillableOption = {
</div>
</div>
</div>
<div class="grid gap-2 grid-cols-2">
<div class="space-y-1">
<InputLabel>Start</InputLabel>
<div class="">
<InputLabel>Start</InputLabel>
<div class="flex flex-col items-center space-y-2 mt-1">
<TimePickerSimple
v-model="localStart"
size="large"></TimePickerSimple>
<DatePicker
v-model="localStart"
tabindex="1"
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
</div>
<div class="space-y-1">
<InputLabel>End</InputLabel>
</div>
<div class="">
<InputLabel>End</InputLabel>
<div class="flex flex-col items-center space-y-2 mt-1">
<TimePickerSimple
v-model="localEnd"
size="large"></TimePickerSimple>
<DatePicker
v-model="localEnd"
tabindex="1"
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
</div>
<DatePicker
v-model="localStart"
size="sm"
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
<DatePicker
v-model="localEnd"
size="sm"
class="text-xs text-text-tertiary max-w-28 px-1.5 py-1.5"></DatePicker>
</div>
</div>
</template>
<template #footer>
<SecondaryButton @click="show = false">Cancel</SecondaryButton>
<SecondaryButton tabindex="2" @click="show = false"> Cancel</SecondaryButton>
<PrimaryButton
tabindex="2"
class="ms-3"
:class="{ 'opacity-25': saving }"
:disabled="saving"

View File

@@ -101,19 +101,15 @@ const startTime = computed(() => {
const inputField = ref<HTMLInputElement | null>(null);
const timeRangeSelector = ref<HTMLElement | null>(null);
const isMouseDown = ref(false);
function openModalOnTab(e: FocusEvent) {
// check if the source is inside the dropdown
console.log(e.target);
const source = e.relatedTarget as HTMLElement;
if (
source &&
window.document.body
.querySelector<HTMLElement>('#app')
?.contains(source) &&
!isMouseDown.value
?.contains(source)
) {
open.value = true;
}
@@ -157,8 +153,6 @@ function closeAndFocusInput() {
@keydown.exact.tab="focusNextElement"
@keydown.exact.shift.tab="open = false"
@blur="updateTimerAndStartLiveTimerUpdate"
@mousedown="isMouseDown = true"
@mouseup="isMouseDown = false"
@keydown.enter="onTimeEntryEnterPress" />
</template>
<template #content>

View File

@@ -13,6 +13,7 @@ import updateLocale from 'dayjs/plugin/updateLocale';
import { computed } from 'vue';
import { formatNumber } from './number';
export type DateFormat =
| 'point-separated-d-m-yyyy'
| 'slash-separated-mm-dd-yyyy'
@@ -27,7 +28,7 @@ const dateFormatMap: Record<DateFormat, string> = {
'slash-separated-dd-mm-yyyy': 'DD/MM/YYYY',
'hyphen-separated-dd-mm-yyyy': 'DD-MM-YYYY',
'hyphen-separated-mm-dd-yyyy': 'MM-DD-YYYY',
'hyphen-separated-yyyy-mm-dd': 'YYYY-MM-DD',
'hyphen-separated-yyyy-mm-dd': 'YYYY-MM-DD'
};
export type TimeFormat = '12-hours' | '24-hours';
@@ -83,7 +84,7 @@ export function formatHumanReadableDuration(
case 'hours-minutes':
return `${hours}h ${minutes.toString().padStart(2, '0')}min`;
case 'hours-minutes-colon-separated':
return `${hours}:${minutes.toString().padStart(2, '0')} h`;
return `${hours}:${minutes.toString().padStart(2, '0')}`;
case 'hours-minutes-seconds-colon-separated':
return `${hours}:${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
default:
@@ -128,10 +129,7 @@ export function getLocalizedDateFromTimestamp(timestamp: string) {
* Returns a formatted date.
* @param date - date in the format of 'YYYY-MM-DD'
*/
export function formatDate(
date: string,
format: DateFormat = 'point-separated-d-m-yyyy'
): string {
export function formatDate(date: string, format: DateFormat = 'point-separated-d-m-yyyy'): string {
if (date?.includes('+')) {
console.warn(
'Date contains timezone information, use formatDateLocalized instead'
@@ -144,18 +142,11 @@ export function formatDate(
* Returns a formatted date.
* @param date - date in the format of 'YYYY-MM-DD'
*/
export function formatDateLocalized(
date: string,
format: DateFormat = 'point-separated-d-m-yyyy'
): string {
export function formatDateLocalized(date: string, format: DateFormat = 'point-separated-d-m-yyyy'): string {
return getLocalizedDayJs(date).format(dateFormatMap[format]);
}
export function formatDateTimeLocalized(
date: string,
dateFormat?: DateFormat,
timeFormat?: TimeFormat
): string {
export function formatDateTimeLocalized(date: string, dateFormat?: DateFormat, timeFormat?: TimeFormat): string {
const format = `${dateFormatMap[dateFormat ?? 'point-separated-d-m-yyyy']} ${timeFormat === '12-hours' ? 'hh:mm A' : 'HH:mm'}`;
return getLocalizedDayJs(date).format(format);
}
@@ -181,11 +172,7 @@ export function formatWeekday(date: string) {
return dayjs(date).format('dddd');
}
export function formatStartEnd(
start: string,
end: string | null,
timeFormat: TimeFormat = '24-hours'
) {
export function formatStartEnd(start: string, end: string | null, timeFormat: TimeFormat = '24-hours') {
if (end) {
return `${formatTime(start, timeFormat)} - ${formatTime(end, timeFormat)}`;
} else {

View File

@@ -125,6 +125,4 @@ export function canViewAllTimeEntries() {
export function canViewInvoices() {
return currentUserHasPermission('invoices:view');
}
export function canCreateReports() {
return currentUserHasPermission('reports:create');
}

View File

@@ -152,13 +152,12 @@
<div
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }} </div>
</div>
@if($showBillableRate)
<div style="padding: 8px 12px; border-radius: 8px;">
<div style="color: #71717a; font-weight: 600;">Total cost</div>
<div
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }} </div>
</div>
@endif
</div>
<div id="main-chart" style="width: 700px; height: 300px; margin: 20px auto;"></div>
@@ -178,9 +177,7 @@
{{ $group->description() }}
</th>
<th>Duration</th>
@if($showBillableRate)
<th style="text-align: right;">Cost</th>
@endif
</tr>
</thead>
@foreach($aggregatedData['grouped_data'] as $group1Entry)
@@ -191,21 +188,23 @@
}};">
</div>
<span style="padding-left: 8px;">
@if($group->is(\App\Enums\TimeEntryAggregationType::Billable))
{{ $group1Entry['key'] === '1' ? 'Billable' : 'Non-billable' }}
@else
{{ $group1Entry['description'] ?? $group1Entry['key'] ?? 'No '.Str::lower($group->description()) }}
@endif
</span>
</span>
</td>
<td style="text-align: left;">
{{ $localization->formatInterval(CarbonInterval::seconds($group1Entry['seconds'])) }}
</td>
@if($showBillableRate)
<td style="text-align: right;">
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($group1Entry['cost'], 2)->__toString(), $currency)) }}
</td>
@endif
</tr>
@endforeach
<tfoot>
@@ -216,11 +215,9 @@
<td style="font-weight: 500;color: #18181b;">
{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }}
</td>
@if($showBillableRate)
<td style="text-align: right; font-weight: 500;color: #18181b;">
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }}
</td>
@endif
</tr>
</tfoot>
</table>
@@ -256,11 +253,9 @@
<th>
Duration (h)
</th>
@if($showBillableRate)
<th>
Cost
</th>
@endif
</tr>
</thead>
<tbody>
@@ -287,17 +282,13 @@
<td>
{{ $localization->formatNumber($duration->totalHours) }}
</td>
@if($showBillableRate)
<td>
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->__toString(), $currency)) }}
</td>
@endif
</tr>
@php
$totalDuration += $group2Entry['seconds'];
if ($showBillableRate) {
$totalCost += $group2Entry['cost'];
}
$totalCost += $group2Entry['cost'];
@endphp
@endforeach
</tbody>

View File

@@ -62,11 +62,9 @@
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
{{ round($duration->totalHours, 2) }}
</td>
@if($showBillableRate)
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
{{ round(BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->toFloat(), 2) }}
</td>
@endif
@else
@if ($group === TimeEntryAggregationType::Billable)
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
@@ -94,20 +92,16 @@
data-format="{{ NumberFormat::FORMAT_NUMBER_00 }}">
{{ $duration->totalHours }}
</td>
@if($showBillableRate)
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_NUMERIC }}"
data-format="{{ NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1 }}">
{{ BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->__toString() }}
</td>
@endif
@endif
</tr>
@php
++$counter;
$totalDuration += $group2Entry['seconds'];
if ($showBillableRate) {
$totalCost += $group2Entry['cost'];
}
$totalCost += $group2Entry['cost'];
@endphp
@endforeach
@endforeach
@@ -126,11 +120,9 @@
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_STRING }}">
{{ round($totalDurationInterval->totalHours, 2) }}
</td>
@if($showBillableRate)
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_STRING }}">
{{ round(BigDecimal::ofUnscaledValue($totalCost, 2)->toFloat(), 2) }}
</td>
@endif
@else
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_FORMULA }}"
data-format="[hh]:mm:ss">

View File

@@ -140,14 +140,12 @@
<div
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }} </div>
</div>
@if($showBillableRate)
<div style="padding: 8px 12px; border-radius: 8px;">
<div style="color: #71717a; font-weight: 600;">Total cost</div>
<div style="font-size: 24px; font-weight: 500; margin-top: 2px;">
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }}
</div>
<div
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }} </div>
</div>
@endif
</div>
<div>
<table style="width: 100%;">

View File

@@ -56,12 +56,10 @@ abstract class TestCaseWithDatabase extends TestCase
/**
* @return object{user: User, organization: Organization, member: Member, owner: User, ownerMember: Member}
*/
public function createUserWithRole(Role $role, bool $employeesCanSeeBillableRates = false): object
public function createUserWithRole(Role $role): object
{
$owner = User::factory()->create();
$organization = Organization::factory()->withOwner($owner)->create([
'employees_can_see_billable_rates' => $employeesCanSeeBillableRates,
]);
$organization = Organization::factory()->withOwner($owner)->create();
$ownerMember = Member::factory()->forUser($owner)->forOrganization($organization)->role(Role::Owner)->create();
$owner->currentOrganization()->associate($organization);
$owner->save();

View File

@@ -340,35 +340,6 @@ class ReportEndpointTest extends ApiEndpointTestAbstract
);
}
public function test_update_endpoint_can_update_public_until_without_changing_secret(): void
{
// Arrange
$data = $this->createUserWithPermission([
'reports:update',
]);
$report = Report::factory()->public()->forOrganization($data->organization)->create();
$secret = $report->share_secret;
$newPublicUntil = Carbon::now()->addDays(30)->toIso8601ZuluString();
Passport::actingAs($data->user);
// Act
$response = $this->putJson(route('api.v1.reports.update', [$data->organization->getKey(), $report->getKey()]), [
'public_until' => $newPublicUntil,
]);
// Assert
$report->refresh();
$this->assertTrue($report->is_public);
$this->assertSame($secret, $report->share_secret);
$this->assertSame($newPublicUntil, $report->public_until->toIso8601ZuluString());
$response->assertStatus(200);
$response->assertJson(fn (AssertableJson $json) => $json
->has('data')
->where('data.is_public', true)
->where('data.shareable_link', $report->getShareableLink())
);
}
public function test_update_endpoint_can_update_the_report_all_properties_set(): void
{
// Arrange

View File

@@ -686,10 +686,6 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
'time-entries:view:all',
]);
Passport::actingAs($data->user);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$this->actAsOrganizationWithSubscription();
// Act
@@ -704,192 +700,6 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_csv_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::CSV,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_ods_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::ODS,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_xlxs_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::XLSX,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_pdf_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
Passport::actingAs($data->user);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$this->actAsOrganizationWithSubscription();
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::PDF,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_csv_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::CSV,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_ods_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::ODS,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_xlxs_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::XLSX,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_index_export_endpoint_can_create_a_detailed_time_entry_report_in_format_pdf_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
Passport::actingAs($data->user);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$this->actAsOrganizationWithSubscription();
// Act
$response = $this->getJson(route('api.v1.time-entries.index-export', [
$data->organization->getKey(),
'format' => ExportFormat::PDF,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->id,
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_fails_if_user_no_permission_to_view_time_entries(): void
{
// Arrange
@@ -1005,58 +815,6 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_csv_report_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::CSV,
'group' => TimeEntryAggregationType::Client,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_csv_report_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::CSV,
'group' => TimeEntryAggregationType::Client,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_xlsx_report(): void
{
// Arrange
@@ -1084,58 +842,6 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_xlsx_report_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::XLSX,
'group' => TimeEntryAggregationType::Client,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_xlsx_report_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::XLSX,
'group' => TimeEntryAggregationType::Client,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_ods_report(): void
{
// Arrange
@@ -1163,58 +869,6 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_ods_report_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::ODS,
'group' => TimeEntryAggregationType::User,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_ods_report_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::ODS,
'group' => TimeEntryAggregationType::User,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoint_fails_if_pdf_renderer_is_not_configured_but_a_user_want_a_pdf_report(): void
{
// Arrange
@@ -1273,60 +927,6 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_pdf_report_as_employee_role_with_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, true);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
$this->actAsOrganizationWithSubscription();
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::PDF,
'group' => TimeEntryAggregationType::User,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_export_endpoints_can_create_a_pdf_report_as_employee_role_without_show_billable_rate(): void
{
// Arrange
$data = $this->createUserWithRole(Role::Employee, false);
$client = Client::factory()->forOrganization($data->organization)->create();
$project = Project::factory()->forOrganization($data->organization)->forClient($client)->create();
$timeEntry1 = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
$timeEntry2 = TimeEntry::factory()->forOrganization($data->organization)->forProject($project)->forMember($data->member)->startWithDuration(Carbon::now(), 100)->create();
Passport::actingAs($data->user);
$this->actAsOrganizationWithSubscription();
// Act
$response = $this->getJson(route('api.v1.time-entries.aggregate-export', [
$data->organization->getKey(),
'format' => ExportFormat::PDF,
'group' => TimeEntryAggregationType::User,
'sub_group' => TimeEntryAggregationType::Project,
'history_group' => TimeEntryAggregationTypeInterval::Month,
'start' => Carbon::now()->startOfYear()->toIso8601ZuluString(),
'end' => Carbon::now()->endOfYear()->toIso8601ZuluString(),
'member_id' => $data->member->getKey(),
]));
// Assert
$this->assertResponseCode($response, 200);
}
public function test_aggregate_endpoint_fails_if_user_has_only_access_to_own_time_entries_but_does_not_filter_for_this(): void
{
// Arrange