|
6 | 6 |
|
7 | 7 | use App\Enums\ExportFormat; |
8 | 8 | use App\Enums\Role; |
| 9 | +use App\Enums\TimeEntryType; |
9 | 10 | use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException; |
10 | 11 | use App\Exceptions\Api\OverlappingTimeEntryApiException; |
11 | 12 | use App\Exceptions\Api\PdfRendererIsNotConfiguredException; |
@@ -208,6 +209,7 @@ private function getTimeEntriesQuery(Organization $organization, TimeEntryIndexR |
208 | 209 | $filter->addTaskIdsFilter($request->input('task_ids')); |
209 | 210 | $filter->addClientIdsFilter($request->input('client_ids')); |
210 | 211 | $filter->addBillableFilter($request->input('billable')); |
| 212 | + $filter->addTypeFilter($request->input('type')); |
211 | 213 |
|
212 | 214 | return $filter->get(); |
213 | 215 | } |
@@ -564,6 +566,7 @@ private function getTimeEntriesAggregateQuery(Organization $organization, TimeEn |
564 | 566 | $filter->addTaskIdsFilter($request->input('task_ids')); |
565 | 567 | $filter->addClientIdsFilter($request->input('client_ids')); |
566 | 568 | $filter->addBillableFilter($request->input('billable')); |
| 569 | + $filter->addTypeFilter($request->input('type')); |
567 | 570 |
|
568 | 571 | return $filter->get(); |
569 | 572 | } |
@@ -746,6 +749,19 @@ public function updateMultiple(Organization $organization, TimeEntryUpdateMultip |
746 | 749 | continue; |
747 | 750 |
|
748 | 751 | } |
| 752 | + // Changing time entries to Break entries is only allowed when breaks are enabled in the org settings |
| 753 | + $resultingType = isset($changes['type']) ? TimeEntryType::from($changes['type']) : $timeEntry->type; |
| 754 | + if ($resultingType === TimeEntryType::Break && $timeEntry->type !== TimeEntryType::Break && ! $organization->breaks_enabled) { |
| 755 | + $error->push($id); |
| 756 | + |
| 757 | + continue; |
| 758 | + } |
| 759 | + // Break entries can not be billable, have tags or belong to a project/task (see TimeEntry::booted) |
| 760 | + if ($resultingType === TimeEntryType::Break && ($project !== null || $task !== null || $request->boolean('changes.billable') || count($changes['tags'] ?? []) > 0)) { |
| 761 | + $error->push($id); |
| 762 | + |
| 763 | + continue; |
| 764 | + } |
749 | 765 | $oldProject = $timeEntry->project; |
750 | 766 | $oldTask = $timeEntry->task; |
751 | 767 |
|
|
0 commit comments