mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-08 05:43:18 +01:00
Compare commits
1 Commits
feature/bi
...
feature/vo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1fbf7b87bb |
@@ -5,8 +5,7 @@ APP_KEY=base64:UNQNf1SXeASNkWux01Rj8EnHYx8FO0kAxWNDwktclkk=
|
|||||||
APP_DEBUG=true
|
APP_DEBUG=true
|
||||||
APP_URL=https://solidtime.test
|
APP_URL=https://solidtime.test
|
||||||
APP_FORCE_HTTPS=false
|
APP_FORCE_HTTPS=false
|
||||||
# Supported values: on, off, invite-only (true/false are supported for backwards compatibility)
|
APP_ENABLE_REGISTRATION=true
|
||||||
APP_ENABLE_REGISTRATION=on
|
|
||||||
SUPER_ADMINS=admin@example.com
|
SUPER_ADMINS=admin@example.com
|
||||||
PAGINATION_PER_PAGE_DEFAULT=500
|
PAGINATION_PER_PAGE_DEFAULT=500
|
||||||
|
|
||||||
|
|||||||
12
.github/VOUCHED.td
vendored
12
.github/VOUCHED.td
vendored
@@ -14,14 +14,10 @@
|
|||||||
# Seeded 2026-07-25 from the authors of every merged pull request.
|
# Seeded 2026-07-25 from the authors of every merged pull request.
|
||||||
|
|
||||||
agross
|
agross
|
||||||
akolenda
|
|
||||||
bufferhead-code
|
|
||||||
candideu
|
candideu
|
||||||
kasparrosin
|
KasparRosin
|
||||||
korridor
|
korridor
|
||||||
nikbucher tasks table sorting
|
Onatcer
|
||||||
onatcer
|
ShrootBuck
|
||||||
shrootbuck
|
smileBeda
|
||||||
smilebeda
|
|
||||||
thespyder
|
|
||||||
utlark
|
utlark
|
||||||
|
|||||||
4
.github/workflows/build-onpremise.yml
vendored
4
.github/workflows/build-onpremise.yml
vendored
@@ -141,7 +141,7 @@ jobs:
|
|||||||
${{ env.DOCKER_REPO }}
|
${{ env.DOCKER_REPO }}
|
||||||
|
|
||||||
- name: "Login to solidtime OnPremise Registry"
|
- name: "Login to solidtime OnPremise Registry"
|
||||||
uses: docker/login-action@v4.5.2
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: registry.on-premise.solidtime.io
|
registry: registry.on-premise.solidtime.io
|
||||||
username: ${{ secrets.ONPREMISE_USERNAME }}
|
username: ${{ secrets.ONPREMISE_USERNAME }}
|
||||||
@@ -195,7 +195,7 @@ jobs:
|
|||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: "Login to solidtime OnPremise Registry"
|
- name: "Login to solidtime OnPremise Registry"
|
||||||
uses: docker/login-action@v4.5.2
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: registry.on-premise.solidtime.io
|
registry: registry.on-premise.solidtime.io
|
||||||
username: ${{ secrets.ONPREMISE_USERNAME }}
|
username: ${{ secrets.ONPREMISE_USERNAME }}
|
||||||
|
|||||||
2
.github/workflows/build-private.yml
vendored
2
.github/workflows/build-private.yml
vendored
@@ -177,7 +177,7 @@ jobs:
|
|||||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||||
|
|
||||||
- name: "Login to GitHub Container Registry"
|
- name: "Login to GitHub Container Registry"
|
||||||
uses: docker/login-action@v4.5.2
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: rg.fr-par.scw.cloud/solidtime
|
registry: rg.fr-par.scw.cloud/solidtime
|
||||||
username: nologin
|
username: nologin
|
||||||
|
|||||||
8
.github/workflows/build-public.yml
vendored
8
.github/workflows/build-public.yml
vendored
@@ -117,13 +117,13 @@ jobs:
|
|||||||
${{ env.GHCR_REPO }}
|
${{ env.GHCR_REPO }}
|
||||||
|
|
||||||
- name: "Login to Docker Hub Container Registry"
|
- name: "Login to Docker Hub Container Registry"
|
||||||
uses: docker/login-action@v4.5.2
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: "Login to GitHub Container Registry"
|
- name: "Login to GitHub Container Registry"
|
||||||
uses: docker/login-action@v4.5.2
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -177,13 +177,13 @@ jobs:
|
|||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: "Login to Docker Hub"
|
- name: "Login to Docker Hub"
|
||||||
uses: docker/login-action@v4.5.2
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: "Login to GHCR"
|
- name: "Login to GHCR"
|
||||||
uses: docker/login-action@v4.5.2
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Actions\Fortify;
|
namespace App\Actions\Fortify;
|
||||||
|
|
||||||
use App\Enums\RegistrationMode;
|
|
||||||
use App\Enums\Weekday;
|
use App\Enums\Weekday;
|
||||||
use App\Events\NewsletterRegistered;
|
use App\Events\NewsletterRegistered;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Service\InvitationService;
|
|
||||||
use App\Service\IpLookup\IpLookupServiceContract;
|
use App\Service\IpLookup\IpLookupServiceContract;
|
||||||
use App\Service\TimezoneService;
|
use App\Service\TimezoneService;
|
||||||
use App\Service\UserService;
|
use App\Service\UserService;
|
||||||
@@ -33,14 +31,13 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
*/
|
*/
|
||||||
public function create(array $input): User
|
public function create(array $input): User
|
||||||
{
|
{
|
||||||
$registrationMode = RegistrationMode::fromConfig(config('app.enable_registration'));
|
if (! config('app.enable_registration')) {
|
||||||
if ($registrationMode === RegistrationMode::Off) {
|
|
||||||
throw ValidationException::withMessages([
|
throw ValidationException::withMessages([
|
||||||
'email' => [__('Registration is disabled.')],
|
'email' => [__('Registration is disabled.')],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$validated = Validator::make($input, [
|
Validator::make($input, [
|
||||||
'name' => [
|
'name' => [
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
@@ -63,20 +60,6 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
],
|
],
|
||||||
])->validate();
|
])->validate();
|
||||||
|
|
||||||
if ($registrationMode === RegistrationMode::InviteOnly) {
|
|
||||||
$invitationService = app(InvitationService::class);
|
|
||||||
$email = (string) $validated['email'];
|
|
||||||
if (! $invitationService->hasAcceptedInvitationForEmail($email)) {
|
|
||||||
$message = $invitationService->hasPendingInvitationForEmail($email)
|
|
||||||
? __('Please accept the organization invitation sent to your email address before registering.')
|
|
||||||
: __('Registration is only available to invited users.');
|
|
||||||
|
|
||||||
throw ValidationException::withMessages([
|
|
||||||
'email' => [$message],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$timezone = null;
|
$timezone = null;
|
||||||
if (array_key_exists('timezone', $input) && is_string($input['timezone'])) {
|
if (array_key_exists('timezone', $input) && is_string($input['timezone'])) {
|
||||||
if (app(TimezoneService::class)->isValid($input['timezone'])) {
|
if (app(TimezoneService::class)->isValid($input['timezone'])) {
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Auth;
|
|
||||||
|
|
||||||
use Illuminate\Auth\EloquentUserProvider;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User provider that only resolves non-placeholder users.
|
|
||||||
*
|
|
||||||
* Placeholder users are created by imports and when members are removed from an
|
|
||||||
* organization. They can share an email address with a real user, so resolving a user by
|
|
||||||
* email can return a placeholder instead of the real account. The login flow filters them
|
|
||||||
* out explicitly, but the password broker and the guard credential checks (for example the
|
|
||||||
* password confirmation) resolve users through the configured user provider.
|
|
||||||
*
|
|
||||||
* Registered as the "eloquent" provider driver in the AuthServiceProvider, so it replaces the
|
|
||||||
* built-in one for every provider in config/auth.php.
|
|
||||||
*/
|
|
||||||
class ActiveUserProvider extends EloquentUserProvider
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param Model|null $model
|
|
||||||
* @return Builder<Model>
|
|
||||||
*/
|
|
||||||
#[\Override]
|
|
||||||
protected function newModelQuery($model = null): Builder
|
|
||||||
{
|
|
||||||
$query = parent::newModelQuery($model);
|
|
||||||
$query->getQuery()->where('is_placeholder', '=', false);
|
|
||||||
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -51,8 +51,7 @@ class TimeEntrySendStillRunningMailsCommand extends Command
|
|||||||
])
|
])
|
||||||
->whereHas('user', function (Builder $query): void {
|
->whereHas('user', function (Builder $query): void {
|
||||||
/** @var Builder<User> $query */
|
/** @var Builder<User> $query */
|
||||||
$query->where('is_placeholder', '=', false)
|
$query->where('is_placeholder', '=', false);
|
||||||
->where('send_time_entry_still_running_email', '=', true);
|
|
||||||
})
|
})
|
||||||
->orderBy('created_at', 'asc')
|
->orderBy('created_at', 'asc')
|
||||||
->chunk(500, function (Collection $timeEntries) use ($dryRun, &$sentMails): void {
|
->chunk(500, function (Collection $timeEntries) use ($dryRun, &$sentMails): void {
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
enum RegistrationMode: string
|
|
||||||
{
|
|
||||||
case On = 'on';
|
|
||||||
case InviteOnly = 'invite-only';
|
|
||||||
case Off = 'off';
|
|
||||||
|
|
||||||
public static function fromConfig(mixed $value): self
|
|
||||||
{
|
|
||||||
if ($value === true) {
|
|
||||||
return self::On;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($value === false || $value === null) {
|
|
||||||
return self::Off;
|
|
||||||
}
|
|
||||||
|
|
||||||
return match (strtolower(trim((string) $value))) {
|
|
||||||
'1', 'on', 'true' => self::On,
|
|
||||||
'invite-only' => self::InviteOnly,
|
|
||||||
default => self::Off,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,6 @@ enum TimeEntryAggregationType: string
|
|||||||
case Billable = 'billable';
|
case Billable = 'billable';
|
||||||
case Description = 'description';
|
case Description = 'description';
|
||||||
case Tag = 'tag';
|
case Tag = 'tag';
|
||||||
case Type = 'type';
|
|
||||||
|
|
||||||
public static function fromInterval(TimeEntryAggregationTypeInterval $timeEntryAggregationTypeInterval): TimeEntryAggregationType
|
public static function fromInterval(TimeEntryAggregationTypeInterval $timeEntryAggregationTypeInterval): TimeEntryAggregationType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum TimeEntryType: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case Work = 'work';
|
|
||||||
case Break = 'break';
|
|
||||||
}
|
|
||||||
@@ -60,6 +60,7 @@ abstract class ApiException extends Exception
|
|||||||
*/
|
*/
|
||||||
public function report(): bool
|
public function report(): bool
|
||||||
{
|
{
|
||||||
|
// TODO: temporary activated
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class CanNotDeleteUserWhoIsOwnerOfOrganizationWithMultipleMembers extends ApiException
|
class CanNotDeleteUserWhoIsOwnerOfOrganizationWithMultipleMembers extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'can_not_delete_user_who_is_owner_of_organization_with_multiple_members';
|
public const string KEY = 'can_not_delete_user_who_is_owner_of_organization_with_multiple_members';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class CanNotRemoveOwnerFromOrganization extends ApiException
|
class CanNotRemoveOwnerFromOrganization extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'can_not_remove_owner_from_organization';
|
public const string KEY = 'can_not_remove_owner_from_organization';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class ChangingRoleOfPlaceholderIsNotAllowed extends ApiException
|
class ChangingRoleOfPlaceholderIsNotAllowed extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'changing_role_of_placeholder_is_not_allowed';
|
public const string KEY = 'changing_role_of_placeholder_is_not_allowed';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class ChangingRoleToPlaceholderIsNotAllowed extends ApiException
|
class ChangingRoleToPlaceholderIsNotAllowed extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'changing_role_to_placeholder_is_not_allowed';
|
public const string KEY = 'changing_role_to_placeholder_is_not_allowed';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,6 @@ class EntityStillInUseApiException extends ApiException
|
|||||||
|
|
||||||
public const string KEY = 'entity_still_in_use';
|
public const string KEY = 'entity_still_in_use';
|
||||||
|
|
||||||
/**
|
|
||||||
* Report the exception.
|
|
||||||
*
|
|
||||||
* @return bool true means the exception handler will not report it again
|
|
||||||
*/
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the translated message for the exception.
|
* Get the translated message for the exception.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class FeatureIsNotAvailableInFreePlanApiException extends ApiException
|
class FeatureIsNotAvailableInFreePlanApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'feature_is_not_available_in_free_plan';
|
public const string KEY = 'feature_is_not_available_in_free_plan';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class InactiveUserCanNotBeUsedApiException extends ApiException
|
class InactiveUserCanNotBeUsedApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'inactive_user_can_not_be_used';
|
public const string KEY = 'inactive_user_can_not_be_used';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class InvitationForTheEmailAlreadyExistsApiException extends ApiException
|
class InvitationForTheEmailAlreadyExistsApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'invitation_for_the_email_already_exists';
|
public const string KEY = 'invitation_for_the_email_already_exists';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class OnlyOwnerCanChangeOwnership extends ApiException
|
class OnlyOwnerCanChangeOwnership extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'only_owner_can_change_ownership';
|
public const string KEY = 'only_owner_can_change_ownership';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class OnlyPlaceholdersCanBeMergedIntoAnotherMember extends ApiException
|
class OnlyPlaceholdersCanBeMergedIntoAnotherMember extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'only_placeholders_can_be_merged_into_another_member';
|
public const string KEY = 'only_placeholders_can_be_merged_into_another_member';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class OrganizationHasNoSubscriptionButMultipleMembersException extends ApiException
|
class OrganizationHasNoSubscriptionButMultipleMembersException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'organization_has_no_subscription_but_multiple_members';
|
public const string KEY = 'organization_has_no_subscription_but_multiple_members';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class OrganizationNeedsAtLeastOneOwner extends ApiException
|
class OrganizationNeedsAtLeastOneOwner extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'organization_needs_at_least_one_owner';
|
public const string KEY = 'organization_needs_at_least_one_owner';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class OverlappingTimeEntryApiException extends ApiException
|
class OverlappingTimeEntryApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'overlapping_time_entry';
|
public const string KEY = 'overlapping_time_entry';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException extends ApiException
|
class ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'this_placeholder_can_not_be_invited_use_the_merge_tool_instead_api_exception';
|
public const string KEY = 'this_placeholder_can_not_be_invited_use_the_merge_tool_instead_api_exception';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class TimeEntryCanNotBeRestartedApiException extends ApiException
|
class TimeEntryCanNotBeRestartedApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'time_entry_can_not_be_restarted';
|
public const string KEY = 'time_entry_can_not_be_restarted';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class TimeEntryStillRunningApiException extends ApiException
|
class TimeEntryStillRunningApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'time_entry_still_running';
|
public const string KEY = 'time_entry_still_running';
|
||||||
|
|
||||||
/**
|
|
||||||
* Report the exception.
|
|
||||||
*
|
|
||||||
* @return bool true means the exception handler will not report it again
|
|
||||||
*/
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class UserIsAlreadyMemberOfOrganizationApiException extends ApiException
|
class UserIsAlreadyMemberOfOrganizationApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'user_is_already_member_of_organization';
|
public const string KEY = 'user_is_already_member_of_organization';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class UserIsAlreadyMemberOfProjectApiException extends ApiException
|
class UserIsAlreadyMemberOfProjectApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'user_is_already_member_of_project';
|
public const string KEY = 'user_is_already_member_of_project';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class UserNotPlaceholderApiException extends ApiException
|
class UserNotPlaceholderApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'user_not_placeholder';
|
public const string KEY = 'user_not_placeholder';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ namespace App\Exceptions\Api;
|
|||||||
class UserResendEmailVerificationNoPendingEmailApiException extends ApiException
|
class UserResendEmailVerificationNoPendingEmailApiException extends ApiException
|
||||||
{
|
{
|
||||||
public const string KEY = 'user_resend_email_verification_no_pending_email';
|
public const string KEY = 'user_resend_email_verification_no_pending_email';
|
||||||
|
|
||||||
public function report(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,7 @@ namespace App\Exceptions;
|
|||||||
|
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
|
||||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
@@ -34,33 +30,6 @@ class Handler extends ExceptionHandler
|
|||||||
$this->reportable(function (Throwable $e): void {
|
$this->reportable(function (Throwable $e): void {
|
||||||
//
|
//
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->dontReportWhen(fn (Throwable $e): bool => $e instanceof OAuthServerException
|
|
||||||
&& $e->getErrorType() === 'access_denied'
|
|
||||||
&& $e->getHttpStatusCode() === 401);
|
|
||||||
|
|
||||||
// A request on an untrusted host (see App\Http\Middleware\TrustHosts)
|
|
||||||
// otherwise renders as a bare "Bad request." 400. Show a message that
|
|
||||||
// says how to fix it instead. The framework has already converted the
|
|
||||||
// SuspiciousOperationException into a BadRequestHttpException by the time
|
|
||||||
// renderables run, so we match that and inspect the original.
|
|
||||||
$this->renderable(function (BadRequestHttpException $e, Request $request): ?Response {
|
|
||||||
$previous = $e->getPrevious();
|
|
||||||
|
|
||||||
if (! $previous instanceof SuspiciousOperationException
|
|
||||||
|| ! str_starts_with($previous->getMessage(), 'Untrusted Host')) {
|
|
||||||
return null; // any other bad request keeps the default response
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = 'This hostname is not configured for this instance. '
|
|
||||||
.'Set APP_URL, or add the host to TRUSTED_HOSTS.';
|
|
||||||
|
|
||||||
if ($request->expectsJson()) {
|
|
||||||
return response()->json(['message' => $message], 400);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response()->view('errors.untrusted-host', ['message' => $message], 400);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render($request, Throwable $e): Response|RedirectResponse
|
public function render($request, Throwable $e): Response|RedirectResponse
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
namespace App\Http\Controllers\Api\V1;
|
||||||
|
|
||||||
|
use App\Enums\Role;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Service\DashboardService;
|
use App\Service\DashboardService;
|
||||||
use App\Service\PermissionStore;
|
use App\Service\PermissionStore;
|
||||||
@@ -158,7 +159,7 @@ class ChartController extends Controller
|
|||||||
$this->checkPermission($organization, 'charts:view:own');
|
$this->checkPermission($organization, 'charts:view:own');
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
|
|
||||||
$showBillableRate = $this->canSeeBillableRates($organization);
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
if (! $showBillableRate) {
|
if (! $showBillableRate) {
|
||||||
throw new AuthorizationException('You do not have permission to view billable rates.');
|
throw new AuthorizationException('You do not have permission to view billable rates.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
namespace App\Http\Controllers\Api\V1;
|
||||||
|
|
||||||
use App\Enums\Role;
|
|
||||||
use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Service\BillingContract;
|
use App\Service\BillingContract;
|
||||||
use App\Service\PermissionStore;
|
use App\Service\PermissionStore;
|
||||||
@@ -51,30 +49,4 @@ class Controller extends \App\Http\Controllers\Controller
|
|||||||
{
|
{
|
||||||
return app(BillingContract::class)->hasSubscription($organization) || app(BillingContract::class)->hasTrial($organization);
|
return app(BillingContract::class)->hasSubscription($organization) || app(BillingContract::class)->hasTrial($organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function canUseBillableRates(Organization $organization): bool
|
|
||||||
{
|
|
||||||
return app(BillingContract::class)->canUseBillableRates($organization);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function canSeeBillableRates(Organization $organization): bool
|
|
||||||
{
|
|
||||||
if (! $this->canUseBillableRates($organization)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Organizations that can not use billable rates may keep or remove an existing rate, but not set a new one
|
|
||||||
*
|
|
||||||
* @throws FeatureIsNotAvailableInFreePlanApiException
|
|
||||||
*/
|
|
||||||
protected function checkBillableRateChange(Organization $organization, ?int $oldBillableRate, ?int $newBillableRate): void
|
|
||||||
{
|
|
||||||
if ($newBillableRate !== null && $newBillableRate !== $oldBillableRate && ! $this->canUseBillableRates($organization)) {
|
|
||||||
throw new FeatureIsNotAvailableInFreePlanApiException;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,7 @@ class ExportController extends Controller
|
|||||||
|
|
||||||
$filepath = $exportService->export($organization);
|
$filepath = $exportService->export($organization);
|
||||||
$downloadUrl = Storage::disk(config('filesystems.private'))
|
$downloadUrl = Storage::disk(config('filesystems.private'))
|
||||||
->temporaryUrl($filepath, Carbon::now()->addMinutes(10), [
|
->temporaryUrl($filepath, Carbon::now()->addMinutes(10));
|
||||||
'ResponseContentDisposition' => 'attachment; filename="'.basename($filepath).'"',
|
|
||||||
]);
|
|
||||||
|
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ class MemberController extends Controller
|
|||||||
$this->checkPermission($organization, 'members:update', $member);
|
$this->checkPermission($organization, 'members:update', $member);
|
||||||
|
|
||||||
if ($request->has('billable_rate') && $member->billable_rate !== $request->getBillableRate()) {
|
if ($request->has('billable_rate') && $member->billable_rate !== $request->getBillableRate()) {
|
||||||
$this->checkBillableRateChange($organization, $member->billable_rate, $request->getBillableRate());
|
|
||||||
$member->billable_rate = $request->getBillableRate();
|
$member->billable_rate = $request->getBillableRate();
|
||||||
|
|
||||||
$billableRateService->updateTimeEntriesBillableRateForMember($member);
|
$billableRateService->updateTimeEntriesBillableRateForMember($member);
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
namespace App\Http\Controllers\Api\V1;
|
||||||
|
|
||||||
|
use App\Enums\Role;
|
||||||
use App\Events\AfterCreateOrganization;
|
use App\Events\AfterCreateOrganization;
|
||||||
use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException;
|
|
||||||
use App\Http\Requests\V1\Organization\OrganizationDestroyRequest;
|
use App\Http\Requests\V1\Organization\OrganizationDestroyRequest;
|
||||||
use App\Http\Requests\V1\Organization\OrganizationStoreRequest;
|
use App\Http\Requests\V1\Organization\OrganizationStoreRequest;
|
||||||
use App\Http\Requests\V1\Organization\OrganizationUpdateRequest;
|
use App\Http\Requests\V1\Organization\OrganizationUpdateRequest;
|
||||||
@@ -32,7 +32,7 @@ class OrganizationController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'organizations:view');
|
$this->checkPermission($organization, 'organizations:view');
|
||||||
|
|
||||||
$showBillableRate = $this->canSeeBillableRates($organization);
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
|
|
||||||
return new OrganizationResource($organization, $showBillableRate);
|
return new OrganizationResource($organization, $showBillableRate);
|
||||||
}
|
}
|
||||||
@@ -54,10 +54,7 @@ class OrganizationController extends Controller
|
|||||||
if ($request->getCurrency() !== null) {
|
if ($request->getCurrency() !== null) {
|
||||||
$organization->currency = $request->getCurrency();
|
$organization->currency = $request->getCurrency();
|
||||||
}
|
}
|
||||||
if ($request->getEmployeesCanSeeBillableRates() !== null && $request->getEmployeesCanSeeBillableRates() !== $organization->employees_can_see_billable_rates) {
|
if ($request->getEmployeesCanSeeBillableRates() !== null) {
|
||||||
if (! $this->canUseBillableRates($organization)) {
|
|
||||||
throw new FeatureIsNotAvailableInFreePlanApiException;
|
|
||||||
}
|
|
||||||
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
||||||
}
|
}
|
||||||
if ($request->getEmployeesCanManageTasks() !== null) {
|
if ($request->getEmployeesCanManageTasks() !== null) {
|
||||||
@@ -81,12 +78,8 @@ class OrganizationController extends Controller
|
|||||||
if ($request->getPreventOverlappingTimeEntries() !== null) {
|
if ($request->getPreventOverlappingTimeEntries() !== null) {
|
||||||
$organization->prevent_overlapping_time_entries = $request->getPreventOverlappingTimeEntries();
|
$organization->prevent_overlapping_time_entries = $request->getPreventOverlappingTimeEntries();
|
||||||
}
|
}
|
||||||
if ($request->getBreaksEnabled() !== null) {
|
|
||||||
$organization->breaks_enabled = $request->getBreaksEnabled();
|
|
||||||
}
|
|
||||||
$hasBillableRate = $request->has('billable_rate');
|
$hasBillableRate = $request->has('billable_rate');
|
||||||
if ($hasBillableRate) {
|
if ($hasBillableRate) {
|
||||||
$this->checkBillableRateChange($organization, $organization->billable_rate, $request->getBillableRate());
|
|
||||||
$oldBillableRate = $organization->billable_rate;
|
$oldBillableRate = $organization->billable_rate;
|
||||||
$organization->billable_rate = $request->getBillableRate();
|
$organization->billable_rate = $request->getBillableRate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ProjectController extends Controller
|
|||||||
->orderBy('id')
|
->orderBy('id')
|
||||||
->paginate(config('app.pagination_per_page_default'));
|
->paginate(config('app.pagination_per_page_default'));
|
||||||
|
|
||||||
$showBillableRate = $this->canSeeBillableRates($organization);
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
|
|
||||||
return new ProjectCollection($projects, $showBillableRate);
|
return new ProjectCollection($projects, $showBillableRate);
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,6 @@ class ProjectController extends Controller
|
|||||||
public function store(Organization $organization, ProjectStoreRequest $request): JsonResource
|
public function store(Organization $organization, ProjectStoreRequest $request): JsonResource
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'projects:create');
|
$this->checkPermission($organization, 'projects:create');
|
||||||
$this->checkBillableRateChange($organization, null, $request->getBillableRate());
|
|
||||||
$project = new Project;
|
$project = new Project;
|
||||||
$project->name = $request->input('name');
|
$project->name = $request->input('name');
|
||||||
$project->color = $request->input('color');
|
$project->color = $request->input('color');
|
||||||
@@ -126,7 +125,6 @@ class ProjectController extends Controller
|
|||||||
public function update(Organization $organization, Project $project, ProjectUpdateRequest $request, BillableRateService $billableRateService): JsonResource
|
public function update(Organization $organization, Project $project, ProjectUpdateRequest $request, BillableRateService $billableRateService): JsonResource
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'projects:update', $project);
|
$this->checkPermission($organization, 'projects:update', $project);
|
||||||
$this->checkBillableRateChange($organization, $project->billable_rate, $request->getBillableRate());
|
|
||||||
$project->name = $request->input('name');
|
$project->name = $request->input('name');
|
||||||
$project->color = $request->input('color');
|
$project->color = $request->input('color');
|
||||||
$project->is_billable = (bool) $request->input('is_billable');
|
$project->is_billable = (bool) $request->input('is_billable');
|
||||||
@@ -141,17 +139,14 @@ class ProjectController extends Controller
|
|||||||
}
|
}
|
||||||
$oldBillableRate = $project->billable_rate;
|
$oldBillableRate = $project->billable_rate;
|
||||||
$clientIdChanged = false;
|
$clientIdChanged = false;
|
||||||
// Organizations that can not use billable rates do not receive the rate of the project, so the incoming value is ignored to keep the existing rate
|
$project->billable_rate = $request->getBillableRate();
|
||||||
if ($this->canUseBillableRates($organization)) {
|
|
||||||
$project->billable_rate = $request->getBillableRate();
|
|
||||||
}
|
|
||||||
if ($project->client_id !== $request->input('client_id')) {
|
if ($project->client_id !== $request->input('client_id')) {
|
||||||
$project->client_id = $request->input('client_id');
|
$project->client_id = $request->input('client_id');
|
||||||
$clientIdChanged = true;
|
$clientIdChanged = true;
|
||||||
}
|
}
|
||||||
$project->save();
|
$project->save();
|
||||||
|
|
||||||
if ($oldBillableRate !== $project->billable_rate) {
|
if ($oldBillableRate !== $request->getBillableRate()) {
|
||||||
$billableRateService->updateTimeEntriesBillableRateForProject($project);
|
$billableRateService->updateTimeEntriesBillableRateForProject($project);
|
||||||
}
|
}
|
||||||
if ($clientIdChanged) {
|
if ($clientIdChanged) {
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ class ProjectMemberController extends Controller
|
|||||||
public function store(Organization $organization, Project $project, ProjectMemberStoreRequest $request, BillableRateService $billableRateService): JsonResource
|
public function store(Organization $organization, Project $project, ProjectMemberStoreRequest $request, BillableRateService $billableRateService): JsonResource
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'project-members:create', $project);
|
$this->checkPermission($organization, 'project-members:create', $project);
|
||||||
$this->checkBillableRateChange($organization, null, $request->getBillableRate());
|
|
||||||
|
|
||||||
$member = Member::findOrFail((string) $request->input('member_id'));
|
$member = Member::findOrFail((string) $request->input('member_id'));
|
||||||
if ($member->user->is_placeholder) {
|
if ($member->user->is_placeholder) {
|
||||||
@@ -99,7 +98,6 @@ class ProjectMemberController extends Controller
|
|||||||
public function update(Organization $organization, ProjectMember $projectMember, ProjectMemberUpdateRequest $request, BillableRateService $billableRateService): JsonResource
|
public function update(Organization $organization, ProjectMember $projectMember, ProjectMemberUpdateRequest $request, BillableRateService $billableRateService): JsonResource
|
||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'project-members:update', projectMember: $projectMember);
|
$this->checkPermission($organization, 'project-members:update', projectMember: $projectMember);
|
||||||
$this->checkBillableRateChange($organization, $projectMember->billable_rate, $request->getBillableRate());
|
|
||||||
$oldBillableRate = $projectMember->billable_rate;
|
$oldBillableRate = $projectMember->billable_rate;
|
||||||
$projectMember->billable_rate = $request->getBillableRate();
|
$projectMember->billable_rate = $request->getBillableRate();
|
||||||
$projectMember->save();
|
$projectMember->save();
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class ReportController extends Controller
|
|||||||
$filter->addEnd($properties->end);
|
$filter->addEnd($properties->end);
|
||||||
$filter->addActive($properties->active);
|
$filter->addActive($properties->active);
|
||||||
$filter->addBillable($properties->billable);
|
$filter->addBillable($properties->billable);
|
||||||
$filter->addType($properties->timeEntryType);
|
|
||||||
$filter->addMemberIdsFilter($properties->memberIds?->toArray());
|
$filter->addMemberIdsFilter($properties->memberIds?->toArray());
|
||||||
$filter->addProjectIdsFilter($properties->projectIds?->toArray());
|
$filter->addProjectIdsFilter($properties->projectIds?->toArray());
|
||||||
$filter->addTagIdsFilter($properties->tagIds?->toArray(), $properties->tagMatchType);
|
$filter->addTagIdsFilter($properties->tagIds?->toArray(), $properties->tagMatchType);
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ class ReportController extends Controller
|
|||||||
$properties->timezone = $timezone;
|
$properties->timezone = $timezone;
|
||||||
$properties->roundingType = $request->getPropertyRoundingType();
|
$properties->roundingType = $request->getPropertyRoundingType();
|
||||||
$properties->roundingMinutes = $request->getPropertyRoundingMinutes();
|
$properties->roundingMinutes = $request->getPropertyRoundingMinutes();
|
||||||
$properties->timeEntryType = $request->getPropertyTimeEntryType();
|
|
||||||
$report->properties = $properties;
|
$report->properties = $properties;
|
||||||
if ($isPublic) {
|
if ($isPublic) {
|
||||||
$report->share_secret = $reportService->generateSecret();
|
$report->share_secret = $reportService->generateSecret();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Controllers\Api\V1;
|
namespace App\Http\Controllers\Api\V1;
|
||||||
|
|
||||||
use App\Enums\ExportFormat;
|
use App\Enums\ExportFormat;
|
||||||
use App\Enums\TimeEntryType;
|
use App\Enums\Role;
|
||||||
use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException;
|
use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException;
|
||||||
use App\Exceptions\Api\OverlappingTimeEntryApiException;
|
use App\Exceptions\Api\OverlappingTimeEntryApiException;
|
||||||
use App\Exceptions\Api\PdfRendererIsNotConfiguredException;
|
use App\Exceptions\Api\PdfRendererIsNotConfiguredException;
|
||||||
@@ -209,7 +209,6 @@ class TimeEntryController extends Controller
|
|||||||
$filter->addTaskIdsFilter($request->input('task_ids'));
|
$filter->addTaskIdsFilter($request->input('task_ids'));
|
||||||
$filter->addClientIdsFilter($request->input('client_ids'));
|
$filter->addClientIdsFilter($request->input('client_ids'));
|
||||||
$filter->addBillableFilter($request->input('billable'));
|
$filter->addBillableFilter($request->input('billable'));
|
||||||
$filter->addTypeFilter($request->input('type'));
|
|
||||||
|
|
||||||
return $filter->get();
|
return $filter->get();
|
||||||
}
|
}
|
||||||
@@ -239,7 +238,7 @@ class TimeEntryController extends Controller
|
|||||||
}
|
}
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$timezone = $user->timezone;
|
$timezone = $user->timezone;
|
||||||
$showBillableRate = $this->canSeeBillableRates($organization);
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
$roundingType = $canAccessPremiumFeatures ? $request->getRoundingType() : null;
|
$roundingType = $canAccessPremiumFeatures ? $request->getRoundingType() : null;
|
||||||
$roundingMinutes = $canAccessPremiumFeatures ? $request->getRoundingMinutes() : null;
|
$roundingMinutes = $canAccessPremiumFeatures ? $request->getRoundingMinutes() : null;
|
||||||
|
|
||||||
@@ -335,9 +334,7 @@ class TimeEntryController extends Controller
|
|||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'download_url' => Storage::disk(config('filesystems.private'))
|
'download_url' => Storage::disk(config('filesystems.private'))
|
||||||
->temporaryUrl($path, now()->addMinutes(5), [
|
->temporaryUrl($path, now()->addMinutes(5)),
|
||||||
'ResponseContentDisposition' => 'attachment; filename="'.$filename.'"',
|
|
||||||
]),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +382,7 @@ class TimeEntryController extends Controller
|
|||||||
}
|
}
|
||||||
$canAccessPremiumFeatures = $this->canAccessPremiumFeatures($organization);
|
$canAccessPremiumFeatures = $this->canAccessPremiumFeatures($organization);
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$showBillableRate = $this->canSeeBillableRates($organization);
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
|
|
||||||
$group1Type = $request->getGroup();
|
$group1Type = $request->getGroup();
|
||||||
$group2Type = $request->getSubGroup();
|
$group2Type = $request->getSubGroup();
|
||||||
@@ -440,7 +437,7 @@ class TimeEntryController extends Controller
|
|||||||
}
|
}
|
||||||
$debug = $request->getDebug();
|
$debug = $request->getDebug();
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$showBillableRate = $this->canSeeBillableRates($organization);
|
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
||||||
|
|
||||||
$group = $request->getGroup();
|
$group = $request->getGroup();
|
||||||
$subGroup = $request->getSubGroup();
|
$subGroup = $request->getSubGroup();
|
||||||
@@ -536,7 +533,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, $showBillableRate, $localizationService),
|
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup, $showBillableRate),
|
||||||
$path,
|
$path,
|
||||||
config('filesystems.private'),
|
config('filesystems.private'),
|
||||||
$format->getExportPackageType(),
|
$format->getExportPackageType(),
|
||||||
@@ -548,9 +545,7 @@ class TimeEntryController extends Controller
|
|||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'download_url' => Storage::disk(config('filesystems.private'))
|
'download_url' => Storage::disk(config('filesystems.private'))
|
||||||
->temporaryUrl($path, now()->addMinutes(5), [
|
->temporaryUrl($path, now()->addMinutes(5)),
|
||||||
'ResponseContentDisposition' => 'attachment; filename="'.$filename.'"',
|
|
||||||
]),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,7 +568,6 @@ class TimeEntryController extends Controller
|
|||||||
$filter->addTaskIdsFilter($request->input('task_ids'));
|
$filter->addTaskIdsFilter($request->input('task_ids'));
|
||||||
$filter->addClientIdsFilter($request->input('client_ids'));
|
$filter->addClientIdsFilter($request->input('client_ids'));
|
||||||
$filter->addBillableFilter($request->input('billable'));
|
$filter->addBillableFilter($request->input('billable'));
|
||||||
$filter->addTypeFilter($request->input('type'));
|
|
||||||
|
|
||||||
return $filter->get();
|
return $filter->get();
|
||||||
}
|
}
|
||||||
@@ -765,19 +759,6 @@ class TimeEntryController extends Controller
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
// Changing time entries to Break entries is only allowed when breaks are enabled in the org settings
|
|
||||||
$resultingType = isset($changes['type']) ? TimeEntryType::from($changes['type']) : $timeEntry->type;
|
|
||||||
if ($resultingType === TimeEntryType::Break && $timeEntry->type !== TimeEntryType::Break && ! $organization->breaks_enabled) {
|
|
||||||
$error->push($id);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Break entries can not be billable, have tags or belong to a project/task (see TimeEntry::booted)
|
|
||||||
if ($resultingType === TimeEntryType::Break && ($project !== null || $task !== null || $request->boolean('changes.billable') || count($changes['tags'] ?? []) > 0)) {
|
|
||||||
$error->push($id);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$oldProject = $timeEntry->project;
|
$oldProject = $timeEntry->project;
|
||||||
$oldTask = $timeEntry->task;
|
$oldTask = $timeEntry->task;
|
||||||
|
|
||||||
|
|||||||
@@ -124,10 +124,6 @@ class UserController extends Controller
|
|||||||
$user->week_start = $request->getWeekStart();
|
$user->week_start = $request->getWeekStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->getSendTimeEntryStillRunningEmail() !== null) {
|
|
||||||
$user->send_time_entry_still_running_email = $request->getSendTimeEntryStillRunningEmail();
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
if ($emailToVerify !== null) {
|
if ($emailToVerify !== null) {
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class OrganizationInvitationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('register'))
|
return redirect(route('register'))
|
||||||
->with('registration_email', $email)
|
|
||||||
->with('bannerText', __('Please create an account to finish joining the :organization organization.', [
|
->with('bannerText', __('Please create an account to finish joining the :organization organization.', [
|
||||||
'organization' => $organization->name,
|
'organization' => $organization->name,
|
||||||
]))
|
]))
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ use App\Http\Middleware\PreventRequestsDuringMaintenance;
|
|||||||
use App\Http\Middleware\RedirectIfAuthenticated;
|
use App\Http\Middleware\RedirectIfAuthenticated;
|
||||||
use App\Http\Middleware\ShareInertiaData;
|
use App\Http\Middleware\ShareInertiaData;
|
||||||
use App\Http\Middleware\TrimStrings;
|
use App\Http\Middleware\TrimStrings;
|
||||||
use App\Http\Middleware\TrustHosts;
|
|
||||||
use App\Http\Middleware\TrustProxies;
|
use App\Http\Middleware\TrustProxies;
|
||||||
use App\Http\Middleware\ValidateSignature;
|
use App\Http\Middleware\ValidateSignature;
|
||||||
use App\Http\Middleware\VerifyCsrfToken;
|
use App\Http\Middleware\VerifyCsrfToken;
|
||||||
@@ -48,7 +47,6 @@ class Kernel extends HttpKernel
|
|||||||
*/
|
*/
|
||||||
protected $middleware = [
|
protected $middleware = [
|
||||||
ForceHttps::class,
|
ForceHttps::class,
|
||||||
TrustHosts::class,
|
|
||||||
TrustProxies::class,
|
TrustProxies::class,
|
||||||
HandleCors::class,
|
HandleCors::class,
|
||||||
PreventRequestsDuringMaintenance::class,
|
PreventRequestsDuringMaintenance::class,
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ class HandleInertiaRequests extends Middleware
|
|||||||
'has_trial' => $billing->hasTrial($currentOrganization),
|
'has_trial' => $billing->hasTrial($currentOrganization),
|
||||||
'trial_until' => $billing->getTrialUntil($currentOrganization)?->toIso8601ZuluString(),
|
'trial_until' => $billing->getTrialUntil($currentOrganization)?->toIso8601ZuluString(),
|
||||||
'is_blocked' => $billing->isBlocked($currentOrganization),
|
'is_blocked' => $billing->isBlocked($currentOrganization),
|
||||||
'can_use_billable_rates' => $billing->canUseBillableRates($currentOrganization),
|
|
||||||
] : null,
|
] : null,
|
||||||
'flash' => [
|
'flash' => [
|
||||||
'message' => fn () => $request->session()->get('message'),
|
'message' => fn () => $request->session()->get('message'),
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Middleware;
|
|
||||||
|
|
||||||
use Illuminate\Http\Middleware\TrustHosts as BaseTrustHosts;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\Response;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rejects requests whose Host is not trusted, preventing Host-header poisoning of
|
|
||||||
* generated URLs (password reset, SSO callback, invitations). Trusted = the
|
|
||||||
* APP_URL host and its subdomains, plus TRUSTED_HOSTS (for multi-host access such
|
|
||||||
* as a Tailscale name). Health-check endpoints are exempt (probed by IP).
|
|
||||||
*/
|
|
||||||
class TrustHosts extends BaseTrustHosts
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return array<int, string|null>
|
|
||||||
*/
|
|
||||||
public function hosts(): array
|
|
||||||
{
|
|
||||||
/** @var array<int, string> $configured */
|
|
||||||
$configured = config('app.trusted_hosts', []);
|
|
||||||
|
|
||||||
$extra = array_map(function (string $host): string {
|
|
||||||
$host = trim($host);
|
|
||||||
|
|
||||||
// "*.example.com" matches any subdomain, not the apex.
|
|
||||||
if (str_starts_with($host, '*.')) {
|
|
||||||
return '^.+\.'.preg_quote(substr($host, 2), '#').'$';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '^'.preg_quote($host, '#').'$';
|
|
||||||
}, $configured);
|
|
||||||
|
|
||||||
return array_merge([$this->allSubdomainsOfApplicationUrl()], $extra);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \Closure(Request): Response $next
|
|
||||||
*/
|
|
||||||
public function handle(Request $request, $next)
|
|
||||||
{
|
|
||||||
// Exempt health checks (probed by IP). Also reset the trusted hosts,
|
|
||||||
// since Octane leaks the static state across requests.
|
|
||||||
if ($request->is('health-check/*')) {
|
|
||||||
Request::setTrustedHosts([]);
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::handle($request, $next);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,6 @@ class ImportRequest extends BaseFormRequest
|
|||||||
'data' => [
|
'data' => [
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
'max:'.config('import.max_data_size'),
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,9 +51,6 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
'prevent_overlapping_time_entries' => [
|
'prevent_overlapping_time_entries' => [
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'breaks_enabled' => [
|
|
||||||
'boolean',
|
|
||||||
],
|
|
||||||
'number_format' => [
|
'number_format' => [
|
||||||
Rule::enum(NumberFormat::class),
|
Rule::enum(NumberFormat::class),
|
||||||
],
|
],
|
||||||
@@ -128,9 +125,4 @@ class OrganizationUpdateRequest extends BaseFormRequest
|
|||||||
{
|
{
|
||||||
return $this->has('prevent_overlapping_time_entries') ? $this->boolean('prevent_overlapping_time_entries') : null;
|
return $this->has('prevent_overlapping_time_entries') ? $this->boolean('prevent_overlapping_time_entries') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBreaksEnabled(): ?bool
|
|
||||||
{
|
|
||||||
return $this->has('breaks_enabled') ? $this->boolean('breaks_enabled') : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Enums\TagMatchType;
|
|||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
use App\Enums\TimeEntryRoundingType;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Enums\Weekday;
|
use App\Enums\Weekday;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -178,12 +177,6 @@ class ReportStoreRequest extends BaseFormRequest
|
|||||||
'numeric',
|
'numeric',
|
||||||
'integer',
|
'integer',
|
||||||
],
|
],
|
||||||
// Filter by time entry type
|
|
||||||
'properties.time_entry_type' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,15 +240,6 @@ class ReportStoreRequest extends BaseFormRequest
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPropertyTimeEntryType(): ?TimeEntryType
|
|
||||||
{
|
|
||||||
if (! $this->has('properties.time_entry_type') || $this->input('properties.time_entry_type') === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TimeEntryType::from($this->input('properties.time_entry_type'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPropertyGroup(): TimeEntryAggregationType
|
public function getPropertyGroup(): TimeEntryAggregationType
|
||||||
{
|
{
|
||||||
return TimeEntryAggregationType::from($this->input('properties.group'));
|
return TimeEntryAggregationType::from($this->input('properties.group'));
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use App\Enums\TagMatchType;
|
|||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
use App\Enums\TimeEntryRoundingType;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
@@ -184,11 +183,6 @@ class TimeEntryAggregateExportRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Filter by time entry type
|
|
||||||
'type' => [
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
],
|
|
||||||
'fill_gaps_in_time_groups' => [
|
'fill_gaps_in_time_groups' => [
|
||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace App\Http\Requests\V1\TimeEntry;
|
|||||||
use App\Enums\TagMatchType;
|
use App\Enums\TagMatchType;
|
||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
use App\Enums\TimeEntryRoundingType;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
@@ -170,11 +169,6 @@ class TimeEntryAggregateRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Filter by time entry type
|
|
||||||
'type' => [
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
],
|
|
||||||
'fill_gaps_in_time_groups' => [
|
'fill_gaps_in_time_groups' => [
|
||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace App\Http\Requests\V1\TimeEntry;
|
|||||||
use App\Enums\ExportFormat;
|
use App\Enums\ExportFormat;
|
||||||
use App\Enums\TagMatchType;
|
use App\Enums\TagMatchType;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
use App\Enums\TimeEntryRoundingType;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -156,11 +155,6 @@ class TimeEntryIndexExportRequest extends TimeEntryIndexRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Filter by time entry type
|
|
||||||
'type' => [
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
],
|
|
||||||
// Limit the number of returned time entries (default: 150)
|
// Limit the number of returned time entries (default: 150)
|
||||||
'limit' => [
|
'limit' => [
|
||||||
'integer',
|
'integer',
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace App\Http\Requests\V1\TimeEntry;
|
|||||||
|
|
||||||
use App\Enums\TagMatchType;
|
use App\Enums\TagMatchType;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
use App\Enums\TimeEntryRoundingType;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
@@ -149,11 +148,6 @@ class TimeEntryIndexRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
'in:true,false',
|
'in:true,false',
|
||||||
],
|
],
|
||||||
// Filter by time entry type
|
|
||||||
'type' => [
|
|
||||||
'string',
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
],
|
|
||||||
// Limit the number of returned time entries (default: 150)
|
// Limit the number of returned time entries (default: 150)
|
||||||
'limit' => [
|
'limit' => [
|
||||||
'integer',
|
'integer',
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -15,7 +14,6 @@ use App\Service\PermissionStore;
|
|||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +24,7 @@ class TimeEntryStoreRequest extends BaseFormRequest
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|\Closure|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
@@ -44,7 +42,6 @@ class TimeEntryStoreRequest extends BaseFormRequest
|
|||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
'required_with:task_id',
|
'required_with:task_id',
|
||||||
'prohibited_if:type,break',
|
|
||||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
$builder = $builder->whereBelongsTo($this->organization, 'organization');
|
$builder = $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
@@ -63,7 +60,6 @@ class TimeEntryStoreRequest extends BaseFormRequest
|
|||||||
'task_id' => [
|
'task_id' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
'prohibited_if:type,break',
|
|
||||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Task> $builder */
|
/** @var Builder<Task> $builder */
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
@@ -89,16 +85,6 @@ class TimeEntryStoreRequest extends BaseFormRequest
|
|||||||
'billable' => [
|
'billable' => [
|
||||||
'required',
|
'required',
|
||||||
'boolean',
|
'boolean',
|
||||||
'declined_if:type,break',
|
|
||||||
],
|
|
||||||
// Type of the time entry (work time or a break)
|
|
||||||
'type' => [
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
function (string $attribute, mixed $value, \Closure $fail): void {
|
|
||||||
if ($value === TimeEntryType::Break->value && ! $this->organization->breaks_enabled) {
|
|
||||||
$fail('Breaks are disabled for this organization.');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
// Description of time entry
|
// Description of time entry
|
||||||
'description' => [
|
'description' => [
|
||||||
@@ -110,7 +96,6 @@ class TimeEntryStoreRequest extends BaseFormRequest
|
|||||||
'tags' => [
|
'tags' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'array',
|
'array',
|
||||||
'prohibited_if:type,break',
|
|
||||||
],
|
],
|
||||||
'tags.*' => [
|
'tags.*' => [
|
||||||
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Tag::class, null, function (Builder $builder): Builder {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -15,7 +14,6 @@ use App\Service\PermissionStore;
|
|||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +24,7 @@ class TimeEntryUpdateMultipleRequest extends BaseFormRequest
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
@@ -56,7 +54,6 @@ class TimeEntryUpdateMultipleRequest extends BaseFormRequest
|
|||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
'required_with:task_id',
|
'required_with:task_id',
|
||||||
'prohibited_if:changes.type,break',
|
|
||||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
$builder = $builder->whereBelongsTo($this->organization, 'organization');
|
$builder = $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
@@ -75,7 +72,6 @@ class TimeEntryUpdateMultipleRequest extends BaseFormRequest
|
|||||||
'changes.task_id' => [
|
'changes.task_id' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
'prohibited_if:changes.type,break',
|
|
||||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Task> $builder */
|
/** @var Builder<Task> $builder */
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
@@ -88,13 +84,7 @@ class TimeEntryUpdateMultipleRequest extends BaseFormRequest
|
|||||||
],
|
],
|
||||||
// Whether time entry is billable
|
// Whether time entry is billable
|
||||||
'changes.billable' => [
|
'changes.billable' => [
|
||||||
'sometimes',
|
|
||||||
'boolean',
|
'boolean',
|
||||||
'declined_if:changes.type,break',
|
|
||||||
],
|
|
||||||
// Type of the time entry (work time or a break)
|
|
||||||
'changes.type' => [
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
],
|
],
|
||||||
// Description of time entry
|
// Description of time entry
|
||||||
'changes.description' => [
|
'changes.description' => [
|
||||||
@@ -106,7 +96,6 @@ class TimeEntryUpdateMultipleRequest extends BaseFormRequest
|
|||||||
'changes.tags' => [
|
'changes.tags' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'array',
|
'array',
|
||||||
'prohibited_if:changes.type,break',
|
|
||||||
],
|
],
|
||||||
'changes.tags.*' => [
|
'changes.tags.*' => [
|
||||||
'string',
|
'string',
|
||||||
|
|||||||
@@ -4,21 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use App\Http\Requests\V1\BaseFormRequest;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TimeEntry;
|
|
||||||
use App\Service\PermissionStore;
|
use App\Service\PermissionStore;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Validation\ConditionalRules;
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Illuminate\Validation\Rules\ProhibitedIf;
|
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,19 +24,10 @@ class TimeEntryUpdateRequest extends BaseFormRequest
|
|||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|\Closure|ValidationRule|\Illuminate\Contracts\Validation\Rule|ProhibitedIf|ConditionalRules>>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
// Break restrictions need to apply based on the type the entry will have after the
|
|
||||||
// update, not only when the payload itself contains type=break.
|
|
||||||
$timeEntry = $this->route('timeEntry');
|
|
||||||
$timeEntry = $timeEntry instanceof TimeEntry ? $timeEntry : null;
|
|
||||||
$resultingType = $this->has('type')
|
|
||||||
? TimeEntryType::tryFrom((string) $this->input('type'))
|
|
||||||
: $timeEntry?->type;
|
|
||||||
$isBreak = $resultingType === TimeEntryType::Break;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// ID of the organization member that the time entry should belong to
|
// ID of the organization member that the time entry should belong to
|
||||||
'member_id' => [
|
'member_id' => [
|
||||||
@@ -56,7 +42,6 @@ class TimeEntryUpdateRequest extends BaseFormRequest
|
|||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
'required_with:task_id',
|
'required_with:task_id',
|
||||||
Rule::prohibitedIf($isBreak),
|
|
||||||
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Project::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
$builder = $builder->whereBelongsTo($this->organization, 'organization');
|
$builder = $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
@@ -75,7 +60,6 @@ class TimeEntryUpdateRequest extends BaseFormRequest
|
|||||||
'task_id' => [
|
'task_id' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'string',
|
'string',
|
||||||
Rule::prohibitedIf($isBreak),
|
|
||||||
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Task::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Task> $builder */
|
/** @var Builder<Task> $builder */
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
@@ -98,22 +82,7 @@ class TimeEntryUpdateRequest extends BaseFormRequest
|
|||||||
],
|
],
|
||||||
// Whether time entry is billable
|
// Whether time entry is billable
|
||||||
'billable' => [
|
'billable' => [
|
||||||
'sometimes',
|
|
||||||
'boolean',
|
'boolean',
|
||||||
Rule::when($isBreak, ['declined']),
|
|
||||||
],
|
|
||||||
// Type of the time entry (work time or a break)
|
|
||||||
'type' => [
|
|
||||||
Rule::enum(TimeEntryType::class),
|
|
||||||
function (string $attribute, mixed $value, \Closure $fail) use ($timeEntry): void {
|
|
||||||
// While breaks are disabled, entries that already are breaks may stay
|
|
||||||
// breaks, but converting a work entry to a break is not allowed.
|
|
||||||
if ($value === TimeEntryType::Break->value
|
|
||||||
&& ! $this->organization->breaks_enabled
|
|
||||||
&& $timeEntry?->type !== TimeEntryType::Break) {
|
|
||||||
$fail('Breaks are disabled for this organization.');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
// Description of time entry
|
// Description of time entry
|
||||||
'description' => [
|
'description' => [
|
||||||
@@ -125,7 +94,6 @@ class TimeEntryUpdateRequest extends BaseFormRequest
|
|||||||
'tags' => [
|
'tags' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'array',
|
'array',
|
||||||
Rule::prohibitedIf($isBreak),
|
|
||||||
],
|
],
|
||||||
'tags.*' => [
|
'tags.*' => [
|
||||||
'string',
|
'string',
|
||||||
|
|||||||
@@ -58,9 +58,6 @@ class UserUpdateRequest extends BaseFormRequest
|
|||||||
'week_start' => [
|
'week_start' => [
|
||||||
Rule::enum(Weekday::class),
|
Rule::enum(Weekday::class),
|
||||||
],
|
],
|
||||||
'send_time_entry_still_running_email' => [
|
|
||||||
'boolean',
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,13 +81,6 @@ class UserUpdateRequest extends BaseFormRequest
|
|||||||
return $this->has('week_start') ? Weekday::from($this->input('week_start')) : null;
|
return $this->has('week_start') ? Weekday::from($this->input('week_start')) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSendTimeEntryStillRunningEmail(): ?bool
|
|
||||||
{
|
|
||||||
return $this->has('send_time_entry_still_running_email')
|
|
||||||
? $this->boolean('send_time_entry_still_running_email')
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasPhotoKey(): bool
|
public function hasPhotoKey(): bool
|
||||||
{
|
{
|
||||||
return $this->has('photo');
|
return $this->has('photo');
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ class OrganizationResource extends BaseResource
|
|||||||
'employees_can_manage_tasks' => $this->resource->employees_can_manage_tasks,
|
'employees_can_manage_tasks' => $this->resource->employees_can_manage_tasks,
|
||||||
/** @var bool $prevent_overlapping_time_entries Prevent creating overlapping time entries (only new entries) */
|
/** @var bool $prevent_overlapping_time_entries Prevent creating overlapping time entries (only new entries) */
|
||||||
'prevent_overlapping_time_entries' => $this->resource->prevent_overlapping_time_entries,
|
'prevent_overlapping_time_entries' => $this->resource->prevent_overlapping_time_entries,
|
||||||
/** @var bool $breaks_enabled Whether members of the organization can track breaks */
|
|
||||||
'breaks_enabled' => $this->resource->breaks_enabled,
|
|
||||||
/** @var string $currency Currency code (ISO 4217) */
|
/** @var string $currency Currency code (ISO 4217) */
|
||||||
'currency' => $this->resource->currency,
|
'currency' => $this->resource->currency,
|
||||||
/** @var string $currency_symbol Currency symbol */
|
/** @var string $currency_symbol Currency symbol */
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ class DetailedReportResource extends BaseResource
|
|||||||
'member_ids' => $this->resource->properties->memberIds?->toArray(),
|
'member_ids' => $this->resource->properties->memberIds?->toArray(),
|
||||||
/** @var bool|null $billable Filter by billable status */
|
/** @var bool|null $billable Filter by billable status */
|
||||||
'billable' => $this->resource->properties->billable,
|
'billable' => $this->resource->properties->billable,
|
||||||
/** @var string|null $time_entry_type Filter by time entry type */
|
|
||||||
'time_entry_type' => $this->resource->properties->timeEntryType?->value,
|
|
||||||
/** @var array<string>|null $client_ids Filter by client IDs, client IDs are OR combined */
|
/** @var array<string>|null $client_ids Filter by client IDs, client IDs are OR combined */
|
||||||
'client_ids' => $this->resource->properties->clientIds?->toArray(),
|
'client_ids' => $this->resource->properties->clientIds?->toArray(),
|
||||||
/** @var array<string>|null $project_ids Filter by project IDs, project IDs are OR combined */
|
/** @var array<string>|null $project_ids Filter by project IDs, project IDs are OR combined */
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ class TimeEntryResource extends BaseResource
|
|||||||
'tags' => $this->resource->tags ?? [],
|
'tags' => $this->resource->tags ?? [],
|
||||||
/** @var bool $billable Whether time entry is billable */
|
/** @var bool $billable Whether time entry is billable */
|
||||||
'billable' => $this->resource->billable,
|
'billable' => $this->resource->billable,
|
||||||
/** @var string $type Type of the time entry (`work` time or a `break`) */
|
|
||||||
'type' => $this->resource->type->value,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ class UserResource extends BaseResource
|
|||||||
'timezone' => $this->resource->timezone,
|
'timezone' => $this->resource->timezone,
|
||||||
/** @var Weekday $week_start Starting day of the week */
|
/** @var Weekday $week_start Starting day of the week */
|
||||||
'week_start' => $this->resource->week_start->value,
|
'week_start' => $this->resource->week_start->value,
|
||||||
/** @var bool $send_time_entry_still_running_email Whether to email the user when a time entry has been running for more than 8 hours */
|
|
||||||
'send_time_entry_still_running_email' => $this->resource->send_time_entry_still_running_email,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
* @property bool $employees_can_see_billable_rates
|
* @property bool $employees_can_see_billable_rates
|
||||||
* @property bool $employees_can_manage_tasks
|
* @property bool $employees_can_manage_tasks
|
||||||
* @property bool $prevent_overlapping_time_entries
|
* @property bool $prevent_overlapping_time_entries
|
||||||
* @property bool $breaks_enabled
|
|
||||||
* @property User $owner
|
* @property User $owner
|
||||||
* @property Carbon|null $created_at
|
* @property Carbon|null $created_at
|
||||||
* @property Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
@@ -71,7 +70,6 @@ class Organization extends Model implements AuditableContract
|
|||||||
'employees_can_see_billable_rates' => 'boolean',
|
'employees_can_see_billable_rates' => 'boolean',
|
||||||
'employees_can_manage_tasks' => 'boolean',
|
'employees_can_manage_tasks' => 'boolean',
|
||||||
'prevent_overlapping_time_entries' => 'boolean',
|
'prevent_overlapping_time_entries' => 'boolean',
|
||||||
'breaks_enabled' => 'boolean',
|
|
||||||
'number_format' => NumberFormat::class,
|
'number_format' => NumberFormat::class,
|
||||||
'currency_format' => CurrencyFormat::class,
|
'currency_format' => CurrencyFormat::class,
|
||||||
'date_format' => DateFormat::class,
|
'date_format' => DateFormat::class,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Models\Concerns\CustomAuditable;
|
use App\Models\Concerns\CustomAuditable;
|
||||||
use App\Models\Concerns\HasUuids;
|
use App\Models\Concerns\HasUuids;
|
||||||
use App\Service\BillableRateService;
|
use App\Service\BillableRateService;
|
||||||
@@ -29,7 +28,6 @@ use Staudenmeir\EloquentJsonRelations\Relations\BelongsToJson;
|
|||||||
* @property Carbon|null $end
|
* @property Carbon|null $end
|
||||||
* @property int|null $billable_rate Billable rate per hour in cents
|
* @property int|null $billable_rate Billable rate per hour in cents
|
||||||
* @property bool $billable
|
* @property bool $billable
|
||||||
* @property TimeEntryType $type
|
|
||||||
* @property array<string> $tags
|
* @property array<string> $tags
|
||||||
* @property string $user_id
|
* @property string $user_id
|
||||||
* @property string $member_id
|
* @property string $member_id
|
||||||
@@ -73,20 +71,12 @@ class TimeEntry extends Model implements AuditableContract
|
|||||||
'start' => 'datetime',
|
'start' => 'datetime',
|
||||||
'end' => 'datetime',
|
'end' => 'datetime',
|
||||||
'billable' => 'bool',
|
'billable' => 'bool',
|
||||||
'type' => TimeEntryType::class,
|
|
||||||
'tags' => 'array',
|
'tags' => 'array',
|
||||||
'billable_rate' => 'int',
|
'billable_rate' => 'int',
|
||||||
'is_imported' => 'bool',
|
'is_imported' => 'bool',
|
||||||
'still_active_email_sent_at' => 'datetime',
|
'still_active_email_sent_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
protected $attributes = [
|
|
||||||
'type' => 'work',
|
|
||||||
];
|
|
||||||
|
|
||||||
public const array SELECT_COLUMNS = [
|
public const array SELECT_COLUMNS = [
|
||||||
'id',
|
'id',
|
||||||
'description',
|
'description',
|
||||||
@@ -94,7 +84,6 @@ class TimeEntry extends Model implements AuditableContract
|
|||||||
'end',
|
'end',
|
||||||
'billable_rate',
|
'billable_rate',
|
||||||
'billable',
|
'billable',
|
||||||
'type',
|
|
||||||
'user_id',
|
'user_id',
|
||||||
'organization_id',
|
'organization_id',
|
||||||
'project_id',
|
'project_id',
|
||||||
@@ -128,21 +117,6 @@ class TimeEntry extends Model implements AuditableContract
|
|||||||
'billable_rate',
|
'billable_rate',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected static function booted(): void
|
|
||||||
{
|
|
||||||
// Break entries can never be billable, have tags or belong to a project/task.
|
|
||||||
static::saving(function (TimeEntry $timeEntry): void {
|
|
||||||
if ($timeEntry->type === TimeEntryType::Break) {
|
|
||||||
$timeEntry->billable = false;
|
|
||||||
$timeEntry->billable_rate = null;
|
|
||||||
$timeEntry->project_id = null;
|
|
||||||
$timeEntry->task_id = null;
|
|
||||||
$timeEntry->client_id = null;
|
|
||||||
$timeEntry->tags = [];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBillableRateComputed(): ?int
|
public function getBillableRateComputed(): ?int
|
||||||
{
|
{
|
||||||
return app(BillableRateService::class)->getBillableRateForTimeEntry($this);
|
return app(BillableRateService::class)->getBillableRateForTimeEntry($this);
|
||||||
@@ -199,16 +173,6 @@ class TimeEntry extends Model implements AuditableContract
|
|||||||
$builder->whereJsonContains('tags', $tag->getKey());
|
$builder->whereJsonContains('tags', $tag->getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Only work entries — breaks do not count toward tracked/billable time.
|
|
||||||
*
|
|
||||||
* @param Builder<TimeEntry> $builder
|
|
||||||
*/
|
|
||||||
public function scopeWorkTime(Builder $builder): void
|
|
||||||
{
|
|
||||||
$builder->where('type', '=', TimeEntryType::Work);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return BelongsTo<User, $this>
|
* @return BelongsTo<User, $this>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -38,14 +38,10 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
* @property string|null $pending_email
|
* @property string|null $pending_email
|
||||||
* @property Carbon|null $email_verified_at
|
* @property Carbon|null $email_verified_at
|
||||||
* @property string|null $password
|
* @property string|null $password
|
||||||
* @property string|null $remember_token
|
|
||||||
* @property string|null $two_factor_secret
|
* @property string|null $two_factor_secret
|
||||||
* @property string|null $two_factor_recovery_codes
|
|
||||||
* @property Carbon|null $two_factor_confirmed_at
|
|
||||||
* @property string $timezone
|
* @property string $timezone
|
||||||
* @property bool $is_placeholder
|
* @property bool $is_placeholder
|
||||||
* @property Weekday $week_start
|
* @property Weekday $week_start
|
||||||
* @property bool $send_time_entry_still_running_email
|
|
||||||
* @property string|null $profile_photo_path
|
* @property string|null $profile_photo_path
|
||||||
* @property-read Organization|null $currentOrganization
|
* @property-read Organization|null $currentOrganization
|
||||||
* @property-read string $profile_photo_url
|
* @property-read string $profile_photo_url
|
||||||
@@ -112,7 +108,6 @@ class User extends Authenticatable implements AuditableContract, FilamentUser, M
|
|||||||
'is_admin' => 'boolean',
|
'is_admin' => 'boolean',
|
||||||
'is_placeholder' => 'boolean',
|
'is_placeholder' => 'boolean',
|
||||||
'week_start' => Weekday::class,
|
'week_start' => Weekday::class,
|
||||||
'send_time_entry_still_running_email' => 'boolean',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +117,6 @@ class User extends Authenticatable implements AuditableContract, FilamentUser, M
|
|||||||
*/
|
*/
|
||||||
protected $attributes = [
|
protected $attributes = [
|
||||||
'week_start' => Weekday::Monday,
|
'week_start' => Weekday::Monday,
|
||||||
'send_time_entry_still_running_email' => true,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,9 +147,7 @@ class User extends Authenticatable implements AuditableContract, FilamentUser, M
|
|||||||
|
|
||||||
public function canAccessPanel(Panel $panel): bool
|
public function canAccessPanel(Panel $panel): bool
|
||||||
{
|
{
|
||||||
return $this->is_placeholder === false
|
return in_array($this->email, config('auth.super_admins', []), true) && $this->hasVerifiedEmail();
|
||||||
&& in_array($this->email, config('auth.super_admins', []), true)
|
|
||||||
&& $this->hasVerifiedEmail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isMemberOfOrganization(Organization $organization): bool
|
public function isMemberOfOrganization(Organization $organization): bool
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ use App\Service\BillingContract;
|
|||||||
use App\Service\IpLookup\IpLookupServiceContract;
|
use App\Service\IpLookup\IpLookupServiceContract;
|
||||||
use App\Service\IpLookup\NoIpLookupService;
|
use App\Service\IpLookup\NoIpLookupService;
|
||||||
use App\Service\PermissionStore;
|
use App\Service\PermissionStore;
|
||||||
use DateTimeInterface;
|
|
||||||
use Dedoc\Scramble\Scramble;
|
use Dedoc\Scramble\Scramble;
|
||||||
use Dedoc\Scramble\Support\Generator\OpenApi;
|
use Dedoc\Scramble\Support\Generator\OpenApi;
|
||||||
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
use Dedoc\Scramble\Support\Generator\SecurityScheme;
|
||||||
@@ -30,13 +29,8 @@ use Filament\Tables\Table;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Illuminate\Support\Facades\URL;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -104,27 +98,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
$this->app->bind(IpLookupServiceContract::class, NoIpLookupService::class);
|
$this->app->bind(IpLookupServiceContract::class, NoIpLookupService::class);
|
||||||
$this->app->bind(BillingContract::class);
|
$this->app->bind(BillingContract::class);
|
||||||
|
|
||||||
// Storage
|
|
||||||
// The local driver ignores the ResponseContentDisposition option of temporaryUrl,
|
|
||||||
// so mirror it through the signed query parameters of the storage route.
|
|
||||||
$privateDisk = config('filesystems.private');
|
|
||||||
if (config('filesystems.disks.'.$privateDisk.'.driver') === 'local') {
|
|
||||||
$disk = Storage::disk($privateDisk);
|
|
||||||
$disk->serveUsing(function (Request $request, string $path, array $headers) use ($disk): StreamedResponse {
|
|
||||||
return $disk->response($path, null, $headers, $request->query('disposition', 'inline'));
|
|
||||||
});
|
|
||||||
$disk->buildTemporaryUrlsUsing(function (string $path, DateTimeInterface $expiration, array $options) use ($privateDisk): string {
|
|
||||||
$parameters = array_filter([
|
|
||||||
'path' => $path,
|
|
||||||
'disposition' => isset($options['ResponseContentDisposition'])
|
|
||||||
? Str::before($options['ResponseContentDisposition'], ';')
|
|
||||||
: null,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return url(URL::temporarySignedRoute('storage.'.$privateDisk, $expiration, $parameters, absolute: false));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Routing
|
// Routing
|
||||||
Route::model('member', Member::class);
|
Route::model('member', Member::class);
|
||||||
Route::model('invitation', OrganizationInvitation::class);
|
Route::model('invitation', OrganizationInvitation::class);
|
||||||
|
|||||||
@@ -4,14 +4,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Auth\ActiveUserProvider;
|
|
||||||
use App\Models\Passport\AuthCode;
|
use App\Models\Passport\AuthCode;
|
||||||
use App\Models\Passport\Client;
|
use App\Models\Passport\Client;
|
||||||
use App\Models\Passport\RefreshToken;
|
use App\Models\Passport\RefreshToken;
|
||||||
use App\Models\Passport\Token;
|
use App\Models\Passport\Token;
|
||||||
use Illuminate\Contracts\Foundation\Application;
|
|
||||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Laravel\Passport\Passport;
|
use Laravel\Passport\Passport;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends ServiceProvider
|
||||||
@@ -29,13 +26,6 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
// Replaces the built-in eloquent user provider, so that no authentication flow can
|
|
||||||
// resolve a placeholder user. The driver name is kept, because Passport recognizes
|
|
||||||
// only providers that are configured with the driver "eloquent".
|
|
||||||
Auth::provider('eloquent', function (Application $app, array $config): ActiveUserProvider {
|
|
||||||
return new ActiveUserProvider($app->make('hash'), $config['model']);
|
|
||||||
});
|
|
||||||
|
|
||||||
// define scopes for passport tokens
|
// define scopes for passport tokens
|
||||||
Passport::tokensCan([
|
Passport::tokensCan([
|
||||||
'create' => 'Create resources',
|
'create' => 'Create resources',
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class FortifyServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
Fortify::registerView(function () {
|
Fortify::registerView(function () {
|
||||||
return Inertia::render('Auth/Register', [
|
return Inertia::render('Auth/Register', [
|
||||||
'email' => session('registration_email', ''),
|
|
||||||
'terms_url' => config('auth.terms_url'),
|
'terms_url' => config('auth.terms_url'),
|
||||||
'privacy_policy_url' => config('auth.privacy_policy_url'),
|
'privacy_policy_url' => config('auth.privacy_policy_url'),
|
||||||
'newsletter_consent' => config('auth.newsletter_consent'),
|
'newsletter_consent' => config('auth.newsletter_consent'),
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $request->user()
|
return $request->user()
|
||||||
? Limit::perMinute(config('app.api_rate_limit_authenticated_per_minute'))->by($request->user()->id)
|
? Limit::perMinute(200)->by($request->user()->id)
|
||||||
: Limit::perMinute(config('app.api_rate_limit_guest_per_minute'))->by($request->ip());
|
: Limit::perMinute(60)->by($request->ip());
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->routes(function (): void {
|
$this->routes(function (): void {
|
||||||
|
|||||||
@@ -54,13 +54,4 @@ class BillingContract
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the organization can set and see billable rates
|
|
||||||
* Without a billing system every organization can use billable rates
|
|
||||||
*/
|
|
||||||
public function canUseBillableRates(Organization $organization): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Service;
|
namespace App\Service;
|
||||||
|
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Enums\Weekday;
|
use App\Enums\Weekday;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
@@ -155,7 +154,6 @@ class DashboardService
|
|||||||
->select(DB::raw('DATE('.$dateWithTimeZone.') as date, round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
->select(DB::raw('DATE('.$dateWithTimeZone.') as date, round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
||||||
->where('user_id', '=', $user->getKey())
|
->where('user_id', '=', $user->getKey())
|
||||||
->where('organization_id', '=', $organization->getKey())
|
->where('organization_id', '=', $organization->getKey())
|
||||||
->workTime()
|
|
||||||
->groupBy(DB::raw('DATE('.$dateWithTimeZone.')'))
|
->groupBy(DB::raw('DATE('.$dateWithTimeZone.')'))
|
||||||
->orderBy('date');
|
->orderBy('date');
|
||||||
|
|
||||||
@@ -197,7 +195,6 @@ class DashboardService
|
|||||||
->select(DB::raw('DATE('.$dateWithTimeZone.') as date, round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
->select(DB::raw('DATE('.$dateWithTimeZone.') as date, round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
||||||
->where('user_id', '=', $user->getKey())
|
->where('user_id', '=', $user->getKey())
|
||||||
->where('organization_id', '=', $organization->getKey())
|
->where('organization_id', '=', $organization->getKey())
|
||||||
->workTime()
|
|
||||||
->groupBy(DB::raw('DATE('.$dateWithTimeZone.')'))
|
->groupBy(DB::raw('DATE('.$dateWithTimeZone.')'))
|
||||||
->orderBy('date');
|
->orderBy('date');
|
||||||
|
|
||||||
@@ -225,8 +222,7 @@ class DashboardService
|
|||||||
$query = TimeEntry::query()
|
$query = TimeEntry::query()
|
||||||
->select(DB::raw('round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
->select(DB::raw('round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
||||||
->where('user_id', '=', $user->getKey())
|
->where('user_id', '=', $user->getKey())
|
||||||
->where('organization_id', '=', $organization->getKey())
|
->where('organization_id', '=', $organization->getKey());
|
||||||
->workTime();
|
|
||||||
|
|
||||||
$query = $this->constrainDateByPossibleDates($query, $possibleDays, $timezone);
|
$query = $this->constrainDateByPossibleDates($query, $possibleDays, $timezone);
|
||||||
/** @var Collection<int, object{aggregate: int}> $resultDb */
|
/** @var Collection<int, object{aggregate: int}> $resultDb */
|
||||||
@@ -294,7 +290,6 @@ class DashboardService
|
|||||||
->select(DB::raw('project_id, round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
->select(DB::raw('project_id, round(sum(extract(epoch from (coalesce("end", now()) - start)))) as aggregate'))
|
||||||
->where('user_id', '=', $user->getKey())
|
->where('user_id', '=', $user->getKey())
|
||||||
->where('organization_id', '=', $organization->getKey())
|
->where('organization_id', '=', $organization->getKey())
|
||||||
->workTime()
|
|
||||||
->groupBy('project_id');
|
->groupBy('project_id');
|
||||||
|
|
||||||
$query = $this->constrainDateByCurrentWeek($query, $timezone, $user->week_start);
|
$query = $this->constrainDateByCurrentWeek($query, $timezone, $user->week_start);
|
||||||
@@ -438,8 +433,7 @@ class DashboardService
|
|||||||
JOIN time_entries ON time_entries.start < time_ranges."end"
|
JOIN time_entries ON time_entries.start < time_ranges."end"
|
||||||
AND coalesce(time_entries."end", :now::timestamp) > time_ranges.start
|
AND coalesce(time_entries."end", :now::timestamp) > time_ranges.start
|
||||||
WHERE time_entries.user_id = :user_id and
|
WHERE time_entries.user_id = :user_id and
|
||||||
time_entries.organization_id = :organization_id and
|
time_entries.organization_id = :organization_id
|
||||||
time_entries.type = :work_type
|
|
||||||
GROUP BY time_ranges.start
|
GROUP BY time_ranges.start
|
||||||
ORDER BY time_ranges.start
|
ORDER BY time_ranges.start
|
||||||
', [
|
', [
|
||||||
@@ -448,7 +442,6 @@ class DashboardService
|
|||||||
'user_id' => $user->getKey(),
|
'user_id' => $user->getKey(),
|
||||||
'organization_id' => $organization->getKey(),
|
'organization_id' => $organization->getKey(),
|
||||||
'now' => Carbon::now()->toDateTimeString(),
|
'now' => Carbon::now()->toDateTimeString(),
|
||||||
'work_type' => TimeEntryType::Work->value,
|
|
||||||
]))->pluck('aggregate', 'start');
|
]))->pluck('aggregate', 'start');
|
||||||
|
|
||||||
$response = [];
|
$response = [];
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use App\Enums\TagMatchType;
|
|||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||||
use App\Enums\TimeEntryRoundingType;
|
use App\Enums\TimeEntryRoundingType;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Enums\Weekday;
|
use App\Enums\Weekday;
|
||||||
use App\Service\TimeEntryFilter;
|
use App\Service\TimeEntryFilter;
|
||||||
use Illuminate\Contracts\Database\Eloquent\Castable;
|
use Illuminate\Contracts\Database\Eloquent\Castable;
|
||||||
@@ -69,8 +68,6 @@ class ReportPropertiesDto implements Castable
|
|||||||
|
|
||||||
public ?int $roundingMinutes = null;
|
public ?int $roundingMinutes = null;
|
||||||
|
|
||||||
public ?TimeEntryType $timeEntryType = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the caster class to use when casting from / to this cast target.
|
* Get the caster class to use when casting from / to this cast target.
|
||||||
*
|
*
|
||||||
@@ -132,12 +129,6 @@ class ReportPropertiesDto implements Castable
|
|||||||
$dto->roundingType = isset($data->roundingType) ? TimeEntryRoundingType::from($data->roundingType) : null;
|
$dto->roundingType = isset($data->roundingType) ? TimeEntryRoundingType::from($data->roundingType) : null;
|
||||||
// Note: roundingMinutes was added later so it is possible that the value is missing in persisted reports in the DB
|
// Note: roundingMinutes was added later so it is possible that the value is missing in persisted reports in the DB
|
||||||
$dto->roundingMinutes = isset($data->roundingMinutes) ? (int) $data->roundingMinutes : null;
|
$dto->roundingMinutes = isset($data->roundingMinutes) ? (int) $data->roundingMinutes : null;
|
||||||
// Note: timeEntryType was added later, reports persisted before that are missing the value and default to "work"
|
|
||||||
if (property_exists($data, 'timeEntryType')) {
|
|
||||||
$dto->timeEntryType = $data->timeEntryType !== null ? TimeEntryType::from($data->timeEntryType) : null;
|
|
||||||
} else {
|
|
||||||
$dto->timeEntryType = TimeEntryType::Work;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $dto;
|
return $dto;
|
||||||
}
|
}
|
||||||
@@ -166,7 +157,6 @@ class ReportPropertiesDto implements Castable
|
|||||||
'timezone' => $value->timezone,
|
'timezone' => $value->timezone,
|
||||||
'roundingType' => $value->roundingType?->value,
|
'roundingType' => $value->roundingType?->value,
|
||||||
'roundingMinutes' => $value->roundingMinutes,
|
'roundingMinutes' => $value->roundingMinutes,
|
||||||
'timeEntryType' => $value->timeEntryType?->value,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$jsonString = json_encode($data);
|
$jsonString = json_encode($data);
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ class ExportService
|
|||||||
'end',
|
'end',
|
||||||
'billable_rate',
|
'billable_rate',
|
||||||
'billable',
|
'billable',
|
||||||
'type',
|
|
||||||
'member_id',
|
'member_id',
|
||||||
'user_id',
|
'user_id',
|
||||||
'organization_id',
|
'organization_id',
|
||||||
@@ -132,7 +131,6 @@ class ExportService
|
|||||||
$timeEntry->end?->toIso8601ZuluString() ?? '',
|
$timeEntry->end?->toIso8601ZuluString() ?? '',
|
||||||
$timeEntry->billable_rate ?? '',
|
$timeEntry->billable_rate ?? '',
|
||||||
$timeEntry->billable ? 'true' : 'false',
|
$timeEntry->billable ? 'true' : 'false',
|
||||||
$timeEntry->type->value,
|
|
||||||
$timeEntry->member_id,
|
$timeEntry->member_id,
|
||||||
$timeEntry->user_id,
|
$timeEntry->user_id,
|
||||||
$timeEntry->organization_id,
|
$timeEntry->organization_id,
|
||||||
|
|||||||
@@ -9,8 +9,11 @@ use App\Service\Import\Importers\ImporterContract;
|
|||||||
use App\Service\Import\Importers\ImporterProvider;
|
use App\Service\Import\Importers\ImporterProvider;
|
||||||
use App\Service\Import\Importers\ImportException;
|
use App\Service\Import\Importers\ImportException;
|
||||||
use App\Service\Import\Importers\ReportDto;
|
use App\Service\Import\Importers\ReportDto;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class ImportService
|
class ImportService
|
||||||
{
|
{
|
||||||
@@ -22,6 +25,8 @@ class ImportService
|
|||||||
/** @var ImporterContract $importer */
|
/** @var ImporterContract $importer */
|
||||||
$importer = app(ImporterProvider::class)->getImporter($importerType);
|
$importer = app(ImporterProvider::class)->getImporter($importerType);
|
||||||
$importer->init($organization);
|
$importer->init($organization);
|
||||||
|
Storage::disk(config('filesystems.default'))
|
||||||
|
->put('import/'.Carbon::now()->toDateString().'-'.$organization->getKey().'-'.Str::uuid(), $data);
|
||||||
|
|
||||||
$lock = Cache::lock('import:'.$organization->getKey(), config('octane.max_execution_time', 60) + 1);
|
$lock = Cache::lock('import:'.$organization->getKey(), config('octane.max_execution_time', 60) + 1);
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Import\Importers;
|
namespace App\Service\Import\Importers;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Jobs\RecalculateSpentTimeForProject;
|
use App\Jobs\RecalculateSpentTimeForProject;
|
||||||
use App\Jobs\RecalculateSpentTimeForTask;
|
use App\Jobs\RecalculateSpentTimeForTask;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
@@ -72,12 +71,8 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
'role' => Role::Placeholder->value,
|
'role' => Role::Placeholder->value,
|
||||||
]);
|
]);
|
||||||
$member = $this->memberImportHelper->getModelById($memberId);
|
$member = $this->memberImportHelper->getModelById($memberId);
|
||||||
// Clockify allows a project/task/client/tags/billable on breaks, but those are
|
|
||||||
// meaningless for non-work time. Detect breaks up front and skip creating any of
|
|
||||||
// that so a break can't spawn an orphan project/tag or inflate the import counts.
|
|
||||||
$isBreak = isset($record['Type']) && strtolower($record['Type']) === 'break';
|
|
||||||
$clientId = null;
|
$clientId = null;
|
||||||
if (! $isBreak && ($record['Client'] ?? '') !== '') {
|
if (($record['Client'] ?? '') !== '') {
|
||||||
$clientId = $this->clientImportHelper->getKey([
|
$clientId = $this->clientImportHelper->getKey([
|
||||||
'name' => $record['Client'],
|
'name' => $record['Client'],
|
||||||
'organization_id' => $this->organization->id,
|
'organization_id' => $this->organization->id,
|
||||||
@@ -86,7 +81,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
$projectId = null;
|
$projectId = null;
|
||||||
$project = null;
|
$project = null;
|
||||||
$projectMember = null;
|
$projectMember = null;
|
||||||
if (! $isBreak && $record['Project'] !== '') {
|
if ($record['Project'] !== '') {
|
||||||
$projectId = $this->projectImportHelper->getKey([
|
$projectId = $this->projectImportHelper->getKey([
|
||||||
'name' => $record['Project'],
|
'name' => $record['Project'],
|
||||||
'client_id' => $clientId,
|
'client_id' => $clientId,
|
||||||
@@ -102,7 +97,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$taskId = null;
|
$taskId = null;
|
||||||
if (! $isBreak && $taskKey !== null && $record[$taskKey] !== '') {
|
if ($taskKey !== null && $record[$taskKey] !== '') {
|
||||||
$taskId = $this->taskImportHelper->getKey([
|
$taskId = $this->taskImportHelper->getKey([
|
||||||
'name' => $record[$taskKey],
|
'name' => $record[$taskKey],
|
||||||
'project_id' => $projectId,
|
'project_id' => $projectId,
|
||||||
@@ -128,12 +123,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
}
|
}
|
||||||
$timeEntry->billable = $record['Billable'] === 'Yes';
|
$timeEntry->billable = $record['Billable'] === 'Yes';
|
||||||
}
|
}
|
||||||
if ($isBreak) {
|
$timeEntry->tags = $this->getTags($record['Tags']);
|
||||||
// Breaks can not be billable or belong to a project/task (already skipped above)
|
|
||||||
$timeEntry->type = TimeEntryType::Break;
|
|
||||||
$timeEntry->billable = false;
|
|
||||||
}
|
|
||||||
$timeEntry->tags = $isBreak ? [] : $this->getTags($record['Tags']);
|
|
||||||
$timeEntry->is_imported = true;
|
$timeEntry->is_imported = true;
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Service\BillableRateService;
|
use App\Service\BillableRateService;
|
||||||
use App\Service\BillingContract;
|
|
||||||
use App\Service\ColorService;
|
use App\Service\ColorService;
|
||||||
use App\Service\Import\ImportDatabaseHelper;
|
use App\Service\Import\ImportDatabaseHelper;
|
||||||
use App\Service\TimezoneService;
|
use App\Service\TimezoneService;
|
||||||
@@ -72,15 +71,9 @@ abstract class DefaultImporter implements ImporterContract
|
|||||||
|
|
||||||
protected BillableRateService $billableRateService;
|
protected BillableRateService $billableRateService;
|
||||||
|
|
||||||
/**
|
|
||||||
* Organizations that can not use billable rates import projects, members and project members without billable rates
|
|
||||||
*/
|
|
||||||
protected bool $canUseBillableRates;
|
|
||||||
|
|
||||||
public function init(Organization $organization): void
|
public function init(Organization $organization): void
|
||||||
{
|
{
|
||||||
$this->organization = $organization;
|
$this->organization = $organization;
|
||||||
$this->canUseBillableRates = app(BillingContract::class)->canUseBillableRates($organization);
|
|
||||||
$this->userImportHelper = new ImportDatabaseHelper(User::class, ['email'], true, function (Builder $builder) {
|
$this->userImportHelper = new ImportDatabaseHelper(User::class, ['email'], true, function (Builder $builder) {
|
||||||
/** @var Builder<User> $builder */
|
/** @var Builder<User> $builder */
|
||||||
return $builder->belongsToOrganization($this->organization);
|
return $builder->belongsToOrganization($this->organization);
|
||||||
@@ -103,11 +96,7 @@ abstract class DefaultImporter implements ImporterContract
|
|||||||
'string',
|
'string',
|
||||||
'in:placeholder',
|
'in:placeholder',
|
||||||
],
|
],
|
||||||
], beforeSave: function (Member $member): void {
|
]);
|
||||||
if (! $this->canUseBillableRates) {
|
|
||||||
$member->billable_rate = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$this->projectImportHelper = new ImportDatabaseHelper(Project::class, ['name', 'client_id', 'organization_id'], true, function (Builder $builder) {
|
$this->projectImportHelper = new ImportDatabaseHelper(Project::class, ['name', 'client_id', 'organization_id'], true, function (Builder $builder) {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
return $builder->where('organization_id', $this->organization->id);
|
return $builder->where('organization_id', $this->organization->id);
|
||||||
@@ -131,7 +120,7 @@ abstract class DefaultImporter implements ImporterContract
|
|||||||
'uuid',
|
'uuid',
|
||||||
],
|
],
|
||||||
], beforeSave: function (Project $project): void {
|
], beforeSave: function (Project $project): void {
|
||||||
if ($project->billable_rate === 0 || ! $this->canUseBillableRates) {
|
if ($project->billable_rate === 0) {
|
||||||
$project->billable_rate = null;
|
$project->billable_rate = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -145,7 +134,7 @@ abstract class DefaultImporter implements ImporterContract
|
|||||||
'max:2147483647',
|
'max:2147483647',
|
||||||
],
|
],
|
||||||
], beforeSave: function (ProjectMember $projectMember): void {
|
], beforeSave: function (ProjectMember $projectMember): void {
|
||||||
if ($projectMember->billable_rate === 0 || ! $this->canUseBillableRates) {
|
if ($projectMember->billable_rate === 0) {
|
||||||
$projectMember->billable_rate = null;
|
$projectMember->billable_rate = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\Import\Importers;
|
namespace App\Service\Import\Importers;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Jobs\RecalculateSpentTimeForProject;
|
use App\Jobs\RecalculateSpentTimeForProject;
|
||||||
use App\Jobs\RecalculateSpentTimeForTask;
|
use App\Jobs\RecalculateSpentTimeForTask;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
@@ -16,6 +15,7 @@ use Illuminate\Support\Str;
|
|||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
use Override;
|
use Override;
|
||||||
use Spatie\TemporaryDirectory\TemporaryDirectory;
|
use Spatie\TemporaryDirectory\TemporaryDirectory;
|
||||||
|
use ZipArchive;
|
||||||
|
|
||||||
class SolidtimeImporter extends DefaultImporter
|
class SolidtimeImporter extends DefaultImporter
|
||||||
{
|
{
|
||||||
@@ -33,10 +33,16 @@ class SolidtimeImporter extends DefaultImporter
|
|||||||
$temporaryDirectoryZip = null;
|
$temporaryDirectoryZip = null;
|
||||||
$temporaryDirectory = null;
|
$temporaryDirectory = null;
|
||||||
try {
|
try {
|
||||||
|
$zip = new ZipArchive;
|
||||||
$temporaryDirectoryZip = TemporaryDirectory::make();
|
$temporaryDirectoryZip = TemporaryDirectory::make();
|
||||||
file_put_contents($temporaryDirectoryZip->path('import.zip'), $data);
|
file_put_contents($temporaryDirectoryZip->path('import.zip'), $data);
|
||||||
|
$res = $zip->open($temporaryDirectoryZip->path('import.zip'), ZipArchive::RDONLY);
|
||||||
|
if ($res !== true) {
|
||||||
|
throw new ImportException('Invalid ZIP, error code: '.$res);
|
||||||
|
}
|
||||||
$temporaryDirectory = TemporaryDirectory::make();
|
$temporaryDirectory = TemporaryDirectory::make();
|
||||||
app(ZipImportHelper::class)->extract($temporaryDirectoryZip->path('import.zip'), $temporaryDirectory->path());
|
$zip->extractTo($temporaryDirectory->path());
|
||||||
|
$zip->close();
|
||||||
|
|
||||||
if (! file_exists($temporaryDirectory->path('meta.json'))) {
|
if (! file_exists($temporaryDirectory->path('meta.json'))) {
|
||||||
throw new ImportException('File "meta.json" missing in ZIP');
|
throw new ImportException('File "meta.json" missing in ZIP');
|
||||||
@@ -249,14 +255,6 @@ class SolidtimeImporter extends DefaultImporter
|
|||||||
throw new ImportException('Invalid billable value');
|
throw new ImportException('Invalid billable value');
|
||||||
}
|
}
|
||||||
$timeEntry->billable = $timeEntryRow['billable'] === 'true';
|
$timeEntry->billable = $timeEntryRow['billable'] === 'true';
|
||||||
// The type column does not exist in old exports
|
|
||||||
if (($timeEntryRow['type'] ?? '') !== '') {
|
|
||||||
$type = TimeEntryType::tryFrom($timeEntryRow['type']);
|
|
||||||
if ($type === null) {
|
|
||||||
throw new ImportException('Invalid type value');
|
|
||||||
}
|
|
||||||
$timeEntry->type = $type;
|
|
||||||
}
|
|
||||||
$timeEntry->tags = $this->getTags($timeEntryRow['tags']);
|
$timeEntry->tags = $this->getTags($timeEntryRow['tags']);
|
||||||
$timeEntry->is_imported = true;
|
$timeEntry->is_imported = true;
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use Illuminate\Support\Str;
|
|||||||
use Override;
|
use Override;
|
||||||
use Spatie\TemporaryDirectory\TemporaryDirectory;
|
use Spatie\TemporaryDirectory\TemporaryDirectory;
|
||||||
use ValueError;
|
use ValueError;
|
||||||
|
use ZipArchive;
|
||||||
|
|
||||||
class TogglDataImporter extends DefaultImporter
|
class TogglDataImporter extends DefaultImporter
|
||||||
{
|
{
|
||||||
@@ -25,10 +26,16 @@ class TogglDataImporter extends DefaultImporter
|
|||||||
$temporaryDirectoryZip = null;
|
$temporaryDirectoryZip = null;
|
||||||
$temporaryDirectory = null;
|
$temporaryDirectory = null;
|
||||||
try {
|
try {
|
||||||
|
$zip = new ZipArchive;
|
||||||
$temporaryDirectoryZip = TemporaryDirectory::make();
|
$temporaryDirectoryZip = TemporaryDirectory::make();
|
||||||
file_put_contents($temporaryDirectoryZip->path('import.zip'), $data);
|
file_put_contents($temporaryDirectoryZip->path('import.zip'), $data);
|
||||||
|
$res = $zip->open($temporaryDirectoryZip->path('import.zip'), ZipArchive::RDONLY);
|
||||||
|
if ($res !== true) {
|
||||||
|
throw new ImportException('Invalid ZIP, error code: '.$res);
|
||||||
|
}
|
||||||
$temporaryDirectory = TemporaryDirectory::make();
|
$temporaryDirectory = TemporaryDirectory::make();
|
||||||
app(ZipImportHelper::class)->extract($temporaryDirectoryZip->path('import.zip'), $temporaryDirectory->path());
|
$zip->extractTo($temporaryDirectory->path());
|
||||||
|
$zip->close();
|
||||||
if (! file_exists($temporaryDirectory->path('clients.json'))) {
|
if (! file_exists($temporaryDirectory->path('clients.json'))) {
|
||||||
throw new ImportException('File "clients.json" missing in ZIP');
|
throw new ImportException('File "clients.json" missing in ZIP');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,129 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service\Import\Importers;
|
|
||||||
|
|
||||||
use ZipArchive;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts uploaded ZIP archives with limits on file count, total uncompressed
|
|
||||||
* size and entry paths, so a small malicious archive can not fill the disk
|
|
||||||
* (decompression bomb) or write outside the target directory (zip slip).
|
|
||||||
*/
|
|
||||||
class ZipImportHelper
|
|
||||||
{
|
|
||||||
private const int CHUNK_SIZE = 1024 * 1024;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
public function extract(string $zipPath, string $targetPath): void
|
|
||||||
{
|
|
||||||
$zip = new ZipArchive;
|
|
||||||
$res = $zip->open($zipPath, ZipArchive::RDONLY);
|
|
||||||
if ($res !== true) {
|
|
||||||
throw new ImportException('Invalid ZIP, error code: '.$res);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$maxFiles = (int) config('import.zip_max_files');
|
|
||||||
$maxUncompressedSize = (int) config('import.zip_max_uncompressed_size');
|
|
||||||
|
|
||||||
if ($zip->numFiles > $maxFiles) {
|
|
||||||
throw new ImportException('ZIP contains too many files, maximum is '.$maxFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check the sizes declared in the archive before writing anything to disk
|
|
||||||
$declaredSize = 0;
|
|
||||||
for ($index = 0; $index < $zip->numFiles; $index++) {
|
|
||||||
$stat = $zip->statIndex($index);
|
|
||||||
if ($stat === false) {
|
|
||||||
throw new ImportException('Invalid ZIP entry');
|
|
||||||
}
|
|
||||||
$this->validateEntryName($stat['name']);
|
|
||||||
$declaredSize += $stat['size'];
|
|
||||||
if ($declaredSize > $maxUncompressedSize) {
|
|
||||||
throw new ImportException('ZIP uncompressed size exceeds the maximum of '.$maxUncompressedSize.' bytes');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The declared sizes can be forged, so the written bytes are counted as well
|
|
||||||
$writtenSize = 0;
|
|
||||||
for ($index = 0; $index < $zip->numFiles; $index++) {
|
|
||||||
$stat = $zip->statIndex($index);
|
|
||||||
if ($stat === false) {
|
|
||||||
throw new ImportException('Invalid ZIP entry');
|
|
||||||
}
|
|
||||||
$name = $stat['name'];
|
|
||||||
$entryPath = $targetPath.DIRECTORY_SEPARATOR.$name;
|
|
||||||
|
|
||||||
if (str_ends_with($name, '/')) {
|
|
||||||
$this->ensureDirectoryExists($entryPath);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->ensureDirectoryExists(dirname($entryPath));
|
|
||||||
|
|
||||||
$stream = $zip->getStreamIndex($index);
|
|
||||||
if ($stream === false) {
|
|
||||||
throw new ImportException('ZIP entry "'.$name.'" can not be read');
|
|
||||||
}
|
|
||||||
$target = fopen($entryPath, 'wb');
|
|
||||||
if ($target === false) {
|
|
||||||
fclose($stream);
|
|
||||||
throw new ImportException('ZIP entry "'.$name.'" can not be extracted');
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
while (! feof($stream)) {
|
|
||||||
$chunk = fread($stream, self::CHUNK_SIZE);
|
|
||||||
if ($chunk === false) {
|
|
||||||
throw new ImportException('ZIP entry "'.$name.'" can not be read');
|
|
||||||
}
|
|
||||||
$writtenSize += strlen($chunk);
|
|
||||||
if ($writtenSize > $maxUncompressedSize) {
|
|
||||||
throw new ImportException('ZIP uncompressed size exceeds the maximum of '.$maxUncompressedSize.' bytes');
|
|
||||||
}
|
|
||||||
fwrite($target, $chunk);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
fclose($target);
|
|
||||||
fclose($stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
$zip->close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function validateEntryName(string $name): void
|
|
||||||
{
|
|
||||||
if ($name === '' || str_contains($name, "\0") || str_contains($name, '\\') || str_starts_with($name, '/')) {
|
|
||||||
throw new ImportException('ZIP contains an invalid file path: "'.$name.'"');
|
|
||||||
}
|
|
||||||
if (preg_match('/^[a-zA-Z]:/', $name) === 1) {
|
|
||||||
throw new ImportException('ZIP contains an invalid file path: "'.$name.'"');
|
|
||||||
}
|
|
||||||
foreach (explode('/', rtrim($name, '/')) as $segment) {
|
|
||||||
if ($segment === '' || $segment === '..') {
|
|
||||||
throw new ImportException('ZIP contains an invalid file path: "'.$name.'"');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function ensureDirectoryExists(string $path): void
|
|
||||||
{
|
|
||||||
if (is_dir($path)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (! mkdir($path, 0700, true) && ! is_dir($path)) {
|
|
||||||
throw new ImportException('Directory "'.$path.'" can not be created');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,31 +18,11 @@ use Illuminate\Support\Facades\Mail;
|
|||||||
|
|
||||||
class InvitationService
|
class InvitationService
|
||||||
{
|
{
|
||||||
public function hasAcceptedInvitationForEmail(string $email): bool
|
|
||||||
{
|
|
||||||
return OrganizationInvitation::query()
|
|
||||||
->whereRaw('lower(email) = ?', [strtolower($email)])
|
|
||||||
->whereNotNull('accepted_at')
|
|
||||||
->exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasPendingInvitationForEmail(string $email): bool
|
|
||||||
{
|
|
||||||
return OrganizationInvitation::query()
|
|
||||||
->whereRaw('lower(email) = ?', [strtolower($email)])
|
|
||||||
->whereNull('accepted_at')
|
|
||||||
->exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws UserIsAlreadyMemberOfOrganizationApiException|InvitationForTheEmailAlreadyExistsApiException
|
* @throws UserIsAlreadyMemberOfOrganizationApiException|InvitationForTheEmailAlreadyExistsApiException
|
||||||
*/
|
*/
|
||||||
public function inviteUser(Organization $organization, string $email, Role $role, User $inviter): OrganizationInvitation
|
public function inviteUser(Organization $organization, string $email, Role $role, User $inviter): OrganizationInvitation
|
||||||
{
|
{
|
||||||
// Normalize the email so it matches how user emails are stored (see UserService::createUser),
|
|
||||||
// otherwise a mixed-case invite silently fails to link on registration.
|
|
||||||
$email = strtolower($email);
|
|
||||||
|
|
||||||
if (app(MemberService::class)->isEmailAlreadyMember($organization, $email)) {
|
if (app(MemberService::class)->isEmailAlreadyMember($organization, $email)) {
|
||||||
throw new UserIsAlreadyMemberOfOrganizationApiException;
|
throw new UserIsAlreadyMemberOfOrganizationApiException;
|
||||||
}
|
}
|
||||||
@@ -75,7 +55,7 @@ class InvitationService
|
|||||||
$organizations = new Collection;
|
$organizations = new Collection;
|
||||||
|
|
||||||
$invitations = OrganizationInvitation::query()
|
$invitations = OrganizationInvitation::query()
|
||||||
->whereRaw('lower(email) = ?', [strtolower($user->email)])
|
->where('email', $user->email)
|
||||||
->whereNotNull('accepted_at')
|
->whereNotNull('accepted_at')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,12 @@ use App\Enums\CurrencyFormat;
|
|||||||
use App\Enums\DateFormat;
|
use App\Enums\DateFormat;
|
||||||
use App\Enums\IntervalFormat;
|
use App\Enums\IntervalFormat;
|
||||||
use App\Enums\NumberFormat;
|
use App\Enums\NumberFormat;
|
||||||
use App\Enums\TimeEntryAggregationType;
|
|
||||||
use App\Enums\TimeFormat;
|
use App\Enums\TimeFormat;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Brick\Math\BigDecimal;
|
use Brick\Math\BigDecimal;
|
||||||
use Brick\Money\Money;
|
use Brick\Money\Money;
|
||||||
use Carbon\CarbonInterface;
|
use Carbon\CarbonInterface;
|
||||||
use Carbon\CarbonInterval;
|
use Carbon\CarbonInterval;
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
|
|
||||||
class LocalizationService
|
class LocalizationService
|
||||||
{
|
{
|
||||||
@@ -154,38 +152,6 @@ class LocalizationService
|
|||||||
return $date->format($this->dateFormat->toCarbonFormat());
|
return $date->format($this->dateFormat->toCarbonFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Time group types have no server-side descriptor; their keys are ISO dates and are
|
|
||||||
* formatted here instead. A Week key is the first day of that week, so it renders as the
|
|
||||||
* range it covers. A Year key is already a bare year, so it is returned unchanged - it must
|
|
||||||
* not be parsed, Carbon reads a four digit string as a time of day.
|
|
||||||
*/
|
|
||||||
public function formatTimeGroupKey(?string $key, TimeEntryAggregationType $groupType): ?string
|
|
||||||
{
|
|
||||||
if ($key === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($groupType === TimeEntryAggregationType::Day) {
|
|
||||||
return $this->formatDate(Carbon::parse($key));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($groupType === TimeEntryAggregationType::Week) {
|
|
||||||
$weekStart = Carbon::parse($key);
|
|
||||||
|
|
||||||
return $this->formatDate($weekStart).' - '.$this->formatDate($weekStart->copy()->addDays(6));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($groupType === TimeEntryAggregationType::Month) {
|
|
||||||
// Note: the leading "!" resets all fields the format does not name. Without it the
|
|
||||||
// day of the month is taken from today, and a day that the parsed month does not
|
|
||||||
// have overflows the date into the next month.
|
|
||||||
return Carbon::createFromFormat('!Y-m', $key)->format('F Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDateFormat(DateFormat $dateFormat): void
|
public function setDateFormat(DateFormat $dateFormat): void
|
||||||
{
|
{
|
||||||
$this->dateFormat = $dateFormat;
|
$this->dateFormat = $dateFormat;
|
||||||
|
|||||||
@@ -218,16 +218,7 @@ class MemberService
|
|||||||
|
|
||||||
$placeholderUser = $user->replicate();
|
$placeholderUser = $user->replicate();
|
||||||
$placeholderUser->is_placeholder = true;
|
$placeholderUser->is_placeholder = true;
|
||||||
// Reset authentication relevant properties on the placeholder user
|
$placeholderUser->current_team_id = $member->organization_id;
|
||||||
$placeholderUser->password = null;
|
|
||||||
$placeholderUser->remember_token = null;
|
|
||||||
$placeholderUser->two_factor_secret = null;
|
|
||||||
$placeholderUser->two_factor_recovery_codes = null;
|
|
||||||
$placeholderUser->two_factor_confirmed_at = null;
|
|
||||||
$placeholderUser->email_verified_at = null;
|
|
||||||
$placeholderUser->pending_email = null;
|
|
||||||
$placeholderUser->current_team_id = null;
|
|
||||||
$placeholderUser->profile_photo_path = null;
|
|
||||||
$placeholderUser->save();
|
$placeholderUser->save();
|
||||||
|
|
||||||
$member->user()->associate($placeholderUser);
|
$member->user()->associate($placeholderUser);
|
||||||
|
|||||||
@@ -80,10 +80,6 @@ class PermissionStore
|
|||||||
'invoices:update',
|
'invoices:update',
|
||||||
'invoices:download',
|
'invoices:download',
|
||||||
'invoices:delete',
|
'invoices:delete',
|
||||||
'invoice-recipients:view',
|
|
||||||
'invoice-recipients:create',
|
|
||||||
'invoice-recipients:update',
|
|
||||||
'invoice-recipients:delete',
|
|
||||||
'invoice-settings:view',
|
'invoice-settings:view',
|
||||||
'invoice-settings:update',
|
'invoice-settings:update',
|
||||||
],
|
],
|
||||||
@@ -151,10 +147,6 @@ class PermissionStore
|
|||||||
'invoices:update',
|
'invoices:update',
|
||||||
'invoices:download',
|
'invoices:download',
|
||||||
'invoices:delete',
|
'invoices:delete',
|
||||||
'invoice-recipients:view',
|
|
||||||
'invoice-recipients:create',
|
|
||||||
'invoice-recipients:update',
|
|
||||||
'invoice-recipients:delete',
|
|
||||||
'invoice-settings:view',
|
'invoice-settings:view',
|
||||||
'invoice-settings:update',
|
'invoice-settings:update',
|
||||||
],
|
],
|
||||||
@@ -211,10 +203,6 @@ class PermissionStore
|
|||||||
'invoices:update',
|
'invoices:update',
|
||||||
'invoices:download',
|
'invoices:download',
|
||||||
'invoices:delete',
|
'invoices:delete',
|
||||||
'invoice-recipients:view',
|
|
||||||
'invoice-recipients:create',
|
|
||||||
'invoice-recipients:update',
|
|
||||||
'invoice-recipients:delete',
|
|
||||||
'invoice-settings:view',
|
'invoice-settings:view',
|
||||||
'invoice-settings:update',
|
'invoice-settings:update',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Service\ReportExport;
|
namespace App\Service\ReportExport;
|
||||||
|
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Service\IntervalService;
|
use App\Service\IntervalService;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
@@ -26,7 +25,6 @@ class TimeEntriesDetailedCsvExport extends CsvExport
|
|||||||
'Duration',
|
'Duration',
|
||||||
'Duration (decimal)',
|
'Duration (decimal)',
|
||||||
'Billable',
|
'Billable',
|
||||||
'Break',
|
|
||||||
'Tags',
|
'Tags',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -60,7 +58,6 @@ class TimeEntriesDetailedCsvExport extends CsvExport
|
|||||||
'Duration' => $duration !== null ? $interval->format($model->getDuration()) : null,
|
'Duration' => $duration !== null ? $interval->format($model->getDuration()) : null,
|
||||||
'Duration (decimal)' => $duration?->totalHours,
|
'Duration (decimal)' => $duration?->totalHours,
|
||||||
'Billable' => $model->billable ? 'Yes' : 'No',
|
'Billable' => $model->billable ? 'Yes' : 'No',
|
||||||
'Break' => $model->type === TimeEntryType::Break ? 'Yes' : 'No',
|
|
||||||
'Tags' => $model->tagsRelation->pluck('name')->implode(', '),
|
'Tags' => $model->tagsRelation->pluck('name')->implode(', '),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Service\ReportExport;
|
namespace App\Service\ReportExport;
|
||||||
|
|
||||||
use App\Enums\ExportFormat;
|
use App\Enums\ExportFormat;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Service\LocalizationService;
|
use App\Service\LocalizationService;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
@@ -107,7 +106,6 @@ class TimeEntriesDetailedExport implements FromQuery, ShouldAutoSize, WithColumn
|
|||||||
'Duration',
|
'Duration',
|
||||||
'Duration (decimal)',
|
'Duration (decimal)',
|
||||||
'Billable',
|
'Billable',
|
||||||
'Break',
|
|
||||||
'Tags',
|
'Tags',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -132,7 +130,6 @@ class TimeEntriesDetailedExport implements FromQuery, ShouldAutoSize, WithColumn
|
|||||||
$duration !== null ? $this->localizationService->formatInterval($duration) : null,
|
$duration !== null ? $this->localizationService->formatInterval($duration) : null,
|
||||||
$duration?->totalHours,
|
$duration?->totalHours,
|
||||||
$model->billable ? 'Yes' : 'No',
|
$model->billable ? 'Yes' : 'No',
|
||||||
$model->type === TimeEntryType::Break ? 'Yes' : 'No',
|
|
||||||
$model->tagsRelation->pluck('name')->implode(', '),
|
$model->tagsRelation->pluck('name')->implode(', '),
|
||||||
];
|
];
|
||||||
} elseif ($this->exportFormat === ExportFormat::ODS) {
|
} elseif ($this->exportFormat === ExportFormat::ODS) {
|
||||||
@@ -147,7 +144,6 @@ class TimeEntriesDetailedExport implements FromQuery, ShouldAutoSize, WithColumn
|
|||||||
$duration !== null ? $this->localizationService->formatInterval($duration) : null,
|
$duration !== null ? $this->localizationService->formatInterval($duration) : null,
|
||||||
$duration?->totalHours,
|
$duration?->totalHours,
|
||||||
$model->billable ? 'Yes' : 'No',
|
$model->billable ? 'Yes' : 'No',
|
||||||
$model->type === TimeEntryType::Break ? 'Yes' : 'No',
|
|
||||||
$model->tagsRelation->pluck('name')->implode(', '),
|
$model->tagsRelation->pluck('name')->implode(', '),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace App\Service\ReportExport;
|
|||||||
|
|
||||||
use App\Enums\ExportFormat;
|
use App\Enums\ExportFormat;
|
||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Service\LocalizationService;
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Maatwebsite\Excel\Concerns\Exportable;
|
use Maatwebsite\Excel\Concerns\Exportable;
|
||||||
use Maatwebsite\Excel\Concerns\FromView;
|
use Maatwebsite\Excel\Concerns\FromView;
|
||||||
@@ -49,8 +48,6 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
|
|||||||
|
|
||||||
private bool $showBillableRate;
|
private bool $showBillableRate;
|
||||||
|
|
||||||
private LocalizationService $localization;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{
|
* @param array{
|
||||||
* grouped_type: string|null,
|
* grouped_type: string|null,
|
||||||
@@ -71,7 +68,7 @@ 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, bool $showBillableRate, LocalizationService $localization)
|
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;
|
||||||
@@ -79,7 +76,6 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
|
|||||||
$this->group = $group;
|
$this->group = $group;
|
||||||
$this->subGroup = $subGroup;
|
$this->subGroup = $subGroup;
|
||||||
$this->showBillableRate = $showBillableRate;
|
$this->showBillableRate = $showBillableRate;
|
||||||
$this->localization = $localization;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function view(): View
|
public function view(): View
|
||||||
@@ -91,7 +87,6 @@ class TimeEntriesReportExport implements FromView, ShouldAutoSize, WithCustomCsv
|
|||||||
'subGroup' => $this->subGroup,
|
'subGroup' => $this->subGroup,
|
||||||
'exportFormat' => $this->exportFormat,
|
'exportFormat' => $this->exportFormat,
|
||||||
'showBillableRate' => $this->showBillableRate,
|
'showBillableRate' => $this->showBillableRate,
|
||||||
'localization' => $this->localization,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,13 +353,6 @@ class TimeEntryAggregationService
|
|||||||
'color' => null,
|
'color' => null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
} elseif ($type === TimeEntryAggregationType::Type) {
|
|
||||||
foreach ($keys as $key) {
|
|
||||||
$descriptorMap[$key] = [
|
|
||||||
'description' => $key === 'break' ? 'Break' : 'Work time',
|
|
||||||
'color' => null,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} elseif ($type === TimeEntryAggregationType::Tag) {
|
} elseif ($type === TimeEntryAggregationType::Tag) {
|
||||||
$tags = Tag::query()
|
$tags = Tag::query()
|
||||||
->whereIn('id', $keys)
|
->whereIn('id', $keys)
|
||||||
@@ -511,8 +504,6 @@ class TimeEntryAggregationService
|
|||||||
return 'client_id';
|
return 'client_id';
|
||||||
} elseif ($group === TimeEntryAggregationType::Billable) {
|
} elseif ($group === TimeEntryAggregationType::Billable) {
|
||||||
return 'billable';
|
return 'billable';
|
||||||
} elseif ($group === TimeEntryAggregationType::Type) {
|
|
||||||
return 'type';
|
|
||||||
} elseif ($group === TimeEntryAggregationType::Description) {
|
} elseif ($group === TimeEntryAggregationType::Description) {
|
||||||
return 'description';
|
return 'description';
|
||||||
} elseif ($group === TimeEntryAggregationType::Tag) {
|
} elseif ($group === TimeEntryAggregationType::Tag) {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Service;
|
namespace App\Service;
|
||||||
|
|
||||||
use App\Enums\TagMatchType;
|
use App\Enums\TagMatchType;
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
@@ -145,32 +144,6 @@ class TimeEntryFilter
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTypeFilter(?string $type): self
|
|
||||||
{
|
|
||||||
if ($type === null) {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
$typeEnum = TimeEntryType::tryFrom($type);
|
|
||||||
if ($typeEnum === null) {
|
|
||||||
Log::warning('Invalid type filter value', ['value' => $type]);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
$this->addType($typeEnum);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addType(?TimeEntryType $type): self
|
|
||||||
{
|
|
||||||
if ($type === null) {
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
$this->builder->where('type', '=', $type->value);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string>|null $clientIds
|
* @param array<string>|null $clientIds
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -75,32 +75,11 @@ return [
|
|||||||
|
|
||||||
'url' => env('APP_URL', 'http://localhost'),
|
'url' => env('APP_URL', 'http://localhost'),
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Trusted Hosts
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Additional hostnames (besides the APP_URL host and its subdomains) that
|
|
||||||
| the application is allowed to respond on. This is needed for multi-host
|
|
||||||
| setups, e.g. reaching the instance over both a public domain and a
|
|
||||||
| Tailscale name. A request arriving on any host that is neither APP_URL
|
|
||||||
| (nor a subdomain of it) nor listed here is rejected, which prevents
|
|
||||||
| Host-header poisoning of password reset and other out-of-band links.
|
|
||||||
|
|
|
||||||
| See App\Http\Middleware\TrustHosts.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'trusted_hosts' => array_values(array_filter(array_map(
|
|
||||||
'trim',
|
|
||||||
explode(',', (string) env('TRUSTED_HOSTS', ''))
|
|
||||||
))),
|
|
||||||
|
|
||||||
'asset_url' => env('ASSET_URL'),
|
'asset_url' => env('ASSET_URL'),
|
||||||
|
|
||||||
'force_https' => (bool) env('APP_FORCE_HTTPS', false),
|
'force_https' => (bool) env('APP_FORCE_HTTPS', false),
|
||||||
|
|
||||||
'enable_registration' => env('APP_ENABLE_REGISTRATION', 'off'),
|
'enable_registration' => (bool) env('APP_ENABLE_REGISTRATION', false),
|
||||||
|
|
||||||
'local_email_verification' => (bool) env('APP_LOCAL_EMAIL_VERIFICATION', false),
|
'local_email_verification' => (bool) env('APP_LOCAL_EMAIL_VERIFICATION', false),
|
||||||
|
|
||||||
@@ -158,21 +137,6 @@ return [
|
|||||||
|
|
||||||
'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15),
|
'pagination_per_page_default' => (int) env('PAGINATION_PER_PAGE_DEFAULT', 15),
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| API Rate Limiting
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| The number of API requests allowed per minute, counted per user for
|
|
||||||
| authenticated requests and per IP address for guest requests. These
|
|
||||||
| limits are only enforced when the application runs in production.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'api_rate_limit_authenticated_per_minute' => (int) (env('API_RATE_LIMIT_AUTH_PER_MINUTE') ?: 200),
|
|
||||||
|
|
||||||
'api_rate_limit_guest_per_minute' => (int) (env('API_RATE_LIMIT_GUEST_PER_MINUTE') ?: 60),
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Encryption Key
|
| Encryption Key
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
return [
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Import payload limit
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Maximum length of the base64 encoded "data" field of an import request in
|
|
||||||
| bytes. Requests with a larger payload are rejected with a validation error.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'max_data_size' => (int) (env('IMPORT_MAX_DATA_SIZE') ?: 50 * 1024 * 1024),
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| ZIP extraction limits
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Limits applied to ZIP based importers before and during extraction to
|
|
||||||
| protect the instance against decompression bombs. The uncompressed size
|
|
||||||
| is the sum of all files in the archive in bytes.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'zip_max_files' => (int) (env('IMPORT_ZIP_MAX_FILES') ?: 100),
|
|
||||||
|
|
||||||
'zip_max_uncompressed_size' => (int) (env('IMPORT_ZIP_MAX_UNCOMPRESSED_SIZE') ?: 500 * 1024 * 1024),
|
|
||||||
|
|
||||||
];
|
|
||||||
@@ -33,7 +33,6 @@ class OrganizationFactory extends Factory
|
|||||||
'user_id' => User::factory(),
|
'user_id' => User::factory(),
|
||||||
'personal_team' => true,
|
'personal_team' => true,
|
||||||
'employees_can_see_billable_rates' => false,
|
'employees_can_see_billable_rates' => false,
|
||||||
'breaks_enabled' => false,
|
|
||||||
'number_format' => $this->faker->randomElement(NumberFormat::values()),
|
'number_format' => $this->faker->randomElement(NumberFormat::values()),
|
||||||
'currency_format' => $this->faker->randomElement(CurrencyFormat::values()),
|
'currency_format' => $this->faker->randomElement(CurrencyFormat::values()),
|
||||||
'date_format' => $this->faker->randomElement(DateFormat::values()),
|
'date_format' => $this->faker->randomElement(DateFormat::values()),
|
||||||
@@ -56,13 +55,6 @@ class OrganizationFactory extends Factory
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withBreaksEnabled(): self
|
|
||||||
{
|
|
||||||
return $this->state(fn (array $attributes) => [
|
|
||||||
'breaks_enabled' => true,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function withOwner(?User $owner = null): self
|
public function withOwner(?User $owner = null): self
|
||||||
{
|
{
|
||||||
return $this->state(fn (array $attributes) => [
|
return $this->state(fn (array $attributes) => [
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Enums\TimeEntryType;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
@@ -34,7 +33,6 @@ class TimeEntryFactory extends Factory
|
|||||||
'start' => $start,
|
'start' => $start,
|
||||||
'end' => $this->faker->dateTimeBetween($start, 'now'),
|
'end' => $this->faker->dateTimeBetween($start, 'now'),
|
||||||
'billable' => $this->faker->boolean(),
|
'billable' => $this->faker->boolean(),
|
||||||
'type' => TimeEntryType::Work,
|
|
||||||
'is_imported' => false,
|
'is_imported' => false,
|
||||||
'tags' => [],
|
'tags' => [],
|
||||||
'user_id' => User::factory(),
|
'user_id' => User::factory(),
|
||||||
@@ -46,18 +44,6 @@ class TimeEntryFactory extends Factory
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isBreak(): self
|
|
||||||
{
|
|
||||||
return $this->state(function (array $attributes): array {
|
|
||||||
return [
|
|
||||||
'type' => TimeEntryType::Break,
|
|
||||||
'billable' => false,
|
|
||||||
'project_id' => null,
|
|
||||||
'task_id' => null,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function notBillable(): self
|
public function notBillable(): self
|
||||||
{
|
{
|
||||||
return $this->state(function (array $attributes): array {
|
return $this->state(function (array $attributes): array {
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('time_entries', function (Blueprint $table): void {
|
|
||||||
$table->string('type')->default('work');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('time_entries', function (Blueprint $table): void {
|
|
||||||
$table->dropColumn('type');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('organizations', function (Blueprint $table): void {
|
|
||||||
$table->boolean('breaks_enabled')->default(false)->after('prevent_overlapping_time_entries');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('organizations', function (Blueprint $table): void {
|
|
||||||
$table->dropColumn('breaks_enabled');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
use function Laravel\Prompts\info as consoleInfo;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* PostgreSQL cannot build or drop an index concurrently inside a transaction.
|
|
||||||
* Keeping this migration non-transactional prevents long write locks in production.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $withinTransaction = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
// Tenant-scoped client pagination ordered by newest first; also covers the organization FK.
|
|
||||||
$this->runIndexOperation('create', 'clients_organization_created_id_index', 'CREATE INDEX CONCURRENTLY clients_organization_created_id_index ON clients (organization_id, created_at DESC, id)');
|
|
||||||
|
|
||||||
// Tenant-scoped project pagination ordered by newest first; also covers the organization FK.
|
|
||||||
$this->runIndexOperation('create', 'projects_organization_created_id_index', 'CREATE INDEX CONCURRENTLY projects_organization_created_id_index ON projects (organization_id, created_at DESC, id)');
|
|
||||||
// Speeds client relationship loads and the FK check when a client is deleted or its ID changes.
|
|
||||||
$this->runIndexOperation('create', 'projects_client_id_index', 'CREATE INDEX CONCURRENTLY projects_client_id_index ON projects (client_id)');
|
|
||||||
|
|
||||||
// Tenant-scoped task pagination ordered by newest first; also covers the organization FK.
|
|
||||||
$this->runIndexOperation('create', 'tasks_organization_created_id_index', 'CREATE INDEX CONCURRENTLY tasks_organization_created_id_index ON tasks (organization_id, created_at DESC, id)');
|
|
||||||
// Speeds project task lists and the FK check when a project is deleted or its ID changes.
|
|
||||||
$this->runIndexOperation('create', 'tasks_project_id_index', 'CREATE INDEX CONCURRENTLY tasks_project_id_index ON tasks (project_id)');
|
|
||||||
|
|
||||||
// Tenant-scoped tag pagination ordered by newest first; also covers the organization FK.
|
|
||||||
$this->runIndexOperation('create', 'tags_organization_created_id_index', 'CREATE INDEX CONCURRENTLY tags_organization_created_id_index ON tags (organization_id, created_at DESC, id)');
|
|
||||||
|
|
||||||
// Tenant-scoped report pagination ordered by newest first; also covers the organization FK.
|
|
||||||
$this->runIndexOperation('create', 'reports_organization_created_id_index', 'CREATE INDEX CONCURRENTLY reports_organization_created_id_index ON reports (organization_id, created_at DESC, id)');
|
|
||||||
|
|
||||||
// Tenant-scoped member pagination; the existing (organization_id, user_id) unique index remains for membership lookup.
|
|
||||||
$this->runIndexOperation('create', 'members_organization_created_id_index', 'CREATE INDEX CONCURRENTLY members_organization_created_id_index ON members (organization_id, created_at DESC, id)');
|
|
||||||
// Supports reverse user-to-membership lookups and the FK check when a user is deleted or its ID changes.
|
|
||||||
$this->runIndexOperation('create', 'members_user_id_index', 'CREATE INDEX CONCURRENTLY members_user_id_index ON members (user_id)');
|
|
||||||
|
|
||||||
// The existing (project_id, user_id) unique index covers project_id, but member_id and legacy user_id need reverse indexes.
|
|
||||||
$this->runIndexOperation('create', 'project_members_member_id_index', 'CREATE INDEX CONCURRENTLY project_members_member_id_index ON project_members (member_id)');
|
|
||||||
$this->runIndexOperation('create', 'project_members_user_id_index', 'CREATE INDEX CONCURRENTLY project_members_user_id_index ON project_members (user_id)');
|
|
||||||
|
|
||||||
// Supports organization deletion/current-team cleanup and the FK check on users.current_team_id.
|
|
||||||
$this->runIndexOperation('create', 'users_current_team_id_index', 'CREATE INDEX CONCURRENTLY users_current_team_id_index ON users (current_team_id)');
|
|
||||||
|
|
||||||
// Filament loads the newest audits first; this avoids scanning and sorting the large append-only audit table.
|
|
||||||
$this->runIndexOperation('create', 'audits_created_at_index', 'CREATE INDEX CONCURRENTLY audits_created_at_index ON audits (created_at DESC)');
|
|
||||||
|
|
||||||
// Main tenant time-entry range/pagination path, including its start DESC, id ordering; also covers the organization FK.
|
|
||||||
$this->runIndexOperation('create', 'time_entries_organization_start_id_index', 'CREATE INDEX CONCURRENTLY time_entries_organization_start_id_index ON time_entries (organization_id, start DESC, id)');
|
|
||||||
// Filament lists time entries globally by creation time, so the tenant-prefixed index cannot provide this ordering.
|
|
||||||
$this->runIndexOperation('create', 'time_entries_created_at_index', 'CREATE INDEX CONCURRENTLY time_entries_created_at_index ON time_entries (created_at DESC)');
|
|
||||||
// Dashboard history is consistently filtered by user and organization, then bounded by start; user first also covers its FK.
|
|
||||||
$this->runIndexOperation('create', 'time_entries_user_organization_start_index', 'CREATE INDEX CONCURRENTLY time_entries_user_organization_start_index ON time_entries (user_id, organization_id, start)');
|
|
||||||
// Member timelines, overlap checks, and billable-rate updates start with member_id; also covers its FK.
|
|
||||||
$this->runIndexOperation('create', 'time_entries_member_start_index', 'CREATE INDEX CONCURRENTLY time_entries_member_start_index ON time_entries (member_id, start)');
|
|
||||||
// These relationship/filter indexes also prevent full scans for FK checks when parent rows change or are deleted.
|
|
||||||
$this->runIndexOperation('create', 'time_entries_project_id_index', 'CREATE INDEX CONCURRENTLY time_entries_project_id_index ON time_entries (project_id)');
|
|
||||||
$this->runIndexOperation('create', 'time_entries_task_id_index', 'CREATE INDEX CONCURRENTLY time_entries_task_id_index ON time_entries (task_id)');
|
|
||||||
$this->runIndexOperation('create', 'time_entries_client_id_index', 'CREATE INDEX CONCURRENTLY time_entries_client_id_index ON time_entries (client_id)');
|
|
||||||
// Active-timer checks touch only open entries, so a partial index stays small while serving the hot member_id lookup.
|
|
||||||
$this->runIndexOperation('create', 'time_entries_active_member_index', 'CREATE INDEX CONCURRENTLY time_entries_active_member_index ON time_entries (member_id) WHERE "end" IS NULL');
|
|
||||||
// whereJsonContains(tags, tag_id) compiles to JSONB containment, which is supported by a GIN index.
|
|
||||||
$this->runIndexOperation('create', 'time_entries_tags_gin_index', 'CREATE INDEX CONCURRENTLY time_entries_tags_gin_index ON time_entries USING GIN (tags)');
|
|
||||||
|
|
||||||
// Passport already indexes user_id; these indexes cover the other FK used during OAuth client deletion/update.
|
|
||||||
$this->runIndexOperation('create', 'oauth_access_tokens_client_id_index', 'CREATE INDEX CONCURRENTLY oauth_access_tokens_client_id_index ON oauth_access_tokens (client_id)');
|
|
||||||
$this->runIndexOperation('create', 'oauth_auth_codes_client_id_index', 'CREATE INDEX CONCURRENTLY oauth_auth_codes_client_id_index ON oauth_auth_codes (client_id)');
|
|
||||||
|
|
||||||
// owner_id is already the leading column of oauth_clients_owner_id_owner_type_index.
|
|
||||||
$this->runIndexOperation('drop', 'oauth_clients_user_id_index', 'DROP INDEX CONCURRENTLY oauth_clients_user_id_index');
|
|
||||||
// Public report lookup starts with the unique share_secret index; no query filters only by this boolean.
|
|
||||||
$this->runIndexOperation('drop', 'reports_is_public_index', 'DROP INDEX CONCURRENTLY reports_is_public_index');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
$indexes = [
|
|
||||||
'clients_organization_created_id_index',
|
|
||||||
'projects_organization_created_id_index',
|
|
||||||
'projects_client_id_index',
|
|
||||||
'tasks_organization_created_id_index',
|
|
||||||
'tasks_project_id_index',
|
|
||||||
'tags_organization_created_id_index',
|
|
||||||
'reports_organization_created_id_index',
|
|
||||||
'members_organization_created_id_index',
|
|
||||||
'members_user_id_index',
|
|
||||||
'project_members_member_id_index',
|
|
||||||
'project_members_user_id_index',
|
|
||||||
'users_current_team_id_index',
|
|
||||||
'audits_created_at_index',
|
|
||||||
'time_entries_organization_start_id_index',
|
|
||||||
'time_entries_created_at_index',
|
|
||||||
'time_entries_user_organization_start_index',
|
|
||||||
'time_entries_member_start_index',
|
|
||||||
'time_entries_project_id_index',
|
|
||||||
'time_entries_task_id_index',
|
|
||||||
'time_entries_client_id_index',
|
|
||||||
'time_entries_active_member_index',
|
|
||||||
'time_entries_tags_gin_index',
|
|
||||||
'oauth_access_tokens_client_id_index',
|
|
||||||
'oauth_auth_codes_client_id_index',
|
|
||||||
];
|
|
||||||
|
|
||||||
$concurrently = DB::transactionLevel() === 0 ? ' CONCURRENTLY' : '';
|
|
||||||
foreach ($indexes as $index) {
|
|
||||||
$this->runIndexOperation('drop', $index, 'DROP INDEX'.$concurrently.' IF EXISTS '.$index);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->runIndexOperation('create', 'oauth_clients_user_id_index', 'CREATE INDEX'.$concurrently.' oauth_clients_user_id_index ON oauth_clients (owner_id)');
|
|
||||||
$this->runIndexOperation('create', 'reports_is_public_index', 'CREATE INDEX'.$concurrently.' reports_is_public_index ON reports (is_public)');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function runIndexOperation(string $operation, string $index, string $statement): void
|
|
||||||
{
|
|
||||||
$indexState = $this->indexState($index);
|
|
||||||
|
|
||||||
if ($operation === 'create' && $indexState === ['valid' => true, 'ready' => true]) {
|
|
||||||
$this->writeProgress(sprintf('Skipping index [%s] because it already exists and is valid', $index));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($operation === 'drop' && $indexState === null) {
|
|
||||||
$this->writeProgress(sprintf('Skipping index [%s] because it does not exist', $index));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($operation === 'create' && $indexState !== null) {
|
|
||||||
$this->writeProgress(sprintf(
|
|
||||||
'Index [%s] exists but is incomplete (valid=%s, ready=%s); dropping it before rebuilding',
|
|
||||||
$index,
|
|
||||||
$indexState['valid'] ? 'true' : 'false',
|
|
||||||
$indexState['ready'] ? 'true' : 'false',
|
|
||||||
));
|
|
||||||
$this->executeIndexStatement(
|
|
||||||
'drop incomplete',
|
|
||||||
$index,
|
|
||||||
(DB::transactionLevel() === 0 ? 'DROP INDEX CONCURRENTLY ' : 'DROP INDEX ').$this->quoteIdentifier($index),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->executeIndexStatement($operation, $index, $statement);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function executeIndexStatement(string $operation, string $index, string $statement): void
|
|
||||||
{
|
|
||||||
$startedAt = microtime(true);
|
|
||||||
$this->writeProgress(sprintf('Starting to %s index [%s]', $operation, $index));
|
|
||||||
|
|
||||||
try {
|
|
||||||
DB::statement($statement);
|
|
||||||
} catch (Throwable $exception) {
|
|
||||||
$this->writeProgress(sprintf(
|
|
||||||
'Failed to %s index [%s] after %.2f seconds: %s',
|
|
||||||
$operation,
|
|
||||||
$index,
|
|
||||||
microtime(true) - $startedAt,
|
|
||||||
$exception->getMessage(),
|
|
||||||
));
|
|
||||||
|
|
||||||
throw $exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->writeProgress(sprintf(
|
|
||||||
'Finished %s index [%s] in %.2f seconds',
|
|
||||||
$operation === 'create' ? 'creating' : 'dropping',
|
|
||||||
$index,
|
|
||||||
microtime(true) - $startedAt,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array{valid: bool, ready: bool}|null
|
|
||||||
*/
|
|
||||||
private function indexState(string $index): ?array
|
|
||||||
{
|
|
||||||
$state = DB::selectOne(
|
|
||||||
<<<'SQL'
|
|
||||||
SELECT pg_index.indisvalid::int AS valid, pg_index.indisready::int AS ready
|
|
||||||
FROM pg_index
|
|
||||||
JOIN pg_class ON pg_class.oid = pg_index.indexrelid
|
|
||||||
JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
|
|
||||||
WHERE pg_namespace.nspname = current_schema()
|
|
||||||
AND pg_class.relname = ?
|
|
||||||
SQL,
|
|
||||||
[$index],
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($state === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'valid' => (bool) $state->valid,
|
|
||||||
'ready' => (bool) $state->ready,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function quoteIdentifier(string $identifier): string
|
|
||||||
{
|
|
||||||
return DB::connection()->getQueryGrammar()->wrap($identifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function writeProgress(string $message): void
|
|
||||||
{
|
|
||||||
if (app()->runningUnitTests()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = sprintf('[%s] %s', date(DATE_ATOM), $message);
|
|
||||||
Log::info($message);
|
|
||||||
consoleInfo($message);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('users', function (Blueprint $table): void {
|
|
||||||
$table->boolean('send_time_entry_still_running_email')->default(true)->after('week_start');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('users', function (Blueprint $table): void {
|
|
||||||
$table->dropColumn('send_time_entry_still_running_email');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Query\Builder;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Placeholder users used to be created as a full copy of the user they were made from,
|
|
||||||
* which included the credentials and the account state of that user. A placeholder is a
|
|
||||||
* stand-in for a person in one organization, not an account, and the row shares the email
|
|
||||||
* address with the real account, so these values are removed from the placeholders that
|
|
||||||
* already exist. The organization a placeholder belongs to is recorded on its member row.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
DB::table('users')
|
|
||||||
->where('is_placeholder', '=', true)
|
|
||||||
->where(function (Builder $builder): void {
|
|
||||||
$builder->whereNotNull('password')
|
|
||||||
->orWhereNotNull('remember_token')
|
|
||||||
->orWhereNotNull('two_factor_secret')
|
|
||||||
->orWhereNotNull('two_factor_recovery_codes')
|
|
||||||
->orWhereNotNull('two_factor_confirmed_at')
|
|
||||||
->orWhereNotNull('email_verified_at')
|
|
||||||
->orWhereNotNull('pending_email')
|
|
||||||
->orWhereNotNull('current_team_id')
|
|
||||||
->orWhereNotNull('profile_photo_path');
|
|
||||||
})
|
|
||||||
->update([
|
|
||||||
'password' => null,
|
|
||||||
'remember_token' => null,
|
|
||||||
'two_factor_secret' => null,
|
|
||||||
'two_factor_recovery_codes' => null,
|
|
||||||
'two_factor_confirmed_at' => null,
|
|
||||||
'email_verified_at' => null,
|
|
||||||
'pending_email' => null,
|
|
||||||
'current_team_id' => null,
|
|
||||||
'profile_photo_path' => null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,278 +0,0 @@
|
|||||||
import { expect, test } from '../playwright/fixtures';
|
|
||||||
import { PLAYWRIGHT_BASE_URL } from '../playwright/config';
|
|
||||||
import type { Page } from '@playwright/test';
|
|
||||||
import {
|
|
||||||
assertThatTimerHasStarted,
|
|
||||||
assertThatTimerIsStopped,
|
|
||||||
newTimeEntryResponse,
|
|
||||||
startOrStopTimerWithButton,
|
|
||||||
stoppedTimeEntryResponse,
|
|
||||||
} from './utils/currentTimeEntry';
|
|
||||||
import { createTimeEntryViaApi, updateOrganizationSettingViaApi } from './utils/api';
|
|
||||||
|
|
||||||
async function goToDashboard(page: Page) {
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
|
||||||
}
|
|
||||||
|
|
||||||
function visibleBreakButton(page: Page) {
|
|
||||||
return page.getByRole('button', { name: 'Take a break' }).locator('visible=true').first();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Breaks are disabled by default for new organizations, so enable them for the break flows.
|
|
||||||
// The tests that assert the disabled behaviour turn them back off explicitly.
|
|
||||||
test.beforeEach(async ({ ctx }) => {
|
|
||||||
await updateOrganizationSettingViaApi(ctx, { breaks_enabled: true });
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that switching to a break stops the work timer and starts a break entry', async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
await goToDashboard(page);
|
|
||||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
|
||||||
await page.getByTestId('time_entry_description').fill('Work before break');
|
|
||||||
await Promise.all([
|
|
||||||
newTimeEntryResponse(page, { description: 'Work before break', type: 'work' }),
|
|
||||||
page.getByTestId('time_entry_description').press('Enter'),
|
|
||||||
]);
|
|
||||||
await assertThatTimerHasStarted(page);
|
|
||||||
await page.waitForTimeout(1500);
|
|
||||||
|
|
||||||
// Switch to break: stops the work entry and starts a break entry
|
|
||||||
await Promise.all([
|
|
||||||
newTimeEntryResponse(page, { description: '', type: 'break' }),
|
|
||||||
visibleBreakButton(page).click(),
|
|
||||||
]);
|
|
||||||
await expect(page.getByText('On break')).toBeVisible();
|
|
||||||
|
|
||||||
// The break bar offers a one-click resume that stops the break and restores
|
|
||||||
// the interrupted work context
|
|
||||||
await page.waitForTimeout(1500);
|
|
||||||
const resumeButton = page.getByRole('button', { name: 'Resume "Work before break"' });
|
|
||||||
await expect(resumeButton).toBeVisible();
|
|
||||||
await Promise.all([
|
|
||||||
stoppedTimeEntryResponse(page, { type: 'break' }),
|
|
||||||
newTimeEntryResponse(page, { description: 'Work before break', type: 'work' }),
|
|
||||||
resumeButton.click(),
|
|
||||||
]);
|
|
||||||
await assertThatTimerHasStarted(page);
|
|
||||||
await expect(page.getByTestId('time_entry_description')).toHaveValue('Work before break');
|
|
||||||
|
|
||||||
// Cleanup: stop the running entry
|
|
||||||
await Promise.all([
|
|
||||||
stoppedTimeEntryResponse(page, { description: 'Work before break', type: 'work' }),
|
|
||||||
startOrStopTimerWithButton(page),
|
|
||||||
]);
|
|
||||||
await assertThatTimerIsStopped(page);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that stopping a break returns to an idle tracker where a fresh entry starts normally', async ({
|
|
||||||
page,
|
|
||||||
}) => {
|
|
||||||
await goToDashboard(page);
|
|
||||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
|
||||||
await page.getByTestId('time_entry_description').fill('Work before break');
|
|
||||||
await Promise.all([
|
|
||||||
newTimeEntryResponse(page, { description: 'Work before break', type: 'work' }),
|
|
||||||
page.getByTestId('time_entry_description').press('Enter'),
|
|
||||||
]);
|
|
||||||
await assertThatTimerHasStarted(page);
|
|
||||||
await page.waitForTimeout(1500);
|
|
||||||
|
|
||||||
// Switch to a break
|
|
||||||
await Promise.all([
|
|
||||||
newTimeEntryResponse(page, { description: '', type: 'break' }),
|
|
||||||
visibleBreakButton(page).click(),
|
|
||||||
]);
|
|
||||||
await expect(page.getByText('On break')).toBeVisible();
|
|
||||||
|
|
||||||
// Stopping the break just ends it — no modal, the tracker returns to the
|
|
||||||
// empty idle input with focus so typing starts a fresh entry
|
|
||||||
await page.waitForTimeout(1500);
|
|
||||||
await Promise.all([
|
|
||||||
stoppedTimeEntryResponse(page, { type: 'break' }),
|
|
||||||
startOrStopTimerWithButton(page),
|
|
||||||
]);
|
|
||||||
await assertThatTimerIsStopped(page);
|
|
||||||
await expect(page.getByTestId('time_entry_description')).toHaveValue('');
|
|
||||||
await expect(page.getByTestId('time_entry_description')).toBeFocused();
|
|
||||||
|
|
||||||
// A fresh entry is the normal start flow: type + Enter
|
|
||||||
await page.getByTestId('time_entry_description').fill('Fresh after break');
|
|
||||||
await Promise.all([
|
|
||||||
newTimeEntryResponse(page, { description: 'Fresh after break', type: 'work' }),
|
|
||||||
page.getByTestId('time_entry_description').press('Enter'),
|
|
||||||
]);
|
|
||||||
await assertThatTimerHasStarted(page);
|
|
||||||
|
|
||||||
// Cleanup: stop the running entry
|
|
||||||
await Promise.all([
|
|
||||||
stoppedTimeEntryResponse(page, { description: 'Fresh after break', type: 'work' }),
|
|
||||||
startOrStopTimerWithButton(page),
|
|
||||||
]);
|
|
||||||
await assertThatTimerIsStopped(page);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that the more options dropdown can start a break directly', async ({ page }) => {
|
|
||||||
await goToDashboard(page);
|
|
||||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
|
||||||
|
|
||||||
// Start a break straight from the more options dropdown (no create modal)
|
|
||||||
await page.getByRole('button', { name: 'Time entry actions' }).click();
|
|
||||||
await Promise.all([
|
|
||||||
newTimeEntryResponse(page, { description: '', type: 'break' }),
|
|
||||||
page.getByRole('menuitem', { name: 'Start Break' }).click(),
|
|
||||||
]);
|
|
||||||
await expect(page.getByText('On break')).toBeVisible();
|
|
||||||
|
|
||||||
// Without interrupted work there is nothing to resume, so no resume button is offered
|
|
||||||
await expect(page.getByRole('button', { name: /^Resume/ })).toHaveCount(0);
|
|
||||||
|
|
||||||
// Cleanup: stop the break
|
|
||||||
await page.waitForTimeout(1500);
|
|
||||||
await Promise.all([
|
|
||||||
stoppedTimeEntryResponse(page, { type: 'break' }),
|
|
||||||
startOrStopTimerWithButton(page),
|
|
||||||
]);
|
|
||||||
await assertThatTimerIsStopped(page);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that disabling breaks hides every break-creation entry point', async ({ page, ctx }) => {
|
|
||||||
// Breaks disabled for the organization (delivered to the client via the organization endpoint)
|
|
||||||
await updateOrganizationSettingViaApi(ctx, { breaks_enabled: false });
|
|
||||||
await createTimeEntryViaApi(ctx, { duration: '1h', description: 'Regular work' });
|
|
||||||
|
|
||||||
// Calendar: the empty-slot context menu offers "Create Time Entry" but no "Add Break",
|
|
||||||
// and the edit modal drops the work-time/break type selector
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/calendar');
|
|
||||||
await expect(page.locator('.fc')).toBeVisible();
|
|
||||||
const event = page.locator('.fc-event').filter({ hasText: 'Regular work' }).first();
|
|
||||||
await event.scrollIntoViewIfNeeded();
|
|
||||||
await expect(event).toBeVisible();
|
|
||||||
|
|
||||||
const box = await event.boundingBox();
|
|
||||||
expect(box).not.toBeNull();
|
|
||||||
await page.mouse.click(box!.x + box!.width / 2, box!.y + box!.height + 40, { button: 'right' });
|
|
||||||
await expect(page.getByRole('menu')).toBeVisible();
|
|
||||||
await expect(page.getByRole('menuitem', { name: 'Create Time Entry' })).toBeVisible();
|
|
||||||
await expect(page.getByRole('menuitem', { name: 'Add Break' })).toHaveCount(0);
|
|
||||||
await page.keyboard.press('Escape');
|
|
||||||
|
|
||||||
await event.click({ button: 'right' });
|
|
||||||
await expect(page.getByRole('menu')).toBeVisible();
|
|
||||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
|
||||||
await expect(page.getByRole('dialog')).toBeVisible();
|
|
||||||
await expect(
|
|
||||||
page.getByRole('dialog').getByRole('combobox').filter({ hasText: 'Work time' })
|
|
||||||
).toHaveCount(0);
|
|
||||||
await page.keyboard.press('Escape');
|
|
||||||
|
|
||||||
// Timesheet: no break row is shown
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/timesheet');
|
|
||||||
await expect(page.getByRole('button', { name: 'Add row' }).first()).toBeVisible();
|
|
||||||
await expect(page.getByText('Break', { exact: true })).toHaveCount(0);
|
|
||||||
|
|
||||||
// Dashboard tracker: no "Start Break" in the more options dropdown
|
|
||||||
await goToDashboard(page);
|
|
||||||
await expect(page.getByTestId('time_entry_description')).toBeEditable();
|
|
||||||
await page.getByRole('button', { name: 'Time entry actions' }).click();
|
|
||||||
await expect(page.getByRole('menuitem', { name: 'Switch to simple mode' })).toBeVisible();
|
|
||||||
await expect(page.getByRole('menuitem', { name: 'Start Break' })).toHaveCount(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// The employee fixture registers a second user and accepts an invitation via Mailpit,
|
|
||||||
// which does not fit into the default per-test timeout.
|
|
||||||
test.describe('Org-level breaks setting', () => {
|
|
||||||
test.describe.configure({ timeout: 60000 });
|
|
||||||
|
|
||||||
test('test that the org-level breaks setting is respected for employees', async ({
|
|
||||||
ctx,
|
|
||||||
employee,
|
|
||||||
}) => {
|
|
||||||
const employeePage = employee.page;
|
|
||||||
|
|
||||||
// Breaks enabled (via beforeEach): the employee sees "Start Break" in the more options dropdown
|
|
||||||
await employeePage.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
|
||||||
await expect(employeePage.getByTestId('dashboard_view')).toBeVisible();
|
|
||||||
await employeePage.getByRole('button', { name: 'Time entry actions' }).click();
|
|
||||||
await expect(
|
|
||||||
employeePage.getByRole('menuitem', { name: 'Switch to simple mode' })
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(employeePage.getByRole('menuitem', { name: 'Start Break' })).toBeVisible();
|
|
||||||
await employeePage.keyboard.press('Escape');
|
|
||||||
|
|
||||||
// The owner disables breaks for the whole organization
|
|
||||||
await updateOrganizationSettingViaApi(ctx, { breaks_enabled: false });
|
|
||||||
|
|
||||||
// The employee reloads: "Start Break" is gone from the dropdown
|
|
||||||
await employeePage.goto(PLAYWRIGHT_BASE_URL + '/dashboard');
|
|
||||||
await expect(employeePage.getByTestId('dashboard_view')).toBeVisible();
|
|
||||||
await employeePage.getByRole('button', { name: 'Time entry actions' }).click();
|
|
||||||
await expect(
|
|
||||||
employeePage.getByRole('menuitem', { name: 'Switch to simple mode' })
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(employeePage.getByRole('menuitem', { name: 'Start Break' })).toHaveCount(0);
|
|
||||||
await employeePage.keyboard.press('Escape');
|
|
||||||
|
|
||||||
// With an active timer the break (coffee) button is not shown either
|
|
||||||
await employeePage.getByTestId('time_entry_description').fill('Employee work');
|
|
||||||
await Promise.all([
|
|
||||||
newTimeEntryResponse(employeePage, { description: 'Employee work', type: 'work' }),
|
|
||||||
employeePage.getByTestId('time_entry_description').press('Enter'),
|
|
||||||
]);
|
|
||||||
await assertThatTimerHasStarted(employeePage);
|
|
||||||
await expect(employeePage.getByRole('button', { name: 'Take a break' })).toHaveCount(0);
|
|
||||||
|
|
||||||
// Cleanup: stop the running entry
|
|
||||||
await Promise.all([
|
|
||||||
stoppedTimeEntryResponse(employeePage, { description: 'Employee work', type: 'work' }),
|
|
||||||
startOrStopTimerWithButton(employeePage),
|
|
||||||
]);
|
|
||||||
await assertThatTimerIsStopped(employeePage);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('test that mass update warns about selected breaks and reports skipped entries instead of success', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
// One work entry and one break: a billable mass update applies to the work
|
|
||||||
// entry but the server skips the break entirely — the UI must say so.
|
|
||||||
await createTimeEntryViaApi(ctx, { duration: '1h', description: 'Mass update work entry' });
|
|
||||||
await createTimeEntryViaApi(ctx, { duration: '30min', type: 'break' });
|
|
||||||
|
|
||||||
await page.goto(PLAYWRIGHT_BASE_URL + '/time');
|
|
||||||
await expect(page.locator('[data-testid="time_entry_row"]')).toHaveCount(2);
|
|
||||||
await page.getByLabel('Select All').click();
|
|
||||||
await expect(page.getByText('2 selected')).toBeVisible();
|
|
||||||
await page.getByRole('button', { name: 'Edit' }).click();
|
|
||||||
await expect(page.getByRole('dialog')).toBeVisible();
|
|
||||||
|
|
||||||
// No warning while the changeset is compatible with breaks
|
|
||||||
await expect(page.getByTestId('mass_update_break_warning')).not.toBeVisible();
|
|
||||||
|
|
||||||
// Making the entries billable is break-incompatible → warning appears
|
|
||||||
await page
|
|
||||||
.getByRole('dialog')
|
|
||||||
.getByRole('combobox')
|
|
||||||
.filter({ hasText: 'Set billable status' })
|
|
||||||
.click();
|
|
||||||
await page.getByRole('option', { name: 'Billable', exact: true }).click();
|
|
||||||
await expect(page.getByTestId('mass_update_break_warning')).toBeVisible();
|
|
||||||
await expect(page.getByTestId('mass_update_break_warning')).toContainText('skipped entirely');
|
|
||||||
|
|
||||||
// Submit: the work entry updates, the break is skipped, and the toast
|
|
||||||
// reports the skip instead of claiming success for all entries
|
|
||||||
const [massUpdateResponse] = await Promise.all([
|
|
||||||
page.waitForResponse(
|
|
||||||
(response) =>
|
|
||||||
response.url().includes('/time-entries') &&
|
|
||||||
response.request().method() === 'PATCH' &&
|
|
||||||
response.status() === 200
|
|
||||||
),
|
|
||||||
page.getByRole('button', { name: 'Update Time Entries' }).click(),
|
|
||||||
]);
|
|
||||||
const massUpdateBody = await massUpdateResponse.json();
|
|
||||||
expect(massUpdateBody.success.length).toBe(1);
|
|
||||||
expect(massUpdateBody.error.length).toBe(1);
|
|
||||||
await expect(page.getByText('1 of 2 time entries was skipped')).toBeVisible();
|
|
||||||
});
|
|
||||||
@@ -2874,54 +2874,3 @@ test.describe('Daily Total After Create', () => {
|
|||||||
}).toPass({ timeout: 5000 });
|
}).toPass({ timeout: 5000 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('test that calendar context menu can add a break that fills the gap between two entries', async ({
|
|
||||||
page,
|
|
||||||
ctx,
|
|
||||||
}) => {
|
|
||||||
await updateOrganizationSettingViaApi(ctx, { breaks_enabled: true });
|
|
||||||
// Two work entries today (09:00-10:00 and 11:00-12:00 UTC) with a one hour gap
|
|
||||||
const today = new Date().toISOString().slice(0, 10);
|
|
||||||
const gapStart = `${today}T10:00:00Z`;
|
|
||||||
const gapEnd = `${today}T11:00:00Z`;
|
|
||||||
await createTimeEntryWithTimestampsViaApi(ctx, {
|
|
||||||
start: `${today}T09:00:00Z`,
|
|
||||||
end: gapStart,
|
|
||||||
description: 'Gap work A',
|
|
||||||
});
|
|
||||||
await createTimeEntryWithTimestampsViaApi(ctx, {
|
|
||||||
start: gapEnd,
|
|
||||||
end: `${today}T12:00:00Z`,
|
|
||||||
description: 'Gap work B',
|
|
||||||
});
|
|
||||||
|
|
||||||
await goToCalendar(page);
|
|
||||||
const eventA = page.locator('.fc-event').filter({ hasText: 'Gap work A' }).first();
|
|
||||||
await eventA.scrollIntoViewIfNeeded();
|
|
||||||
await expect(eventA).toBeVisible();
|
|
||||||
|
|
||||||
// Right-click just below entry A (inside the gap, in the same day column)
|
|
||||||
const box = await eventA.boundingBox();
|
|
||||||
expect(box).not.toBeNull();
|
|
||||||
await page.mouse.click(box!.x + box!.width / 2, box!.y + box!.height + 15, {
|
|
||||||
button: 'right',
|
|
||||||
});
|
|
||||||
await expect(page.getByRole('menu')).toBeVisible();
|
|
||||||
await page.getByRole('menuitem', { name: 'Add Break' }).click();
|
|
||||||
await expect(page.getByRole('dialog')).toBeVisible();
|
|
||||||
|
|
||||||
// The break is prefilled to fill the gap exactly
|
|
||||||
const [createResponse] = await Promise.all([
|
|
||||||
page.waitForResponse(
|
|
||||||
async (response) =>
|
|
||||||
response.url().includes('/time-entries') &&
|
|
||||||
response.request().method() === 'POST' &&
|
|
||||||
response.status() === 201 &&
|
|
||||||
(await response.json()).data.type === 'break'
|
|
||||||
),
|
|
||||||
page.getByRole('button', { name: 'Add Break' }).click(),
|
|
||||||
]);
|
|
||||||
const body = await createResponse.json();
|
|
||||||
expect(body.data.start).toBe(gapStart);
|
|
||||||
expect(body.data.end).toBe(gapEnd);
|
|
||||||
});
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user