@@ -86,7 +86,8 @@ public function index(Organization $organization, TimeEntryIndexRequest $request
8686 $ this ->checkPermission ($ organization , 'time-entries:view:all ' );
8787 }
8888
89- $ timeEntriesQuery = $ this ->getTimeEntriesQuery ($ organization , $ request , $ member );
89+ $ canAccessPremiumFeatures = $ this ->canAccessPremiumFeatures ($ organization );
90+ $ timeEntriesQuery = $ this ->getTimeEntriesQuery ($ organization , $ request , $ member , $ canAccessPremiumFeatures );
9091
9192 $ totalCount = $ timeEntriesQuery ->count ();
9293
@@ -140,13 +141,15 @@ public function index(Organization $organization, TimeEntryIndexRequest $request
140141 /**
141142 * @return Builder<TimeEntry>
142143 */
143- private function getTimeEntriesQuery (Organization $ organization , TimeEntryIndexRequest |TimeEntryIndexExportRequest $ request , ?Member $ member ): Builder
144+ private function getTimeEntriesQuery (Organization $ organization , TimeEntryIndexRequest |TimeEntryIndexExportRequest $ request , ?Member $ member, bool $ canAccessPremiumFeatures ): Builder
144145 {
145146 $ select = TimeEntry::SELECT_COLUMNS ;
146- if ($ request ->getRoundingType () !== null && $ request ->getRoundingMinutes () !== null ) {
147+ $ roundingType = $ canAccessPremiumFeatures ? $ request ->getRoundingType () : null ;
148+ $ roundingMinutes = $ canAccessPremiumFeatures ? $ request ->getRoundingMinutes () : null ;
149+ if ($ roundingType !== null && $ roundingMinutes !== null ) {
147150 $ select = array_diff ($ select , ['start ' , 'end ' ]);
148- $ select [] = DB ::raw (app (TimeEntryService::class)->getStartSelectRawForRounding ($ request -> getRoundingType () , $ request -> getRoundingMinutes () ).' as start ' );
149- $ select [] = DB ::raw (app (TimeEntryService::class)->getEndSelectRawForRounding ($ request -> getRoundingType () , $ request -> getRoundingMinutes () ).' as end ' );
151+ $ select [] = DB ::raw (app (TimeEntryService::class)->getStartSelectRawForRounding ($ roundingType , $ roundingMinutes ).' as start ' );
152+ $ select [] = DB ::raw (app (TimeEntryService::class)->getEndSelectRawForRounding ($ roundingType , $ roundingMinutes ).' as end ' );
150153 }
151154 $ timeEntriesQuery = TimeEntry::query ()
152155 ->whereBelongsTo ($ organization , 'organization ' )
@@ -184,18 +187,19 @@ public function indexExport(Organization $organization, TimeEntryIndexExportRequ
184187 } else {
185188 $ this ->checkPermission ($ organization , 'time-entries:view:all ' );
186189 }
190+ $ canAccessPremiumFeatures = $ this ->canAccessPremiumFeatures ($ organization );
187191 $ debug = $ request ->getDebug ();
188192 $ format = $ request ->getFormatValue ();
189- if ($ format === ExportFormat::PDF && ! $ this -> canAccessPremiumFeatures ( $ organization ) ) {
193+ if ($ format === ExportFormat::PDF && ! $ canAccessPremiumFeatures ) {
190194 throw new FeatureIsNotAvailableInFreePlanApiException ;
191195 }
192196 $ user = $ this ->user ();
193197 $ timezone = $ user ->timezone ;
194198 $ showBillableRate = $ this ->member ($ organization )->role !== Role::Employee->value || $ organization ->employees_can_see_billable_rates ;
195- $ roundingType = $ request ->getRoundingType ();
196- $ roundingMinutes = $ request ->getRoundingMinutes ();
199+ $ roundingType = $ canAccessPremiumFeatures ? $ request ->getRoundingType () : null ;
200+ $ roundingMinutes = $ canAccessPremiumFeatures ? $ request ->getRoundingMinutes () : null ;
197201
198- $ timeEntriesQuery = $ this ->getTimeEntriesQuery ($ organization , $ request , $ member );
202+ $ timeEntriesQuery = $ this ->getTimeEntriesQuery ($ organization , $ request , $ member, $ canAccessPremiumFeatures );
199203 $ timeEntriesQuery ->with ([
200204 'task ' ,
201205 'client ' ,
@@ -332,14 +336,15 @@ public function aggregate(Organization $organization, TimeEntryAggregateRequest
332336 } else {
333337 $ this ->checkPermission ($ organization , 'time-entries:view:all ' );
334338 }
339+ $ canAccessPremiumFeatures = $ this ->canAccessPremiumFeatures ($ organization );
335340 $ user = $ this ->user ();
336341 $ showBillableRate = $ this ->member ($ organization )->role !== Role::Employee->value || $ organization ->employees_can_see_billable_rates ;
337342
338343 $ group1Type = $ request ->getGroup ();
339344 $ group2Type = $ request ->getSubGroup ();
340345 $ timeEntriesAggregateQuery = $ this ->getTimeEntriesAggregateQuery ($ organization , $ request , $ member );
341- $ roundingType = $ request ->getRoundingType ();
342- $ roundingMinutes = $ request ->getRoundingMinutes ();
346+ $ roundingType = $ canAccessPremiumFeatures ? $ request ->getRoundingType () : null ;
347+ $ roundingMinutes = $ canAccessPremiumFeatures ? $ request ->getRoundingMinutes () : null ;
343348
344349 $ aggregatedData = $ timeEntryAggregationService ->getAggregatedTimeEntries (
345350 $ timeEntriesAggregateQuery ,
@@ -380,6 +385,7 @@ public function aggregateExport(Organization $organization, TimeEntryAggregateEx
380385 } else {
381386 $ this ->checkPermission ($ organization , 'time-entries:view:all ' );
382387 }
388+ $ canAccessPremiumFeatures = $ this ->canAccessPremiumFeatures ($ organization );
383389 $ format = $ request ->getFormatValue ();
384390 if ($ format === ExportFormat::PDF && ! $ this ->canAccessPremiumFeatures ($ organization )) {
385391 throw new FeatureIsNotAvailableInFreePlanApiException ;
@@ -391,8 +397,8 @@ public function aggregateExport(Organization $organization, TimeEntryAggregateEx
391397 $ group = $ request ->getGroup ();
392398 $ subGroup = $ request ->getSubGroup ();
393399 $ timeEntriesAggregateQuery = $ this ->getTimeEntriesAggregateQuery ($ organization , $ request , $ member );
394- $ roundingType = $ request ->getRoundingType ();
395- $ roundingMinutes = $ request ->getRoundingMinutes ();
400+ $ roundingType = $ canAccessPremiumFeatures ? $ request ->getRoundingType () : null ;
401+ $ roundingMinutes = $ canAccessPremiumFeatures ? $ request ->getRoundingMinutes () : null ;
396402
397403 $ aggregatedData = $ timeEntryAggregationService ->getAggregatedTimeEntriesWithDescriptions (
398404 $ timeEntriesAggregateQuery ->clone (),
0 commit comments