mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-18 21:22:15 +01:00
Compare commits
7 Commits
feature/co
...
7ae4f2171d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ae4f2171d | ||
|
|
96acd4b962 | ||
|
|
48f09421d0 | ||
|
|
36caadeb14 | ||
|
|
b4edcaa2dc | ||
|
|
a3dda8b03c | ||
|
|
d64f0c52be |
2
.github/workflows/phpunit.yml
vendored
2
.github/workflows/phpunit.yml
vendored
@@ -60,7 +60,7 @@ jobs:
|
|||||||
php artisan passport:keys
|
php artisan passport:keys
|
||||||
|
|
||||||
- name: "Run PHPUnit"
|
- name: "Run PHPUnit"
|
||||||
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
run: php artisan test --parallel --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
||||||
|
|
||||||
- name: "Upload coverage reports to Codecov"
|
- name: "Upload coverage reports to Codecov"
|
||||||
uses: codecov/codecov-action@v5.4.2
|
uses: codecov/codecov-action@v5.4.2
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ class TimeEntryController extends Controller
|
|||||||
'start' => $request->getStart()->timezone($timezone),
|
'start' => $request->getStart()->timezone($timezone),
|
||||||
'end' => $request->getEnd()->timezone($timezone),
|
'end' => $request->getEnd()->timezone($timezone),
|
||||||
'localization' => $localizationService,
|
'localization' => $localizationService,
|
||||||
|
'showBillableRate' => $showBillableRate,
|
||||||
]);
|
]);
|
||||||
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-index/pdf-footer.blade.php'));
|
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-index/pdf-footer.blade.php'));
|
||||||
if ($footerViewFile === false) {
|
if ($footerViewFile === false) {
|
||||||
@@ -428,6 +429,7 @@ class TimeEntryController extends Controller
|
|||||||
'end' => $request->getEnd()->timezone($timezone),
|
'end' => $request->getEnd()->timezone($timezone),
|
||||||
'debug' => $debug,
|
'debug' => $debug,
|
||||||
'localization' => $localizationService,
|
'localization' => $localizationService,
|
||||||
|
'showBillableRate' => $showBillableRate,
|
||||||
]);
|
]);
|
||||||
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-aggregate/pdf-footer.blade.php'));
|
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-aggregate/pdf-footer.blade.php'));
|
||||||
if ($footerViewFile === false) {
|
if ($footerViewFile === false) {
|
||||||
@@ -456,7 +458,7 @@ class TimeEntryController extends Controller
|
|||||||
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
->putFileAs($folderPath, new File($tempFolder->path($filenameTemp)), $filename);
|
||||||
} else {
|
} else {
|
||||||
Excel::store(
|
Excel::store(
|
||||||
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup),
|
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup, $showBillableRate),
|
||||||
$path,
|
$path,
|
||||||
config('filesystems.private'),
|
config('filesystems.private'),
|
||||||
$format->getExportPackageType(),
|
$format->getExportPackageType(),
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||||||
|
|
||||||
class BaseFormRequest extends FormRequest
|
class BaseFormRequest extends FormRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $bigInt
|
|
||||||
* @return list<string>
|
* @return list<string>
|
||||||
*/
|
*/
|
||||||
protected function moneyRules(bool $bigInt = false): array
|
protected function moneyRules(bool $bigInt = false): array
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
|
|||||||
|
|
||||||
private TimeEntryAggregationType $subGroup;
|
private TimeEntryAggregationType $subGroup;
|
||||||
|
|
||||||
|
private bool $showBillableRate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{
|
* @param array{
|
||||||
* grouped_type: string|null,
|
* grouped_type: string|null,
|
||||||
@@ -66,13 +68,14 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
|
|||||||
* cost: int|null
|
* cost: int|null
|
||||||
* } $data
|
* } $data
|
||||||
*/
|
*/
|
||||||
public function __construct(array $data, ExportFormat $exportFormat, string $currency, TimeEntryAggregationType $group, TimeEntryAggregationType $subGroup)
|
public function __construct(array $data, ExportFormat $exportFormat, string $currency, TimeEntryAggregationType $group, TimeEntryAggregationType $subGroup, bool $showBillableRate)
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->exportFormat = $exportFormat;
|
$this->exportFormat = $exportFormat;
|
||||||
$this->currency = $currency;
|
$this->currency = $currency;
|
||||||
$this->group = $group;
|
$this->group = $group;
|
||||||
$this->subGroup = $subGroup;
|
$this->subGroup = $subGroup;
|
||||||
|
$this->showBillableRate = $showBillableRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view(): View
|
public function view(): View
|
||||||
@@ -83,6 +86,7 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
|
|||||||
'group' => $this->group,
|
'group' => $this->group,
|
||||||
'subGroup' => $this->subGroup,
|
'subGroup' => $this->subGroup,
|
||||||
'exportFormat' => $this->exportFormat,
|
'exportFormat' => $this->exportFormat,
|
||||||
|
'showBillableRate' => $this->showBillableRate,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { h, ref } from 'vue';
|
|||||||
import type { CreateReportBodyProperties } from '@/packages/api/src';
|
import type { CreateReportBodyProperties } from '@/packages/api/src';
|
||||||
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
|
||||||
import UpgradeModal from '@/Components/Common/UpgradeModal.vue';
|
import UpgradeModal from '@/Components/Common/UpgradeModal.vue';
|
||||||
|
import { canCreateReports } from '@/utils/permissions';
|
||||||
defineProps<{
|
defineProps<{
|
||||||
reportProperties: CreateReportBodyProperties;
|
reportProperties: CreateReportBodyProperties;
|
||||||
}>();
|
}>();
|
||||||
@@ -33,7 +34,10 @@ function onSaveReportClick() {
|
|||||||
<strong>Sharable Reports</strong> is only available in solidtime
|
<strong>Sharable Reports</strong> is only available in solidtime
|
||||||
Professional.
|
Professional.
|
||||||
</UpgradeModal>
|
</UpgradeModal>
|
||||||
<SecondaryButton :icon="SaveIcon" @click="onSaveReportClick"
|
<SecondaryButton
|
||||||
|
v-if="canCreateReports()"
|
||||||
|
:icon="SaveIcon"
|
||||||
|
@click="onSaveReportClick"
|
||||||
>Save Report</SecondaryButton
|
>Save Report</SecondaryButton
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -107,6 +107,10 @@ function getFilterAttributes(): AggregatedTimeEntriesQueryParams {
|
|||||||
: undefined,
|
: undefined,
|
||||||
tag_ids: selectedTags.value.length > 0 ? selectedTags.value : undefined,
|
tag_ids: selectedTags.value.length > 0 ? selectedTags.value : undefined,
|
||||||
billable: billable.value !== null ? billable.value : undefined,
|
billable: billable.value !== null ? billable.value : undefined,
|
||||||
|
member_id:
|
||||||
|
getCurrentRole() === 'employee'
|
||||||
|
? getCurrentMembershipId()
|
||||||
|
: undefined,
|
||||||
};
|
};
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,4 +125,6 @@ export function canViewAllTimeEntries() {
|
|||||||
export function canViewInvoices() {
|
export function canViewInvoices() {
|
||||||
return currentUserHasPermission('invoices:view');
|
return currentUserHasPermission('invoices:view');
|
||||||
}
|
}
|
||||||
|
export function canCreateReports() {
|
||||||
|
return currentUserHasPermission('reports:create');
|
||||||
|
}
|
||||||
|
|||||||
@@ -152,12 +152,13 @@
|
|||||||
<div
|
<div
|
||||||
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }} </div>
|
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }} </div>
|
||||||
</div>
|
</div>
|
||||||
|
@if($showBillableRate)
|
||||||
<div style="padding: 8px 12px; border-radius: 8px;">
|
<div style="padding: 8px 12px; border-radius: 8px;">
|
||||||
<div style="color: #71717a; font-weight: 600;">Total cost</div>
|
<div style="color: #71717a; font-weight: 600;">Total cost</div>
|
||||||
<div
|
<div
|
||||||
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }} </div>
|
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }} </div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div id="main-chart" style="width: 700px; height: 300px; margin: 20px auto;"></div>
|
<div id="main-chart" style="width: 700px; height: 300px; margin: 20px auto;"></div>
|
||||||
|
|
||||||
@@ -177,7 +178,9 @@
|
|||||||
{{ $group->description() }}
|
{{ $group->description() }}
|
||||||
</th>
|
</th>
|
||||||
<th>Duration</th>
|
<th>Duration</th>
|
||||||
|
@if($showBillableRate)
|
||||||
<th style="text-align: right;">Cost</th>
|
<th style="text-align: right;">Cost</th>
|
||||||
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@foreach($aggregatedData['grouped_data'] as $group1Entry)
|
@foreach($aggregatedData['grouped_data'] as $group1Entry)
|
||||||
@@ -188,23 +191,21 @@
|
|||||||
}};">
|
}};">
|
||||||
</div>
|
</div>
|
||||||
<span style="padding-left: 8px;">
|
<span style="padding-left: 8px;">
|
||||||
|
|
||||||
@if($group->is(\App\Enums\TimeEntryAggregationType::Billable))
|
@if($group->is(\App\Enums\TimeEntryAggregationType::Billable))
|
||||||
{{ $group1Entry['key'] === '1' ? 'Billable' : 'Non-billable' }}
|
{{ $group1Entry['key'] === '1' ? 'Billable' : 'Non-billable' }}
|
||||||
@else
|
@else
|
||||||
{{ $group1Entry['description'] ?? $group1Entry['key'] ?? 'No '.Str::lower($group->description()) }}
|
{{ $group1Entry['description'] ?? $group1Entry['key'] ?? 'No '.Str::lower($group->description()) }}
|
||||||
@endif
|
@endif
|
||||||
|
</span>
|
||||||
|
|
||||||
</span>
|
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: left;">
|
<td style="text-align: left;">
|
||||||
{{ $localization->formatInterval(CarbonInterval::seconds($group1Entry['seconds'])) }}
|
{{ $localization->formatInterval(CarbonInterval::seconds($group1Entry['seconds'])) }}
|
||||||
</td>
|
</td>
|
||||||
|
@if($showBillableRate)
|
||||||
<td style="text-align: right;">
|
<td style="text-align: right;">
|
||||||
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($group1Entry['cost'], 2)->__toString(), $currency)) }}
|
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($group1Entry['cost'], 2)->__toString(), $currency)) }}
|
||||||
</td>
|
</td>
|
||||||
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
<tfoot>
|
<tfoot>
|
||||||
@@ -215,9 +216,11 @@
|
|||||||
<td style="font-weight: 500;color: #18181b;">
|
<td style="font-weight: 500;color: #18181b;">
|
||||||
{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }}
|
{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }}
|
||||||
</td>
|
</td>
|
||||||
|
@if($showBillableRate)
|
||||||
<td style="text-align: right; font-weight: 500;color: #18181b;">
|
<td style="text-align: right; font-weight: 500;color: #18181b;">
|
||||||
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }}
|
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }}
|
||||||
</td>
|
</td>
|
||||||
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
@@ -253,9 +256,11 @@
|
|||||||
<th>
|
<th>
|
||||||
Duration (h)
|
Duration (h)
|
||||||
</th>
|
</th>
|
||||||
|
@if($showBillableRate)
|
||||||
<th>
|
<th>
|
||||||
Cost
|
Cost
|
||||||
</th>
|
</th>
|
||||||
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -282,13 +287,17 @@
|
|||||||
<td>
|
<td>
|
||||||
{{ $localization->formatNumber($duration->totalHours) }}
|
{{ $localization->formatNumber($duration->totalHours) }}
|
||||||
</td>
|
</td>
|
||||||
|
@if($showBillableRate)
|
||||||
<td>
|
<td>
|
||||||
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->__toString(), $currency)) }}
|
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->__toString(), $currency)) }}
|
||||||
</td>
|
</td>
|
||||||
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
@php
|
@php
|
||||||
$totalDuration += $group2Entry['seconds'];
|
$totalDuration += $group2Entry['seconds'];
|
||||||
$totalCost += $group2Entry['cost'];
|
if ($showBillableRate) {
|
||||||
|
$totalCost += $group2Entry['cost'];
|
||||||
|
}
|
||||||
@endphp
|
@endphp
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -62,9 +62,11 @@
|
|||||||
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
|
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
|
||||||
{{ round($duration->totalHours, 2) }}
|
{{ round($duration->totalHours, 2) }}
|
||||||
</td>
|
</td>
|
||||||
|
@if($showBillableRate)
|
||||||
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
|
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
|
||||||
{{ round(BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->toFloat(), 2) }}
|
{{ round(BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->toFloat(), 2) }}
|
||||||
</td>
|
</td>
|
||||||
|
@endif
|
||||||
@else
|
@else
|
||||||
@if ($group === TimeEntryAggregationType::Billable)
|
@if ($group === TimeEntryAggregationType::Billable)
|
||||||
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
|
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_STRING }}">
|
||||||
@@ -92,16 +94,20 @@
|
|||||||
data-format="{{ NumberFormat::FORMAT_NUMBER_00 }}">
|
data-format="{{ NumberFormat::FORMAT_NUMBER_00 }}">
|
||||||
{{ $duration->totalHours }}
|
{{ $duration->totalHours }}
|
||||||
</td>
|
</td>
|
||||||
|
@if($showBillableRate)
|
||||||
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_NUMERIC }}"
|
<td style="border: 1px solid black;" data-type="{{ DataType::TYPE_NUMERIC }}"
|
||||||
data-format="{{ NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1 }}">
|
data-format="{{ NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1 }}">
|
||||||
{{ BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->__toString() }}
|
{{ BigDecimal::ofUnscaledValue($group2Entry['cost'], 2)->__toString() }}
|
||||||
</td>
|
</td>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
@php
|
@php
|
||||||
++$counter;
|
++$counter;
|
||||||
$totalDuration += $group2Entry['seconds'];
|
$totalDuration += $group2Entry['seconds'];
|
||||||
$totalCost += $group2Entry['cost'];
|
if ($showBillableRate) {
|
||||||
|
$totalCost += $group2Entry['cost'];
|
||||||
|
}
|
||||||
@endphp
|
@endphp
|
||||||
@endforeach
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
@@ -120,9 +126,11 @@
|
|||||||
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_STRING }}">
|
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_STRING }}">
|
||||||
{{ round($totalDurationInterval->totalHours, 2) }}
|
{{ round($totalDurationInterval->totalHours, 2) }}
|
||||||
</td>
|
</td>
|
||||||
|
@if($showBillableRate)
|
||||||
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_STRING }}">
|
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_STRING }}">
|
||||||
{{ round(BigDecimal::ofUnscaledValue($totalCost, 2)->toFloat(), 2) }}
|
{{ round(BigDecimal::ofUnscaledValue($totalCost, 2)->toFloat(), 2) }}
|
||||||
</td>
|
</td>
|
||||||
|
@endif
|
||||||
@else
|
@else
|
||||||
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_FORMULA }}"
|
<td style="border: 1px solid black; font-weight: bold;" data-type="{{ DataType::TYPE_FORMULA }}"
|
||||||
data-format="[hh]:mm:ss">
|
data-format="[hh]:mm:ss">
|
||||||
|
|||||||
@@ -140,12 +140,14 @@
|
|||||||
<div
|
<div
|
||||||
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }} </div>
|
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatInterval(CarbonInterval::seconds($aggregatedData['seconds'])) }} </div>
|
||||||
</div>
|
</div>
|
||||||
|
@if($showBillableRate)
|
||||||
<div style="padding: 8px 12px; border-radius: 8px;">
|
<div style="padding: 8px 12px; border-radius: 8px;">
|
||||||
<div style="color: #71717a; font-weight: 600;">Total cost</div>
|
<div style="color: #71717a; font-weight: 600;">Total cost</div>
|
||||||
<div
|
<div style="font-size: 24px; font-weight: 500; margin-top: 2px;">
|
||||||
style="font-size: 24px; font-weight: 500; margin-top: 2px;">{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }} </div>
|
{{ $localization->formatCurrency(Money::of(BigDecimal::ofUnscaledValue($aggregatedData['cost'], 2)->__toString(), $currency)) }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<table style="width: 100%;">
|
<table style="width: 100%;">
|
||||||
|
|||||||
@@ -56,10 +56,12 @@ abstract class TestCaseWithDatabase extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @return object{user: User, organization: Organization, member: Member, owner: User, ownerMember: Member}
|
* @return object{user: User, organization: Organization, member: Member, owner: User, ownerMember: Member}
|
||||||
*/
|
*/
|
||||||
public function createUserWithRole(Role $role): object
|
public function createUserWithRole(Role $role, bool $employeesCanSeeBillableRates = false): object
|
||||||
{
|
{
|
||||||
$owner = User::factory()->create();
|
$owner = User::factory()->create();
|
||||||
$organization = Organization::factory()->withOwner($owner)->create();
|
$organization = Organization::factory()->withOwner($owner)->create([
|
||||||
|
'employees_can_see_billable_rates' => $employeesCanSeeBillableRates,
|
||||||
|
]);
|
||||||
$ownerMember = Member::factory()->forUser($owner)->forOrganization($organization)->role(Role::Owner)->create();
|
$ownerMember = Member::factory()->forUser($owner)->forOrganization($organization)->role(Role::Owner)->create();
|
||||||
$owner->currentOrganization()->associate($organization);
|
$owner->currentOrganization()->associate($organization);
|
||||||
$owner->save();
|
$owner->save();
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ use Illuminate\Support\Facades\Artisan;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use PHPUnit\Framework\Attributes\CoversClass;
|
use PHPUnit\Framework\Attributes\CoversClass;
|
||||||
use PHPUnit\Framework\Attributes\UsesClass;
|
use PHPUnit\Framework\Attributes\UsesClass;
|
||||||
use Tests\TestCase;
|
use Tests\TestCaseWithDatabase;
|
||||||
|
|
||||||
#[CoversClass(SelfHostTelemetryCommand::class)]
|
#[CoversClass(SelfHostTelemetryCommand::class)]
|
||||||
#[CoversClass(ApiService::class)]
|
#[CoversClass(ApiService::class)]
|
||||||
#[UsesClass(SelfHostTelemetryCommand::class)]
|
#[UsesClass(SelfHostTelemetryCommand::class)]
|
||||||
class SelfHostTelemetryCommandTest extends TestCase
|
class SelfHostTelemetryCommandTest extends TestCaseWithDatabase
|
||||||
{
|
{
|
||||||
public function test_telemetry_sends_data_to_telemetry_endpoint_of_solidtime_cloud(): void
|
public function test_telemetry_sends_data_to_telemetry_endpoint_of_solidtime_cloud(): void
|
||||||
{
|
{
|
||||||
@@ -30,9 +30,12 @@ class SelfHostTelemetryCommandTest extends TestCase
|
|||||||
$exitCode = $this->withoutMockingConsoleOutput()->artisan('self-host:telemetry');
|
$exitCode = $this->withoutMockingConsoleOutput()->artisan('self-host:telemetry');
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
$this->assertSame(Command::SUCCESS, $exitCode);
|
|
||||||
$output = Artisan::output();
|
$output = Artisan::output();
|
||||||
$this->assertSame('', $output);
|
$this->assertSame('', $output);
|
||||||
|
if ($exitCode !== Command::SUCCESS) {
|
||||||
|
dump($output);
|
||||||
|
}
|
||||||
|
$this->assertSame(Command::SUCCESS, $exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_telemetry_sends_fails_gracefully_if_response_has_error_status_code(): void
|
public function test_telemetry_sends_fails_gracefully_if_response_has_error_status_code(): void
|
||||||
|
|||||||
@@ -686,6 +686,10 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
|||||||
'time-entries:view:all',
|
'time-entries:view:all',
|
||||||
]);
|
]);
|
||||||
Passport::actingAs($data->user);
|
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();
|
$this->actAsOrganizationWithSubscription();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
@@ -700,6 +704,192 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
|||||||
$this->assertResponseCode($response, 200);
|
$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
|
public function test_aggregate_export_endpoints_fails_if_user_no_permission_to_view_time_entries(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -815,6 +1005,58 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
|||||||
$this->assertResponseCode($response, 200);
|
$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
|
public function test_aggregate_export_endpoints_can_create_a_xlsx_report(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -842,6 +1084,58 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
|||||||
$this->assertResponseCode($response, 200);
|
$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
|
public function test_aggregate_export_endpoints_can_create_a_ods_report(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -869,6 +1163,58 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
|||||||
$this->assertResponseCode($response, 200);
|
$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
|
public function test_aggregate_export_endpoint_fails_if_pdf_renderer_is_not_configured_but_a_user_want_a_pdf_report(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
@@ -927,6 +1273,60 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
|||||||
$this->assertResponseCode($response, 200);
|
$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
|
public function test_aggregate_endpoint_fails_if_user_has_only_access_to_own_time_entries_but_does_not_filter_for_this(): void
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|||||||
Reference in New Issue
Block a user