mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 08:12:17 +01:00
Compare commits
2 Commits
feature/po
...
feature/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9ffa9899f | ||
|
|
aa588196ee |
24
.github/workflows/build-private.yml
vendored
24
.github/workflows/build-private.yml
vendored
@@ -10,8 +10,6 @@ on:
|
|||||||
- '.github/workflows/build-private.yml'
|
- '.github/workflows/build-private.yml'
|
||||||
- 'docker/prod/**'
|
- 'docker/prod/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
name: Build - Private
|
name: Build - Private
|
||||||
jobs:
|
jobs:
|
||||||
@@ -19,7 +17,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: "Check out code"
|
- name: "Check out code"
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -110,24 +107,6 @@ jobs:
|
|||||||
- name: "Install npm dependencies in services extension"
|
- name: "Install npm dependencies in services extension"
|
||||||
run: cd extensions/Services && npm ci
|
run: cd extensions/Services && npm ci
|
||||||
|
|
||||||
- name: "Checkout invoicing extension"
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: solidtime-io/extension-invoicing
|
|
||||||
path: extensions/Invoicing
|
|
||||||
ssh-key: ${{ secrets.SSH_PRIVATE_KEY_INVOICING_EXTENSION }}
|
|
||||||
|
|
||||||
- name: "Install composer dependencies in invoicing extension"
|
|
||||||
uses: php-actions/composer@v6
|
|
||||||
with:
|
|
||||||
working_dir: "extensions/Invoicing"
|
|
||||||
command: install
|
|
||||||
only_args: --no-dev --no-ansi --no-interaction --prefer-dist --ignore-platform-reqs --classmap-authoritative
|
|
||||||
php_version: 8.3
|
|
||||||
|
|
||||||
- name: "Install npm dependencies in invoicing extension"
|
|
||||||
run: cd extensions/Invoicing && npm ci
|
|
||||||
|
|
||||||
- name: "Setup PHP with PECL extension"
|
- name: "Setup PHP with PECL extension"
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
@@ -148,9 +127,6 @@ jobs:
|
|||||||
- name: "Activate services extension"
|
- name: "Activate services extension"
|
||||||
run: php artisan module:enable Services
|
run: php artisan module:enable Services
|
||||||
|
|
||||||
- name: "Activate invoicing extension"
|
|
||||||
run: php artisan module:enable Invoicing
|
|
||||||
|
|
||||||
- name: "Install npm dependencies"
|
- name: "Install npm dependencies"
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
|
|||||||
16
.github/workflows/build-public.yml
vendored
16
.github/workflows/build-public.yml
vendored
@@ -11,12 +11,6 @@ on:
|
|||||||
- 'docker/prod/**'
|
- 'docker/prod/**'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
attestations: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKERHUB_REPO: solidtime/solidtime
|
DOCKERHUB_REPO: solidtime/solidtime
|
||||||
GHCR_REPO: ghcr.io/solidtime-io/solidtime
|
GHCR_REPO: ghcr.io/solidtime-io/solidtime
|
||||||
@@ -32,6 +26,11 @@ jobs:
|
|||||||
- runs-on: "ubuntu-24.04"
|
- runs-on: "ubuntu-24.04"
|
||||||
platform: "linux/amd64"
|
platform: "linux/amd64"
|
||||||
runs-on: ${{ matrix.runs-on }}
|
runs-on: ${{ matrix.runs-on }}
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -164,6 +163,11 @@ jobs:
|
|||||||
|
|
||||||
merge:
|
merge:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
attestations: write
|
||||||
|
id-token: write
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
needs:
|
needs:
|
||||||
- build
|
- build
|
||||||
|
|||||||
3
.github/workflows/generate-api-docs.yml
vendored
3
.github/workflows/generate-api-docs.yml
vendored
@@ -3,9 +3,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
api_docs:
|
api_docs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/npm-build.yml
vendored
2
.github/workflows/npm-build.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: NPM Build
|
name: NPM Build
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
2
.github/workflows/npm-lint.yml
vendored
2
.github/workflows/npm-lint.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: NPM Lint
|
name: NPM Lint
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
2
.github/workflows/npm-publish-api.yml
vendored
2
.github/workflows/npm-publish-api.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: Publish API package to NPM
|
name: Publish API package to NPM
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/npm-publish-ui.yml
vendored
2
.github/workflows/npm-publish-ui.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: Publish UI package to NPM
|
name: Publish UI package to NPM
|
||||||
on:
|
on:
|
||||||
workflow_dispatch
|
workflow_dispatch
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
3
.github/workflows/npm-typecheck.yml
vendored
3
.github/workflows/npm-typecheck.yml
vendored
@@ -1,8 +1,7 @@
|
|||||||
name: NPM Typecheck
|
name: NPM Typecheck
|
||||||
|
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/phpstan.yml
vendored
2
.github/workflows/phpstan.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: Static code analysis (PHPStan)
|
name: Static code analysis (PHPStan)
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
phpstan:
|
phpstan:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
9
.github/workflows/phpunit.yml
vendored
9
.github/workflows/phpunit.yml
vendored
@@ -1,18 +1,13 @@
|
|||||||
name: PHPUnit Tests
|
name: PHPUnit Tests
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
phpunit:
|
phpunit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
postgres_version: [ 15, 16, 17 ]
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
pgsql_test:
|
pgsql_test:
|
||||||
image: postgres:${{ matrix.postgres_version }}
|
image: postgres:15
|
||||||
env:
|
env:
|
||||||
PGPASSWORD: 'root'
|
PGPASSWORD: 'root'
|
||||||
POSTGRES_DB: 'laravel'
|
POSTGRES_DB: 'laravel'
|
||||||
@@ -68,7 +63,7 @@ jobs:
|
|||||||
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml
|
||||||
|
|
||||||
- name: "Upload coverage reports to Codecov"
|
- name: "Upload coverage reports to Codecov"
|
||||||
uses: codecov/codecov-action@v5.4.3
|
uses: codecov/codecov-action@v5.3.1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
slug: solidtime-io/solidtime
|
slug: solidtime-io/solidtime
|
||||||
|
|||||||
2
.github/workflows/pint.yml
vendored
2
.github/workflows/pint.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: PHP Linting
|
name: PHP Linting
|
||||||
on: push
|
on: push
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
pint:
|
pint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
2
.github/workflows/playwright.yml
vendored
2
.github/workflows/playwright.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: Playwright Tests
|
name: Playwright Tests
|
||||||
on: [push]
|
on: [push]
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -76,11 +76,6 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
$ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip());
|
$ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip());
|
||||||
|
|
||||||
$startOfWeek = Weekday::Monday;
|
$startOfWeek = Weekday::Monday;
|
||||||
$numberFormat = null;
|
|
||||||
$currencyFormat = null;
|
|
||||||
$dateFormat = null;
|
|
||||||
$intervalFormat = null;
|
|
||||||
$timeFormat = null;
|
|
||||||
$currency = null;
|
$currency = null;
|
||||||
if ($ipLookupResponse !== null) {
|
if ($ipLookupResponse !== null) {
|
||||||
$startOfWeek = $ipLookupResponse->startOfWeek ?? Weekday::Monday;
|
$startOfWeek = $ipLookupResponse->startOfWeek ?? Weekday::Monday;
|
||||||
@@ -90,7 +85,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
$currency = $ipLookupResponse->currency;
|
$currency = $ipLookupResponse->currency;
|
||||||
}
|
}
|
||||||
$user = null;
|
$user = null;
|
||||||
DB::transaction(function () use (&$user, $input, $timezone, $startOfWeek, $currency, $numberFormat, $currencyFormat, $dateFormat, $intervalFormat, $timeFormat): void {
|
DB::transaction(function () use (&$user, $input, $timezone, $startOfWeek, $currency): void {
|
||||||
$userService = app(UserService::class);
|
$userService = app(UserService::class);
|
||||||
$user = $userService->createUser(
|
$user = $userService->createUser(
|
||||||
$input['name'],
|
$input['name'],
|
||||||
@@ -98,12 +93,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
$input['password'],
|
$input['password'],
|
||||||
$timezone ?? 'UTC',
|
$timezone ?? 'UTC',
|
||||||
$startOfWeek,
|
$startOfWeek,
|
||||||
$currency,
|
$currency ?? 'EUR',
|
||||||
$numberFormat,
|
|
||||||
$currencyFormat,
|
|
||||||
$dateFormat,
|
|
||||||
$intervalFormat,
|
|
||||||
$timeFormat
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Actions\Jetstream;
|
namespace App\Actions\Jetstream;
|
||||||
|
|
||||||
|
use App\Enums\Role;
|
||||||
use App\Events\AfterCreateOrganization;
|
use App\Events\AfterCreateOrganization;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Service\IpLookup\IpLookupServiceContract;
|
|
||||||
use App\Service\OrganizationService;
|
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
@@ -34,18 +33,16 @@ class CreateOrganization implements CreatesTeams
|
|||||||
'name' => ['required', 'string', 'max:255'],
|
'name' => ['required', 'string', 'max:255'],
|
||||||
])->validateWithBag('createTeam');
|
])->validateWithBag('createTeam');
|
||||||
|
|
||||||
$ipLookupResponse = app(IpLookupServiceContract::class)->lookup(request()->ip());
|
$organization = new Organization;
|
||||||
|
$organization->name = $input['name'];
|
||||||
|
$organization->personal_team = false;
|
||||||
|
$organization->owner()->associate($user);
|
||||||
|
$organization->save();
|
||||||
|
|
||||||
$currency = null;
|
$organization->users()->attach(
|
||||||
if ($ipLookupResponse !== null) {
|
$user, [
|
||||||
$currency = $ipLookupResponse->currency;
|
'role' => Role::Owner->value,
|
||||||
}
|
]
|
||||||
|
|
||||||
$organization = app(OrganizationService::class)->createOrganization(
|
|
||||||
$input['name'],
|
|
||||||
$user,
|
|
||||||
false,
|
|
||||||
$currency
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$user->switchTeam($organization);
|
$user->switchTeam($organization);
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ class UserCreateCommand extends Command
|
|||||||
$password,
|
$password,
|
||||||
'UTC',
|
'UTC',
|
||||||
Weekday::Monday,
|
Weekday::Monday,
|
||||||
null,
|
'EUR',
|
||||||
verifyEmail: $verifyEmail
|
$verifyEmail
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
/** @var Organization|null $organization */
|
/** @var Organization|null $organization */
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Console\Commands\Correction;
|
|
||||||
|
|
||||||
use App\Enums\Role;
|
|
||||||
use App\Models\Member;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
|
|
||||||
class CorrectionPlaceholderMembersCommand extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'correction:placeholder-members '.
|
|
||||||
' { --dry-run : Do not actually save anything to the database, just output what would happen }';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Sets all members who belong to a placeholder user to role placeholder';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle(): int
|
|
||||||
{
|
|
||||||
$this->comment('Sets all members who belong to a placeholder user to role placeholder...');
|
|
||||||
$dryRun = (bool) $this->option('dry-run');
|
|
||||||
if ($dryRun) {
|
|
||||||
$this->comment('Running in dry-run mode. Nothing will be saved to the database.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$members = Member::query()
|
|
||||||
->where('role', '!=', Role::Placeholder->value)
|
|
||||||
->whereHas('user', function (Builder $builder): void {
|
|
||||||
/** @var Builder<User> $builder */
|
|
||||||
$builder->where('is_placeholder', '=', true);
|
|
||||||
})
|
|
||||||
->get();
|
|
||||||
foreach ($members as $member) {
|
|
||||||
/** @var Member $member */
|
|
||||||
$member->role = Role::Placeholder->value;
|
|
||||||
if (! $dryRun) {
|
|
||||||
$member->save();
|
|
||||||
}
|
|
||||||
$this->line('Set role of member (id='.$member->getKey().') to placeholder');
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Console\Commands\SelfHost;
|
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
use Illuminate\Database\Query\Builder;
|
|
||||||
use Illuminate\Database\Query\JoinClause;
|
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
|
|
||||||
class SelfHostDatabaseConsistency extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'self-host:database-consistency';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle(): int
|
|
||||||
{
|
|
||||||
$hadAProblem = false;
|
|
||||||
|
|
||||||
// Task need to be part of project in time entries
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['time_entries.id as id'])
|
|
||||||
->join('tasks', 'time_entries.task_id', '=', 'tasks.id')
|
|
||||||
->where('tasks.project_id', '!=', DB::raw('time_entries.project_id'))
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Time entries have a task that does not belong to the project of the time entry', $hadAProblem);
|
|
||||||
|
|
||||||
// Client id is the client id of the project
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['time_entries.id as id'])
|
|
||||||
->join('projects', 'time_entries.project_id', '=', 'projects.id')
|
|
||||||
->where(DB::raw('coalesce(projects.client_id::varchar, \'\')'), '!=', DB::raw('coalesce(time_entries.client_id::varchar, \'\')'))
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Time entries have a client that does not match the client of the project', $hadAProblem);
|
|
||||||
|
|
||||||
// Client id can only be not null if the project id is not null
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['time_entries.id as id'])
|
|
||||||
->whereNotNull('client_id')
|
|
||||||
->whereNull('project_id')
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Time entries have a client but no project', $hadAProblem);
|
|
||||||
|
|
||||||
// Every user needs to be a member of at least one organization
|
|
||||||
$problems = DB::table('users')
|
|
||||||
->select(['users.id as id'])
|
|
||||||
->leftJoin('members', 'users.id', '=', 'members.user_id')
|
|
||||||
->whereNull('members.id')
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Users are not member of any organization', $hadAProblem);
|
|
||||||
|
|
||||||
// Every organization needs at least an owner
|
|
||||||
$problems = DB::table('organizations')
|
|
||||||
->select(['organizations.id as id'])
|
|
||||||
->leftJoin('members', function (JoinClause $join): void {
|
|
||||||
$join->on('organizations.id', '=', 'members.organization_id')
|
|
||||||
->where('members.role', '=', 'owner');
|
|
||||||
})
|
|
||||||
->whereNull('members.id')
|
|
||||||
->get();
|
|
||||||
$this->logProblems($problems, 'Organizations without an owner', $hadAProblem);
|
|
||||||
|
|
||||||
// Every member can only have one running time entry
|
|
||||||
$problems = DB::table('time_entries')
|
|
||||||
->select(['user_id as id'])
|
|
||||||
->whereNull('end')
|
|
||||||
->groupBy('user_id')
|
|
||||||
->havingRaw('count(*) > 1')
|
|
||||||
->get(['user_id', DB::raw('count(*) as count')]);
|
|
||||||
$this->logProblems($problems, 'Users with more than one running time entry', $hadAProblem);
|
|
||||||
|
|
||||||
// Users have a current organization that they are not a member of
|
|
||||||
$problems = DB::table('users')
|
|
||||||
->select(['users.id as id'])
|
|
||||||
->whereNotNull('current_team_id')
|
|
||||||
->whereNotIn('current_team_id', function (Builder $query): void {
|
|
||||||
$query->select('organization_id')
|
|
||||||
->from('members')
|
|
||||||
->whereColumn('members.user_id', 'users.id');
|
|
||||||
})->get();
|
|
||||||
$this->logProblems($problems, 'Users have a current organization that they are not a member of', $hadAProblem);
|
|
||||||
|
|
||||||
return $hadAProblem ? self::FAILURE : self::SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Collection<int, \stdClass> $problems
|
|
||||||
*/
|
|
||||||
private function logProblems(Collection $problems, string $message, bool &$hadAProblem): void
|
|
||||||
{
|
|
||||||
$message = 'Consistency problem: '.$message;
|
|
||||||
if ($problems->isNotEmpty()) {
|
|
||||||
$ids = $problems->pluck('id');
|
|
||||||
$hadAProblem = true;
|
|
||||||
Log::error($message, [
|
|
||||||
'ids' => $ids,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$error = $message;
|
|
||||||
foreach ($ids as $id) {
|
|
||||||
$error .= "\n - ".$id;
|
|
||||||
}
|
|
||||||
$this->error($error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -25,10 +25,6 @@ class Kernel extends ConsoleKernel
|
|||||||
$schedule->command('self-host:telemetry')
|
$schedule->command('self-host:telemetry')
|
||||||
->when(fn (): bool => config('scheduling.tasks.self_hosting_telemetry'))
|
->when(fn (): bool => config('scheduling.tasks.self_hosting_telemetry'))
|
||||||
->twiceDaily();
|
->twiceDaily();
|
||||||
|
|
||||||
$schedule->command('self-host:database-consistency')
|
|
||||||
->when(fn (): bool => config('scheduling.tasks.self_hosting_database_consistency'))
|
|
||||||
->twiceDaily();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum CurrencyFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case ISOCodeBeforeWithSpace = 'iso-code-before-with-space';
|
|
||||||
case ISOCodeAfterWithSpace = 'iso-code-after-with-space';
|
|
||||||
|
|
||||||
case SymbolBefore = 'symbol-before';
|
|
||||||
|
|
||||||
case SymbolAfter = 'symbol-after';
|
|
||||||
|
|
||||||
case SymbolBeforeWithSpace = 'symbol-before-with-space';
|
|
||||||
|
|
||||||
case SymbolAfterWithSpace = 'symbol-after-with-space';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.currency_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum DateFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case PointSeparatedDMYYYY = 'point-separated-d-m-yyyy';
|
|
||||||
case SlashSeparatedMMDDYYYY = 'slash-separated-mm-dd-yyyy';
|
|
||||||
|
|
||||||
case SlashSeparatedDDMMYYYY = 'slash-separated-dd-mm-yyyy';
|
|
||||||
|
|
||||||
case HyphenSeparatedDDMMYYY = 'hyphen-separated-dd-mm-yyyy';
|
|
||||||
|
|
||||||
case HyphenSeparatedMMDDDYYYY = 'hyphen-separated-mm-dd-yyyy';
|
|
||||||
|
|
||||||
case HyphenSeparatedYYYYMMDD = 'hyphen-separated-yyyy-mm-dd';
|
|
||||||
|
|
||||||
public function toCarbonFormat(): string
|
|
||||||
{
|
|
||||||
return match ($this->value) {
|
|
||||||
self::PointSeparatedDMYYYY->value => 'j.n.Y',
|
|
||||||
self::SlashSeparatedMMDDYYYY->value => 'm/d/Y',
|
|
||||||
self::SlashSeparatedDDMMYYYY->value => 'd/m/Y',
|
|
||||||
self::HyphenSeparatedDDMMYYY->value => 'd-m-Y',
|
|
||||||
self::HyphenSeparatedMMDDDYYYY->value => 'm-d-Y',
|
|
||||||
self::HyphenSeparatedYYYYMMDD->value => 'Y-m-d',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.date_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum IntervalFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case Decimal = 'decimal';
|
|
||||||
case HoursMinutes = 'hours-minutes';
|
|
||||||
|
|
||||||
case HoursMinutesColonSeparated = 'hours-minutes-colon-separated';
|
|
||||||
|
|
||||||
case HoursMinutesSecondsColonSeparated = 'hours-minutes-seconds-colon-separated';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.interval_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @info https://en.wikipedia.org/wiki/Decimal_separator
|
|
||||||
*/
|
|
||||||
enum NumberFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case ThousandsPointDecimalComma = 'point-comma';
|
|
||||||
|
|
||||||
case ThousandsCommaDecimalPoint = 'comma-point';
|
|
||||||
case ThousandsSpaceDecimalComma = 'space-comma';
|
|
||||||
|
|
||||||
case ThousandsSpaceDecimalPoint = 'space-point';
|
|
||||||
|
|
||||||
case ThousandsApostropheDecimalPoint = 'apostrophe-point';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.number_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Enums;
|
|
||||||
|
|
||||||
use Datomatic\LaravelEnumHelper\LaravelEnumHelper;
|
|
||||||
|
|
||||||
enum TimeFormat: string
|
|
||||||
{
|
|
||||||
use LaravelEnumHelper;
|
|
||||||
|
|
||||||
case TwelveHours = '12-hours';
|
|
||||||
case TwentyFourHours = '24-hours';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function toSelectArray(): array
|
|
||||||
{
|
|
||||||
$selectArray = [];
|
|
||||||
foreach (self::values() as $value) {
|
|
||||||
$selectArray[(string) $value] = (string) __('enum.time_format.'.$value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $selectArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Events;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
|
||||||
|
|
||||||
class DatabaseSeederAfterSeed
|
|
||||||
{
|
|
||||||
use Dispatchable;
|
|
||||||
|
|
||||||
public function __construct() {}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Events;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
|
||||||
|
|
||||||
class DatabaseSeederBeforeDelete
|
|
||||||
{
|
|
||||||
use Dispatchable;
|
|
||||||
|
|
||||||
public function __construct() {}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Exceptions\Api;
|
|
||||||
|
|
||||||
class ChangingRoleOfPlaceholderIsNotAllowed extends ApiException
|
|
||||||
{
|
|
||||||
public const string KEY = 'changing_role_of_placeholder_is_not_allowed';
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Exceptions\Api;
|
|
||||||
|
|
||||||
class OnlyPlaceholdersCanBeMergedIntoAnotherMember extends ApiException
|
|
||||||
{
|
|
||||||
public const string KEY = 'only_placeholders_can_be_merged_into_another_member';
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Exceptions\Api;
|
|
||||||
|
|
||||||
class ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException extends ApiException
|
|
||||||
{
|
|
||||||
public const string KEY = 'this_placeholder_can_not_be_invited_use_the_merge_tool_instead_api_exception';
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@ use Filament\Tables;
|
|||||||
use Filament\Tables\Columns\IconColumn;
|
use Filament\Tables\Columns\IconColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Novadaemon\FilamentPrettyJson\Form\PrettyJsonField;
|
use Novadaemon\FilamentPrettyJson\PrettyJson;
|
||||||
|
|
||||||
class AuditResource extends Resource
|
class AuditResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -38,8 +38,8 @@ class AuditResource extends Resource
|
|||||||
->maxLength(255),
|
->maxLength(255),
|
||||||
Forms\Components\TextInput::make('auditable_id')
|
Forms\Components\TextInput::make('auditable_id')
|
||||||
->required(),
|
->required(),
|
||||||
PrettyJsonField::make('old_values'),
|
PrettyJson::make('old_values'),
|
||||||
PrettyJsonField::make('new_values'),
|
PrettyJson::make('new_values'),
|
||||||
Forms\Components\Textarea::make('url'),
|
Forms\Components\Textarea::make('url'),
|
||||||
Forms\Components\TextInput::make('ip_address'),
|
Forms\Components\TextInput::make('ip_address'),
|
||||||
Forms\Components\TextInput::make('user_agent')
|
Forms\Components\TextInput::make('user_agent')
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use Filament\Tables\Columns\TextColumn;
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Artisan;
|
use Illuminate\Support\Facades\Artisan;
|
||||||
use Novadaemon\FilamentPrettyJson\Form\PrettyJsonField;
|
use Novadaemon\FilamentPrettyJson\PrettyJson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @source https://gitlab.com/amvisor/filament-failed-jobs
|
* @source https://gitlab.com/amvisor/filament-failed-jobs
|
||||||
@@ -50,7 +50,7 @@ class FailedJobResource extends Resource
|
|||||||
|
|
||||||
// make text a little bit smaller because often a complete Stack Trace is shown:
|
// make text a little bit smaller because often a complete Stack Trace is shown:
|
||||||
TextArea::make('exception')->disabled()->columnSpan(4)->extraInputAttributes(['style' => 'font-size: 80%;']),
|
TextArea::make('exception')->disabled()->columnSpan(4)->extraInputAttributes(['style' => 'font-size: 80%;']),
|
||||||
PrettyJsonField::make('payload')->disabled()->columnSpan(4),
|
PrettyJson::make('payload')->disabled()->columnSpan(4),
|
||||||
])->columns(4);
|
])->columns(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Filament\Resources\OrganizationResource\Pages;
|
use App\Filament\Resources\OrganizationResource\Pages;
|
||||||
use App\Filament\Resources\OrganizationResource\RelationManagers\InvitationsRelationManager;
|
use App\Filament\Resources\OrganizationResource\RelationManagers\InvitationsRelationManager;
|
||||||
use App\Filament\Resources\OrganizationResource\RelationManagers\UsersRelationManager;
|
use App\Filament\Resources\OrganizationResource\RelationManagers\UsersRelationManager;
|
||||||
@@ -61,21 +56,6 @@ class OrganizationResource extends Resource
|
|||||||
->searchable(['name', 'email'])
|
->searchable(['name', 'email'])
|
||||||
->disabledOn(['edit'])
|
->disabledOn(['edit'])
|
||||||
->required(),
|
->required(),
|
||||||
Select::make('date_format')
|
|
||||||
->options(DateFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('currency_format')
|
|
||||||
->options(CurrencyFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('interval_format')
|
|
||||||
->options(IntervalFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('number_format')
|
|
||||||
->options(NumberFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Select::make('time_format')
|
|
||||||
->options(TimeFormat::toSelectArray())
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('currency')
|
Forms\Components\Select::make('currency')
|
||||||
->label('Currency')
|
->label('Currency')
|
||||||
->options(function (): array {
|
->options(function (): array {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use Filament\Tables\Columns\TextColumn;
|
|||||||
use Filament\Tables\Columns\ToggleColumn;
|
use Filament\Tables\Columns\ToggleColumn;
|
||||||
use Filament\Tables\Filters\SelectFilter;
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Novadaemon\FilamentPrettyJson\Form\PrettyJsonField;
|
use Novadaemon\FilamentPrettyJson\PrettyJson;
|
||||||
|
|
||||||
class ReportResource extends Resource
|
class ReportResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,7 @@ class ReportResource extends Resource
|
|||||||
Forms\Components\TextInput::make('share_secret')
|
Forms\Components\TextInput::make('share_secret')
|
||||||
->label('Share Secret')
|
->label('Share Secret')
|
||||||
->nullable(),
|
->nullable(),
|
||||||
PrettyJsonField::make('properties')
|
PrettyJson::make('properties')
|
||||||
->formatStateUsing(function (ReportPropertiesDto $state, Report $record): string {
|
->formatStateUsing(function (ReportPropertiesDto $state, Report $record): string {
|
||||||
return $record->getRawOriginal('properties');
|
return $record->getRawOriginal('properties');
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use Filament\Tables;
|
|||||||
use Filament\Tables\Filters\TernaryFilter;
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
@@ -208,14 +207,6 @@ class UserResource extends Resource
|
|||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Tables\Actions\BulkAction::make('Resend verification email')
|
|
||||||
->icon('heroicon-o-paper-airplane')
|
|
||||||
->action(function (Collection $records): void {
|
|
||||||
foreach ($records as $user) {
|
|
||||||
/** @var User $user */
|
|
||||||
$user->sendEmailVerificationNotification();
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class CreateUser extends CreateRecord
|
|||||||
$data['timezone'],
|
$data['timezone'],
|
||||||
Weekday::from($data['week_start']),
|
Weekday::from($data['week_start']),
|
||||||
$data['currency'],
|
$data['currency'],
|
||||||
verifyEmail: (bool) $data['is_email_verified']
|
(bool) $data['is_email_verified']
|
||||||
);
|
);
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
|
|||||||
@@ -1,172 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
|
||||||
|
|
||||||
use App\Enums\Role;
|
|
||||||
use App\Models\Organization;
|
|
||||||
use App\Service\DashboardService;
|
|
||||||
use App\Service\PermissionStore;
|
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
|
|
||||||
class ChartController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId weeklyProjectOverview
|
|
||||||
*
|
|
||||||
* @response array<int, array{value: int, name: string, color: string}>
|
|
||||||
*/
|
|
||||||
public function weeklyProjectOverview(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$weeklyProjectOverview = $dashboardService->weeklyProjectOverview($user, $organization);
|
|
||||||
|
|
||||||
return response()->json($weeklyProjectOverview);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId latestTasks
|
|
||||||
*
|
|
||||||
* @response array<int, array{task_id: string, name: string, description: string|null, status: bool, time_entry_id: string|null}>
|
|
||||||
*/
|
|
||||||
public function latestTasks(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$latestTasks = $dashboardService->latestTasks($user, $organization);
|
|
||||||
|
|
||||||
return response()->json($latestTasks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId lastSevenDays
|
|
||||||
*
|
|
||||||
* @response array<int, array{ date: string, duration: int, history: array<int> }>
|
|
||||||
*/
|
|
||||||
public function lastSevenDays(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$lastSevenDays = $dashboardService->lastSevenDays($user, $organization);
|
|
||||||
|
|
||||||
return response()->json($lastSevenDays);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId latestTeamActivity
|
|
||||||
*
|
|
||||||
* @response array<int, array{member_id: string, name: string, description: string|null, time_entry_id: string, task_id: string|null, status: bool }>
|
|
||||||
*/
|
|
||||||
public function latestTeamActivity(Organization $organization, DashboardService $dashboardService, PermissionStore $permissionStore): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:all');
|
|
||||||
|
|
||||||
$latestTeamActivity = $dashboardService->latestTeamActivity($organization);
|
|
||||||
|
|
||||||
return response()->json($latestTeamActivity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId dailyTrackedHours
|
|
||||||
*
|
|
||||||
* @response array<int, array{date: string, duration: int}>
|
|
||||||
*/
|
|
||||||
public function dailyTrackedHours(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$dailyTrackedHours = $dashboardService->getDailyTrackedHours($user, $organization, 60);
|
|
||||||
|
|
||||||
return response()->json($dailyTrackedHours);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId totalWeeklyTime
|
|
||||||
*
|
|
||||||
* @response int
|
|
||||||
*/
|
|
||||||
public function totalWeeklyTime(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$totalWeeklyTime = $dashboardService->totalWeeklyTime($user, $organization);
|
|
||||||
|
|
||||||
return response()->json($totalWeeklyTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId totalWeeklyBillableTime
|
|
||||||
*
|
|
||||||
* @response int
|
|
||||||
*/
|
|
||||||
public function totalWeeklyBillableTime(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$totalWeeklyBillableTime = $dashboardService->totalWeeklyBillableTime($user, $organization);
|
|
||||||
|
|
||||||
return response()->json($totalWeeklyBillableTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId totalWeeklyBillableAmount
|
|
||||||
*
|
|
||||||
* @response array{value: int, currency: string}
|
|
||||||
*/
|
|
||||||
public function totalWeeklyBillableAmount(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
|
||||||
if (! $showBillableRate) {
|
|
||||||
throw new AuthorizationException('You do not have permission to view billable rates.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$totalWeeklyBillableAmount = $dashboardService->totalWeeklyBillableAmount($user, $organization);
|
|
||||||
|
|
||||||
return response()->json($totalWeeklyBillableAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws AuthorizationException
|
|
||||||
*
|
|
||||||
* @operationId weeklyHistory
|
|
||||||
*
|
|
||||||
* @response array<int, array{date: string, duration: int}>
|
|
||||||
*/
|
|
||||||
public function weeklyHistory(Organization $organization, DashboardService $dashboardService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'charts:view:own');
|
|
||||||
$user = $this->user();
|
|
||||||
|
|
||||||
$weeklyHistory = $dashboardService->getWeeklyHistory($user, $organization);
|
|
||||||
|
|
||||||
return response()->json($weeklyHistory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Api\V1;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Service\CurrencyService;
|
|
||||||
use Brick\Money\Currency;
|
|
||||||
use Brick\Money\ISOCurrencyProvider;
|
|
||||||
use Illuminate\Http\JsonResponse;
|
|
||||||
|
|
||||||
class CurrencyController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get all currencies
|
|
||||||
*
|
|
||||||
* @response array{code: string, name: string, symbol: string}[]
|
|
||||||
*
|
|
||||||
* @operationId getCurrencies
|
|
||||||
*/
|
|
||||||
public function index(): JsonResponse
|
|
||||||
{
|
|
||||||
$currencyService = app(CurrencyService::class);
|
|
||||||
|
|
||||||
$currencies = array_values(array_map(
|
|
||||||
fn (Currency $currency): array => [
|
|
||||||
'code' => $currency->getCurrencyCode(),
|
|
||||||
'name' => $currency->getName(),
|
|
||||||
'symbol' => $currencyService->getCurrencySymbol($currency->getCurrencyCode()),
|
|
||||||
],
|
|
||||||
ISOCurrencyProvider::getInstance()->getAvailableCurrencies()
|
|
||||||
));
|
|
||||||
|
|
||||||
return response()->json($currencies);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,17 +7,12 @@ namespace App\Http\Controllers\Api\V1;
|
|||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Events\MemberMadeToPlaceholder;
|
use App\Events\MemberMadeToPlaceholder;
|
||||||
use App\Exceptions\Api\CanNotRemoveOwnerFromOrganization;
|
use App\Exceptions\Api\CanNotRemoveOwnerFromOrganization;
|
||||||
use App\Exceptions\Api\ChangingRoleOfPlaceholderIsNotAllowed;
|
|
||||||
use App\Exceptions\Api\ChangingRoleToPlaceholderIsNotAllowed;
|
use App\Exceptions\Api\ChangingRoleToPlaceholderIsNotAllowed;
|
||||||
use App\Exceptions\Api\EntityStillInUseApiException;
|
use App\Exceptions\Api\EntityStillInUseApiException;
|
||||||
use App\Exceptions\Api\OnlyOwnerCanChangeOwnership;
|
use App\Exceptions\Api\OnlyOwnerCanChangeOwnership;
|
||||||
use App\Exceptions\Api\OnlyPlaceholdersCanBeMergedIntoAnotherMember;
|
|
||||||
use App\Exceptions\Api\OrganizationNeedsAtLeastOneOwner;
|
use App\Exceptions\Api\OrganizationNeedsAtLeastOneOwner;
|
||||||
use App\Exceptions\Api\ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
|
||||||
use App\Exceptions\Api\UserIsAlreadyMemberOfOrganizationApiException;
|
|
||||||
use App\Exceptions\Api\UserNotPlaceholderApiException;
|
use App\Exceptions\Api\UserNotPlaceholderApiException;
|
||||||
use App\Http\Requests\V1\Member\MemberIndexRequest;
|
use App\Http\Requests\V1\Member\MemberIndexRequest;
|
||||||
use App\Http\Requests\V1\Member\MemberMergeIntoRequest;
|
|
||||||
use App\Http\Requests\V1\Member\MemberUpdateRequest;
|
use App\Http\Requests\V1\Member\MemberUpdateRequest;
|
||||||
use App\Http\Resources\V1\Member\MemberCollection;
|
use App\Http\Resources\V1\Member\MemberCollection;
|
||||||
use App\Http\Resources\V1\Member\MemberResource;
|
use App\Http\Resources\V1\Member\MemberResource;
|
||||||
@@ -29,8 +24,6 @@ use App\Service\MemberService;
|
|||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class MemberController extends Controller
|
class MemberController extends Controller
|
||||||
{
|
{
|
||||||
@@ -70,7 +63,6 @@ class MemberController extends Controller
|
|||||||
* @throws OrganizationNeedsAtLeastOneOwner
|
* @throws OrganizationNeedsAtLeastOneOwner
|
||||||
* @throws OnlyOwnerCanChangeOwnership
|
* @throws OnlyOwnerCanChangeOwnership
|
||||||
* @throws ChangingRoleToPlaceholderIsNotAllowed
|
* @throws ChangingRoleToPlaceholderIsNotAllowed
|
||||||
* @throws ChangingRoleOfPlaceholderIsNotAllowed
|
|
||||||
*
|
*
|
||||||
* @operationId updateMember
|
* @operationId updateMember
|
||||||
*/
|
*/
|
||||||
@@ -113,9 +105,7 @@ class MemberController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Make a member a placeholder member
|
* Make a member a placeholder member
|
||||||
*
|
*
|
||||||
* @throws AuthorizationException|CanNotRemoveOwnerFromOrganization|ChangingRoleOfPlaceholderIsNotAllowed
|
* @throws AuthorizationException|CanNotRemoveOwnerFromOrganization
|
||||||
*
|
|
||||||
* @operationId makePlaceholder
|
|
||||||
*/
|
*/
|
||||||
public function makePlaceholder(Organization $organization, Member $member, MemberService $memberService): JsonResponse
|
public function makePlaceholder(Organization $organization, Member $member, MemberService $memberService): JsonResponse
|
||||||
{
|
{
|
||||||
@@ -124,9 +114,6 @@ class MemberController extends Controller
|
|||||||
if ($member->role === Role::Owner->value) {
|
if ($member->role === Role::Owner->value) {
|
||||||
throw new CanNotRemoveOwnerFromOrganization;
|
throw new CanNotRemoveOwnerFromOrganization;
|
||||||
}
|
}
|
||||||
if ($member->role === Role::Placeholder->value) {
|
|
||||||
throw new ChangingRoleOfPlaceholderIsNotAllowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
$memberService->makeMemberToPlaceholder($member);
|
$memberService->makeMemberToPlaceholder($member);
|
||||||
|
|
||||||
@@ -135,41 +122,10 @@ class MemberController extends Controller
|
|||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Merge one member into another
|
|
||||||
*
|
|
||||||
* @throws AuthorizationException
|
|
||||||
* @throws OnlyPlaceholdersCanBeMergedIntoAnotherMember
|
|
||||||
* @throws \Throwable
|
|
||||||
*
|
|
||||||
* @operationId mergeMember
|
|
||||||
*/
|
|
||||||
public function mergeInto(Organization $organization, Member $member, MemberMergeIntoRequest $request, MemberService $memberService): JsonResponse
|
|
||||||
{
|
|
||||||
$this->checkPermission($organization, 'members:merge-into', $member);
|
|
||||||
|
|
||||||
$user = $member->user;
|
|
||||||
if ($member->role !== Role::Placeholder->value || ! $user->is_placeholder) {
|
|
||||||
throw new OnlyPlaceholdersCanBeMergedIntoAnotherMember;
|
|
||||||
}
|
|
||||||
$memberTo = Member::findOrFail($request->getMemberId());
|
|
||||||
|
|
||||||
DB::transaction(function () use ($organization, $member, $user, $memberTo, $memberService): void {
|
|
||||||
$memberService->assignOrganizationEntitiesToDifferentMember($organization, $member, $memberTo);
|
|
||||||
$member->delete();
|
|
||||||
$user->delete();
|
|
||||||
});
|
|
||||||
|
|
||||||
return response()->json(null, 204);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invite a placeholder member to become a real member of the organization
|
* Invite a placeholder member to become a real member of the organization
|
||||||
*
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException|UserNotPlaceholderApiException
|
||||||
* @throws UserNotPlaceholderApiException
|
|
||||||
* @throws UserIsAlreadyMemberOfOrganizationApiException
|
|
||||||
* @throws ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException
|
|
||||||
*
|
*
|
||||||
* @operationId invitePlaceholder
|
* @operationId invitePlaceholder
|
||||||
*/
|
*/
|
||||||
@@ -182,10 +138,6 @@ class MemberController extends Controller
|
|||||||
throw new UserNotPlaceholderApiException;
|
throw new UserNotPlaceholderApiException;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::endsWith($user->email, '@solidtime-import.test')) {
|
|
||||||
throw new ThisPlaceholderCanNotBeInvitedUseTheMergeToolInsteadException;
|
|
||||||
}
|
|
||||||
|
|
||||||
$invitationService->inviteUser($organization, $user->email, Role::Employee);
|
$invitationService->inviteUser($organization, $user->email, Role::Employee);
|
||||||
|
|
||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
|
|||||||
@@ -40,35 +40,15 @@ class OrganizationController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkPermission($organization, 'organizations:update');
|
$this->checkPermission($organization, 'organizations:update');
|
||||||
|
|
||||||
if ($request->getName() !== null) {
|
$organization->name = $request->input('name');
|
||||||
$organization->name = $request->getName();
|
$oldBillableRate = $organization->billable_rate;
|
||||||
}
|
if ($request->has('employees_can_see_billable_rates')) {
|
||||||
if ($request->getEmployeesCanSeeBillableRates() !== null) {
|
$organization->employees_can_see_billable_rates = $request->validated('employees_can_see_billable_rates');
|
||||||
$organization->employees_can_see_billable_rates = $request->getEmployeesCanSeeBillableRates();
|
|
||||||
}
|
|
||||||
if ($request->getNumberFormat() !== null) {
|
|
||||||
$organization->number_format = $request->getNumberFormat();
|
|
||||||
}
|
|
||||||
if ($request->getCurrencyFormat() !== null) {
|
|
||||||
$organization->currency_format = $request->getCurrencyFormat();
|
|
||||||
}
|
|
||||||
if ($request->getDateFormat() !== null) {
|
|
||||||
$organization->date_format = $request->getDateFormat();
|
|
||||||
}
|
|
||||||
if ($request->getIntervalFormat() !== null) {
|
|
||||||
$organization->interval_format = $request->getIntervalFormat();
|
|
||||||
}
|
|
||||||
if ($request->getTimeFormat() !== null) {
|
|
||||||
$organization->time_format = $request->getTimeFormat();
|
|
||||||
}
|
|
||||||
$hasBillableRate = $request->has('billable_rate');
|
|
||||||
if ($hasBillableRate) {
|
|
||||||
$oldBillableRate = $organization->billable_rate;
|
|
||||||
$organization->billable_rate = $request->getBillableRate();
|
|
||||||
}
|
}
|
||||||
|
$organization->billable_rate = $request->getBillableRate();
|
||||||
$organization->save();
|
$organization->save();
|
||||||
|
|
||||||
if ($hasBillableRate && $oldBillableRate !== $request->getBillableRate()) {
|
if ($oldBillableRate !== $request->getBillableRate()) {
|
||||||
$billableRateService->updateTimeEntriesBillableRateForOrganization($organization);
|
$billableRateService->updateTimeEntriesBillableRateForOrganization($organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ class ReportController extends Controller
|
|||||||
false,
|
false,
|
||||||
$report->properties->start,
|
$report->properties->start,
|
||||||
$report->properties->end,
|
$report->properties->end,
|
||||||
true
|
|
||||||
);
|
);
|
||||||
$historyData = $timeEntryAggregationService->getAggregatedTimeEntriesWithDescriptions(
|
$historyData = $timeEntryAggregationService->getAggregatedTimeEntriesWithDescriptions(
|
||||||
$timeEntriesQuery->clone(),
|
$timeEntriesQuery->clone(),
|
||||||
@@ -84,7 +83,6 @@ class ReportController extends Controller
|
|||||||
true,
|
true,
|
||||||
$report->properties->start,
|
$report->properties->start,
|
||||||
$report->properties->end,
|
$report->properties->end,
|
||||||
true
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return new DetailedWithDataReportResource($report, $data, $historyData);
|
return new DetailedWithDataReportResource($report, $data, $historyData);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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\Role;
|
|
||||||
use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException;
|
use App\Exceptions\Api\FeatureIsNotAvailableInFreePlanApiException;
|
||||||
use App\Exceptions\Api\PdfRendererIsNotConfiguredException;
|
use App\Exceptions\Api\PdfRendererIsNotConfiguredException;
|
||||||
use App\Exceptions\Api\TimeEntryCanNotBeRestartedApiException;
|
use App\Exceptions\Api\TimeEntryCanNotBeRestartedApiException;
|
||||||
@@ -27,7 +26,6 @@ use App\Models\Organization;
|
|||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Service\LocalizationService;
|
|
||||||
use App\Service\ReportExport\TimeEntriesDetailedCsvExport;
|
use App\Service\ReportExport\TimeEntriesDetailedCsvExport;
|
||||||
use App\Service\ReportExport\TimeEntriesDetailedExport;
|
use App\Service\ReportExport\TimeEntriesDetailedExport;
|
||||||
use App\Service\ReportExport\TimeEntriesReportExport;
|
use App\Service\ReportExport\TimeEntriesReportExport;
|
||||||
@@ -182,7 +180,6 @@ class TimeEntryController extends Controller
|
|||||||
}
|
}
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$timezone = $user->timezone;
|
$timezone = $user->timezone;
|
||||||
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
|
||||||
|
|
||||||
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member);
|
$timeEntriesQuery = $this->getTimeEntriesQuery($organization, $request, $member);
|
||||||
$timeEntriesQuery->with([
|
$timeEntriesQuery->with([
|
||||||
@@ -195,7 +192,6 @@ class TimeEntryController extends Controller
|
|||||||
$filename = 'time-entries-export-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
$filename = 'time-entries-export-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
||||||
$folderPath = 'exports';
|
$folderPath = 'exports';
|
||||||
$path = $folderPath.'/'.$filename;
|
$path = $folderPath.'/'.$filename;
|
||||||
$localizationService = LocalizationService::forOrganization($organization);
|
|
||||||
if ($format === ExportFormat::CSV) {
|
if ($format === ExportFormat::CSV) {
|
||||||
$export = new TimeEntriesDetailedCsvExport(config('filesystems.private'), $folderPath, $filename, $timeEntriesQuery, 1000, $timezone);
|
$export = new TimeEntriesDetailedCsvExport(config('filesystems.private'), $folderPath, $filename, $timeEntriesQuery, 1000, $timezone);
|
||||||
$export->export();
|
$export->export();
|
||||||
@@ -215,8 +211,7 @@ class TimeEntryController extends Controller
|
|||||||
$user->week_start,
|
$user->week_start,
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
null,
|
null
|
||||||
$showBillableRate
|
|
||||||
);
|
);
|
||||||
$html = Blade::render($viewFile, [
|
$html = Blade::render($viewFile, [
|
||||||
'timeEntries' => $timeEntriesQuery->get(),
|
'timeEntries' => $timeEntriesQuery->get(),
|
||||||
@@ -225,8 +220,6 @@ class TimeEntryController extends Controller
|
|||||||
'currency' => $organization->currency,
|
'currency' => $organization->currency,
|
||||||
'start' => $request->getStart()->timezone($timezone),
|
'start' => $request->getStart()->timezone($timezone),
|
||||||
'end' => $request->getEnd()->timezone($timezone),
|
'end' => $request->getEnd()->timezone($timezone),
|
||||||
'localization' => $localizationService,
|
|
||||||
'showBillableRate' => $showBillableRate,
|
|
||||||
]);
|
]);
|
||||||
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-index/pdf-footer.blade.php'));
|
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-index/pdf-footer.blade.php'));
|
||||||
if ($footerViewFile === false) {
|
if ($footerViewFile === false) {
|
||||||
@@ -261,7 +254,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 TimeEntriesDetailedExport($timeEntriesQuery, $format, $timezone, $localizationService),
|
new TimeEntriesDetailedExport($timeEntriesQuery, $format, $timezone),
|
||||||
$path,
|
$path,
|
||||||
config('filesystems.private'),
|
config('filesystems.private'),
|
||||||
$format->getExportPackageType(),
|
$format->getExportPackageType(),
|
||||||
@@ -292,18 +285,18 @@ class TimeEntryController extends Controller
|
|||||||
* grouped_data: null|array<array{
|
* grouped_data: null|array<array{
|
||||||
* key: string|null,
|
* key: string|null,
|
||||||
* seconds: int,
|
* seconds: int,
|
||||||
* cost: int|null,
|
* cost: int,
|
||||||
* grouped_type: string|null,
|
* grouped_type: string|null,
|
||||||
* grouped_data: null|array<array{
|
* grouped_data: null|array<array{
|
||||||
* key: string|null,
|
* key: string|null,
|
||||||
* seconds: int,
|
* seconds: int,
|
||||||
* cost: int|null,
|
* cost: int,
|
||||||
* grouped_type: null,
|
* grouped_type: null,
|
||||||
* grouped_data: null
|
* grouped_data: null
|
||||||
* }>
|
* }>
|
||||||
* }>,
|
* }>,
|
||||||
* seconds: int,
|
* seconds: int,
|
||||||
* cost: int|null
|
* cost: int
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
@@ -319,7 +312,6 @@ class TimeEntryController extends Controller
|
|||||||
$this->checkPermission($organization, 'time-entries:view:all');
|
$this->checkPermission($organization, 'time-entries:view:all');
|
||||||
}
|
}
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$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();
|
||||||
@@ -333,8 +325,7 @@ class TimeEntryController extends Controller
|
|||||||
$user->week_start,
|
$user->week_start,
|
||||||
$request->getFillGapsInTimeGroups(),
|
$request->getFillGapsInTimeGroups(),
|
||||||
$request->getStart(),
|
$request->getStart(),
|
||||||
$request->getEnd(),
|
$request->getEnd()
|
||||||
$showBillableRate
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -368,7 +359,6 @@ class TimeEntryController extends Controller
|
|||||||
}
|
}
|
||||||
$debug = $request->getDebug();
|
$debug = $request->getDebug();
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$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();
|
||||||
@@ -382,8 +372,7 @@ class TimeEntryController extends Controller
|
|||||||
$user->week_start,
|
$user->week_start,
|
||||||
false,
|
false,
|
||||||
$request->getStart(),
|
$request->getStart(),
|
||||||
$request->getEnd(),
|
$request->getEnd()
|
||||||
$showBillableRate
|
|
||||||
);
|
);
|
||||||
$dataHistoryChart = $timeEntryAggregationService->getAggregatedTimeEntries(
|
$dataHistoryChart = $timeEntryAggregationService->getAggregatedTimeEntries(
|
||||||
$timeEntriesAggregateQuery->clone(),
|
$timeEntriesAggregateQuery->clone(),
|
||||||
@@ -393,12 +382,10 @@ class TimeEntryController extends Controller
|
|||||||
$user->week_start,
|
$user->week_start,
|
||||||
true,
|
true,
|
||||||
$request->getStart(),
|
$request->getStart(),
|
||||||
$request->getEnd(),
|
$request->getEnd()
|
||||||
$showBillableRate
|
|
||||||
);
|
);
|
||||||
$currency = $organization->currency;
|
$currency = $organization->currency;
|
||||||
$timezone = app(TimezoneService::class)->getTimezoneFromUser($this->user());
|
$timezone = app(TimezoneService::class)->getTimezoneFromUser($this->user());
|
||||||
$localizationService = LocalizationService::forOrganization($organization);
|
|
||||||
|
|
||||||
$filename = 'time-entries-report-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
$filename = 'time-entries-report-'.now()->format('Y-m-d_H-i-s').'.'.$format->getFileExtension();
|
||||||
$folderPath = 'exports';
|
$folderPath = 'exports';
|
||||||
@@ -424,12 +411,9 @@ class TimeEntryController extends Controller
|
|||||||
'currency' => $currency,
|
'currency' => $currency,
|
||||||
'group' => $group,
|
'group' => $group,
|
||||||
'subGroup' => $subGroup,
|
'subGroup' => $subGroup,
|
||||||
'timezone' => $timezone,
|
|
||||||
'start' => $request->getStart()->timezone($timezone),
|
'start' => $request->getStart()->timezone($timezone),
|
||||||
'end' => $request->getEnd()->timezone($timezone),
|
'end' => $request->getEnd()->timezone($timezone),
|
||||||
'debug' => $debug,
|
'debug' => $debug,
|
||||||
'localization' => $localizationService,
|
|
||||||
'showBillableRate' => $showBillableRate,
|
|
||||||
]);
|
]);
|
||||||
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-aggregate/pdf-footer.blade.php'));
|
$footerViewFile = file_get_contents(resource_path('views/reports/time-entry-aggregate/pdf-footer.blade.php'));
|
||||||
if ($footerViewFile === false) {
|
if ($footerViewFile === false) {
|
||||||
@@ -458,7 +442,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),
|
new TimeEntriesReportExport($aggregatedData, $format, $currency, $group, $subGroup),
|
||||||
$path,
|
$path,
|
||||||
config('filesystems.private'),
|
config('filesystems.private'),
|
||||||
$format->getExportPackageType(),
|
$format->getExportPackageType(),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Api\V1;
|
|||||||
|
|
||||||
use App\Http\Resources\V1\User\UserResource;
|
use App\Http\Resources\V1\User\UserResource;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
@@ -18,7 +19,7 @@ class UserController extends Controller
|
|||||||
*
|
*
|
||||||
* @throws AuthorizationException
|
* @throws AuthorizationException
|
||||||
*/
|
*/
|
||||||
public function me(): UserResource
|
public function me(): JsonResource
|
||||||
{
|
{
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Web;
|
namespace App\Http\Controllers\Web;
|
||||||
|
|
||||||
use App\Enums\Role;
|
|
||||||
use App\Service\DashboardService;
|
use App\Service\DashboardService;
|
||||||
use App\Service\PermissionStore;
|
use App\Service\PermissionStore;
|
||||||
use Illuminate\Auth\Access\AuthorizationException;
|
use Illuminate\Auth\Access\AuthorizationException;
|
||||||
@@ -20,14 +19,30 @@ class DashboardController extends Controller
|
|||||||
{
|
{
|
||||||
$user = $this->user();
|
$user = $this->user();
|
||||||
$organization = $this->currentOrganization();
|
$organization = $this->currentOrganization();
|
||||||
|
$dailyTrackedHours = $dashboardService->getDailyTrackedHours($user, $organization, 60);
|
||||||
|
$weeklyHistory = $dashboardService->getWeeklyHistory($user, $organization);
|
||||||
|
$totalWeeklyTime = $dashboardService->totalWeeklyTime($user, $organization);
|
||||||
|
$totalWeeklyBillableTime = $dashboardService->totalWeeklyBillableTime($user, $organization);
|
||||||
|
$totalWeeklyBillableAmount = $dashboardService->totalWeeklyBillableAmount($user, $organization);
|
||||||
|
$weeklyProjectOverview = $dashboardService->weeklyProjectOverview($user, $organization);
|
||||||
|
$latestTasks = $dashboardService->latestTasks($user, $organization);
|
||||||
|
$lastSevenDays = $dashboardService->lastSevenDays($user, $organization);
|
||||||
|
|
||||||
$latestTeamActivity = null;
|
$latestTeamActivity = null;
|
||||||
if ($permissionStore->has($organization, 'time-entries:view:all')) {
|
if ($permissionStore->has($organization, 'time-entries:view:all')) {
|
||||||
$latestTeamActivity = $dashboardService->latestTeamActivity($organization);
|
$latestTeamActivity = $dashboardService->latestTeamActivity($organization);
|
||||||
}
|
}
|
||||||
|
|
||||||
$showBillableRate = $this->member($organization)->role !== Role::Employee->value || $organization->employees_can_see_billable_rates;
|
return Inertia::render('Dashboard', [
|
||||||
|
'weeklyProjectOverview' => $weeklyProjectOverview,
|
||||||
return Inertia::render('Dashboard');
|
'latestTasks' => $latestTasks,
|
||||||
|
'lastSevenDays' => $lastSevenDays,
|
||||||
|
'latestTeamActivity' => $latestTeamActivity,
|
||||||
|
'dailyTrackedHours' => $dailyTrackedHours,
|
||||||
|
'totalWeeklyTime' => $totalWeeklyTime,
|
||||||
|
'totalWeeklyBillableTime' => $totalWeeklyBillableTime,
|
||||||
|
'totalWeeklyBillableAmount' => $totalWeeklyBillableAmount,
|
||||||
|
'weeklyHistory' => $weeklyHistory,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ class HandleInertiaRequests extends Middleware
|
|||||||
public function share(Request $request): array
|
public function share(Request $request): array
|
||||||
{
|
{
|
||||||
$hasBilling = Module::has('Billing') && Module::isEnabled('Billing');
|
$hasBilling = Module::has('Billing') && Module::isEnabled('Billing');
|
||||||
$hasInvoicing = Module::has('Invoicing') && Module::isEnabled('Invoicing');
|
|
||||||
|
|
||||||
/** @var BillingContract $billing */
|
/** @var BillingContract $billing */
|
||||||
$billing = app(BillingContract::class);
|
$billing = app(BillingContract::class);
|
||||||
@@ -49,7 +48,6 @@ class HandleInertiaRequests extends Middleware
|
|||||||
|
|
||||||
return array_merge(parent::share($request), [
|
return array_merge(parent::share($request), [
|
||||||
'has_billing_extension' => $hasBilling,
|
'has_billing_extension' => $hasBilling,
|
||||||
'has_invoicing_extension' => $hasInvoicing,
|
|
||||||
'billing' => $billing !== null && $currentOrganization !== null ? [
|
'billing' => $billing !== null && $currentOrganization !== null ? [
|
||||||
'has_subscription' => $billing->hasSubscription($currentOrganization),
|
'has_subscription' => $billing->hasSubscription($currentOrganization),
|
||||||
'has_trial' => $billing->hasTrial($currentOrganization),
|
'has_trial' => $billing->hasTrial($currentOrganization),
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\ApiToken;
|
namespace App\Http\Requests\V1\ApiToken;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ApiTokenStoreRequest extends BaseFormRequest
|
class ApiTokenStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Requests\V1;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
|
|
||||||
class BaseFormRequest extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return list<string>
|
|
||||||
*/
|
|
||||||
protected function moneyRules(bool $bigInt = false): array
|
|
||||||
{
|
|
||||||
$rules = [
|
|
||||||
'integer',
|
|
||||||
'min:0',
|
|
||||||
];
|
|
||||||
if ($bigInt) {
|
|
||||||
$rules[] = 'max:9223372036854775807';
|
|
||||||
} else {
|
|
||||||
$rules[] = 'max:2147483647';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rules;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Client;
|
namespace App\Http\Requests\V1\Client;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ClientIndexRequest extends BaseFormRequest
|
class ClientIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Client;
|
namespace App\Http\Requests\V1\Client;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ClientStoreRequest extends BaseFormRequest
|
class ClientStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Client;
|
namespace App\Http\Requests\V1\Client;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Client|null $client Client from model binding
|
* @property Client|null $client Client from model binding
|
||||||
*/
|
*/
|
||||||
class ClientUpdateRequest extends BaseFormRequest
|
class ClientUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Import;
|
namespace App\Http\Requests\V1\Import;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ImportRequest extends BaseFormRequest
|
class ImportRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Invitation;
|
namespace App\Http\Requests\V1\Invitation;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class InvitationIndexRequest extends BaseFormRequest
|
class InvitationIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -5,18 +5,18 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Requests\V1\Invitation;
|
namespace App\Http\Requests\V1\Invitation;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\OrganizationInvitation;
|
use App\Models\OrganizationInvitation;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class InvitationStoreRequest extends BaseFormRequest
|
class InvitationStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Member;
|
namespace App\Http\Requests\V1\Member;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class MemberIndexRequest extends BaseFormRequest
|
class MemberIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Http\Requests\V1\Member;
|
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Member;
|
|
||||||
use App\Models\Organization;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property Organization $organization
|
|
||||||
*/
|
|
||||||
class MemberMergeIntoRequest extends BaseFormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array<string, array<string|ValidationRule|\Illuminate\Contracts\Validation\Rule>>
|
|
||||||
*/
|
|
||||||
public function rules(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
// ID of the member to which the data should be transferred (destination)
|
|
||||||
'member_id' => [
|
|
||||||
'string',
|
|
||||||
ExistsEloquent::make(Member::class, null, function (Builder $builder): Builder {
|
|
||||||
/** @var Builder<Member> $builder */
|
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
|
||||||
})->uuid(),
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMemberId(): string
|
|
||||||
{
|
|
||||||
return (string) $this->input('member_id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,15 +5,15 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Requests\V1\Member;
|
namespace App\Http\Requests\V1\Member;
|
||||||
|
|
||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class MemberUpdateRequest extends BaseFormRequest
|
class MemberUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -27,12 +27,12 @@ class MemberUpdateRequest extends BaseFormRequest
|
|||||||
'string',
|
'string',
|
||||||
Rule::enum(Role::class),
|
Rule::enum(Role::class),
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,98 +4,44 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Organization;
|
namespace App\Http\Requests\V1\Organization;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class OrganizationUpdateRequest extends BaseFormRequest
|
class OrganizationUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string|\Illuminate\Contracts\Validation\Rule>>
|
* @return array<string, array<string|ValidationRule>>
|
||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => [
|
'name' => [
|
||||||
|
'required',
|
||||||
'string',
|
'string',
|
||||||
'max:255',
|
'max:255',
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
'employees_can_see_billable_rates' => [
|
'employees_can_see_billable_rates' => [
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'number_format' => [
|
|
||||||
Rule::enum(NumberFormat::class),
|
|
||||||
],
|
|
||||||
'currency_format' => [
|
|
||||||
Rule::enum(CurrencyFormat::class),
|
|
||||||
],
|
|
||||||
'date_format' => [
|
|
||||||
Rule::enum(DateFormat::class),
|
|
||||||
],
|
|
||||||
'interval_format' => [
|
|
||||||
Rule::enum(IntervalFormat::class),
|
|
||||||
],
|
|
||||||
'time_format' => [
|
|
||||||
Rule::enum(TimeFormat::class),
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): ?string
|
|
||||||
{
|
|
||||||
return $this->has('name') ? (string) $this->input('name') : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNumberFormat(): ?NumberFormat
|
|
||||||
{
|
|
||||||
return $this->has('number_format') ? NumberFormat::from($this->input('number_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrencyFormat(): ?CurrencyFormat
|
|
||||||
{
|
|
||||||
return $this->has('currency_format') ? CurrencyFormat::from($this->input('currency_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDateFormat(): ?DateFormat
|
|
||||||
{
|
|
||||||
return $this->has('date_format') ? DateFormat::from($this->input('date_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIntervalFormat(): ?IntervalFormat
|
|
||||||
{
|
|
||||||
return $this->has('interval_format') ? IntervalFormat::from($this->input('interval_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTimeFormat(): ?TimeFormat
|
|
||||||
{
|
|
||||||
return $this->has('time_format') ? TimeFormat::from($this->input('time_format')) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBillableRate(): ?int
|
public function getBillableRate(): ?int
|
||||||
{
|
{
|
||||||
$input = $this->input('billable_rate');
|
$input = $this->input('billable_rate');
|
||||||
|
|
||||||
return $input !== null && $input !== 0 ? (int) $this->input('billable_rate') : null;
|
return $input !== null && $input !== 0 ? (int) $this->input('billable_rate') : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmployeesCanSeeBillableRates(): ?bool
|
|
||||||
{
|
|
||||||
return $this->has('employees_can_see_billable_rates') ? $this->boolean('employees_can_see_billable_rates') : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Project;
|
namespace App\Http\Requests\V1\Project;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
class ProjectIndexRequest extends BaseFormRequest
|
class ProjectIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,21 +4,20 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Project;
|
namespace App\Http\Requests\V1\Project;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Rules\ColorRule;
|
use App\Rules\ColorRule;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectStoreRequest extends BaseFormRequest
|
class ProjectStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -28,7 +27,6 @@ class ProjectStoreRequest extends BaseFormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// Name of the project, the name needs to be unique per client and organization
|
|
||||||
'name' => [
|
'name' => [
|
||||||
'required',
|
'required',
|
||||||
'string',
|
'string',
|
||||||
@@ -36,13 +34,7 @@ class ProjectStoreRequest extends BaseFormRequest
|
|||||||
'max:255',
|
'max:255',
|
||||||
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
$clientId = $this->input('client_id');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
if (! is_string($clientId) || ! Str::isUuid($clientId)) {
|
|
||||||
$clientId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization')
|
|
||||||
->where('client_id', $clientId);
|
|
||||||
})->withCustomTranslation('validation.project_name_already_exists'),
|
})->withCustomTranslation('validation.project_name_already_exists'),
|
||||||
],
|
],
|
||||||
'color' => [
|
'color' => [
|
||||||
@@ -55,15 +47,14 @@ class ProjectStoreRequest extends BaseFormRequest
|
|||||||
'required',
|
'required',
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
// ID of the client
|
// ID of the client
|
||||||
'client_id' => [
|
'client_id' => [
|
||||||
'present',
|
|
||||||
'nullable',
|
'nullable',
|
||||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Client> $builder */
|
/** @var Builder<Client> $builder */
|
||||||
|
|||||||
@@ -4,14 +4,13 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Project;
|
namespace App\Http\Requests\V1\Project;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Rules\ColorRule;
|
use App\Rules\ColorRule;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
|||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Project|null $project Project from model binding
|
* @property Project|null $project Project from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectUpdateRequest extends BaseFormRequest
|
class ProjectUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -35,13 +34,7 @@ class ProjectUpdateRequest extends BaseFormRequest
|
|||||||
'max:255',
|
'max:255',
|
||||||
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
UniqueEloquent::make(Project::class, 'name', function (Builder $builder): Builder {
|
||||||
/** @var Builder<Project> $builder */
|
/** @var Builder<Project> $builder */
|
||||||
$clientId = $this->input('client_id');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
if (! is_string($clientId) || ! Str::isUuid($clientId)) {
|
|
||||||
$clientId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization')
|
|
||||||
->where('client_id', $clientId);
|
|
||||||
})->ignore($this->project?->getKey())->withCustomTranslation('validation.project_name_already_exists'),
|
})->ignore($this->project?->getKey())->withCustomTranslation('validation.project_name_already_exists'),
|
||||||
],
|
],
|
||||||
'color' => [
|
'color' => [
|
||||||
@@ -61,18 +54,18 @@ class ProjectUpdateRequest extends BaseFormRequest
|
|||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
'client_id' => [
|
'client_id' => [
|
||||||
'present',
|
|
||||||
'nullable',
|
'nullable',
|
||||||
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
ExistsEloquent::make(Client::class, null, function (Builder $builder): Builder {
|
||||||
/** @var Builder<Client> $builder */
|
/** @var Builder<Client> $builder */
|
||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
})->uuid(),
|
})->uuid(),
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge([
|
'billable_rate' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
|
'integer',
|
||||||
|
'min:0',
|
||||||
|
'max:2147483647',
|
||||||
],
|
],
|
||||||
$this->moneyRules()
|
|
||||||
),
|
|
||||||
// Estimated time in seconds
|
// Estimated time in seconds
|
||||||
'estimated_time' => [
|
'estimated_time' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\ProjectMember;
|
namespace App\Http\Requests\V1\ProjectMember;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectMemberStoreRequest extends BaseFormRequest
|
class ProjectMemberStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -31,12 +31,12 @@ class ProjectMemberStoreRequest extends BaseFormRequest
|
|||||||
return $builder->whereBelongsTo($this->organization, 'organization');
|
return $builder->whereBelongsTo($this->organization, 'organization');
|
||||||
})->uuid(),
|
})->uuid(),
|
||||||
],
|
],
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\ProjectMember;
|
namespace App\Http\Requests\V1\ProjectMember;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ProjectMemberUpdateRequest extends BaseFormRequest
|
class ProjectMemberUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -21,12 +21,12 @@ class ProjectMemberUpdateRequest extends BaseFormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'billable_rate' => array_merge(
|
'billable_rate' => [
|
||||||
[
|
'nullable',
|
||||||
'nullable',
|
'integer',
|
||||||
],
|
'min:0',
|
||||||
$this->moneyRules()
|
'max:2147483647',
|
||||||
),
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,17 +7,17 @@ namespace App\Http\Requests\V1\Report;
|
|||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||||
use App\Enums\Weekday;
|
use App\Enums\Weekday;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\Rule as LegacyValidationRule;
|
use Illuminate\Contracts\Validation\Rule as LegacyValidationRule;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ReportStoreRequest extends BaseFormRequest
|
class ReportStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -40,7 +40,7 @@ class ReportStoreRequest extends BaseFormRequest
|
|||||||
'required',
|
'required',
|
||||||
'boolean',
|
'boolean',
|
||||||
],
|
],
|
||||||
// After this date the report will be automatically set to private (is_public=false) (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// After this date the report will be automatically set to private (is_public=false) (ISO 8601 format, UTC timezone)
|
||||||
'public_until' => [
|
'public_until' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Report;
|
namespace App\Http\Requests\V1\Report;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class ReportUpdateRequest extends BaseFormRequest
|
class ReportUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Tag;
|
namespace App\Http\Requests\V1\Tag;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TagStoreRequest extends BaseFormRequest
|
class TagStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Tag;
|
namespace App\Http\Requests\V1\Tag;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Tag|null $tag Tag from model binding
|
* @property Tag|null $tag Tag from model binding
|
||||||
*/
|
*/
|
||||||
class TagUpdateRequest extends BaseFormRequest
|
class TagUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Task;
|
namespace App\Http\Requests\V1\Task;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
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\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TaskIndexRequest extends BaseFormRequest
|
class TaskIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,19 +4,19 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Task;
|
namespace App\Http\Requests\V1\Task;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TaskStoreRequest extends BaseFormRequest
|
class TaskStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\Task;
|
namespace App\Http\Requests\V1\Task;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
* @property Task|null $task Task from model binding
|
* @property Task|null $task Task from model binding
|
||||||
*/
|
*/
|
||||||
class TaskUpdateRequest extends BaseFormRequest
|
class TaskUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace App\Http\Requests\V1\TimeEntry;
|
|||||||
use App\Enums\ExportFormat;
|
use App\Enums\ExportFormat;
|
||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Enums\TimeEntryAggregationTypeInterval;
|
use App\Enums\TimeEntryAggregationTypeInterval;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -17,6 +16,7 @@ use App\Models\Task;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
@@ -24,7 +24,7 @@ use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
|||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class TimeEntryAggregateExportRequest extends BaseFormRequest
|
class TimeEntryAggregateExportRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Enums\TimeEntryAggregationType;
|
use App\Enums\TimeEntryAggregationType;
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -15,6 +14,7 @@ use App\Models\Task;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
@@ -22,7 +22,7 @@ use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
|||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class TimeEntryAggregateRequest extends BaseFormRequest
|
class TimeEntryAggregateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryDestroyMultipleRequest extends BaseFormRequest
|
class TimeEntryDestroyMultipleRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
use App\Http\Requests\V1\BaseFormRequest;
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
@@ -13,12 +12,13 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization
|
* @property Organization $organization
|
||||||
*/
|
*/
|
||||||
class TimeEntryIndexRequest extends BaseFormRequest
|
class TimeEntryIndexRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
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;
|
||||||
@@ -12,12 +11,13 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryStoreRequest extends BaseFormRequest
|
class TimeEntryStoreRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -59,12 +59,12 @@ class TimeEntryStoreRequest extends BaseFormRequest
|
|||||||
->where('project_id', $this->input('project_id'));
|
->where('project_id', $this->input('project_id'));
|
||||||
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
||||||
],
|
],
|
||||||
// Start of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// Start of time entry (ISO 8601 format, UTC timezone)
|
||||||
'start' => [
|
'start' => [
|
||||||
'required',
|
'required',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
],
|
],
|
||||||
// End of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// End of time entry (ISO 8601 format, UTC timezone)
|
||||||
'end' => [
|
'end' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
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;
|
||||||
@@ -12,12 +11,13 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryUpdateMultipleRequest extends BaseFormRequest
|
class TimeEntryUpdateMultipleRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Requests\V1\TimeEntry;
|
namespace App\Http\Requests\V1\TimeEntry;
|
||||||
|
|
||||||
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;
|
||||||
@@ -12,12 +11,13 @@ use App\Models\Tag;
|
|||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
use Korridor\LaravelModelValidationRules\Rules\ExistsEloquent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property Organization $organization Organization from model binding
|
* @property Organization $organization Organization from model binding
|
||||||
*/
|
*/
|
||||||
class TimeEntryUpdateRequest extends BaseFormRequest
|
class TimeEntryUpdateRequest extends FormRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
@@ -59,11 +59,11 @@ class TimeEntryUpdateRequest extends BaseFormRequest
|
|||||||
->where('project_id', $this->input('project_id'));
|
->where('project_id', $this->input('project_id'));
|
||||||
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
})->uuid()->withMessage(__('validation.task_belongs_to_project')),
|
||||||
],
|
],
|
||||||
// Start of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// Start of time entry (ISO 8601 format, UTC timezone)
|
||||||
'start' => [
|
'start' => [
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
],
|
],
|
||||||
// End of time entry (Format: "Y-m-d\TH:i:s\Z", UTC timezone, Example: "2000-02-22T14:58:59Z")
|
// End of time entry (ISO 8601 format, UTC timezone)
|
||||||
'end' => [
|
'end' => [
|
||||||
'nullable',
|
'nullable',
|
||||||
'date_format:Y-m-d\TH:i:s\Z',
|
'date_format:Y-m-d\TH:i:s\Z',
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ abstract class BaseResource extends JsonResource
|
|||||||
protected function formatDateTime(?Carbon $carbon): ?string
|
protected function formatDateTime(?Carbon $carbon): ?string
|
||||||
{
|
{
|
||||||
return $carbon?->toIso8601ZuluString();
|
return $carbon?->toIso8601ZuluString();
|
||||||
}
|
|
||||||
|
|
||||||
protected function formatDate(?Carbon $carbon): ?string
|
|
||||||
{
|
|
||||||
return $carbon?->format('Y-m-d');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Resources\V1\Organization;
|
namespace App\Http\Resources\V1\Organization;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Http\Resources\V1\BaseResource;
|
use App\Http\Resources\V1\BaseResource;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Service\CurrencyService;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,8 +34,6 @@ class OrganizationResource extends BaseResource
|
|||||||
*/
|
*/
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$currencyService = app(CurrencyService::class);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
/** @var string $id ID */
|
/** @var string $id ID */
|
||||||
'id' => $this->resource->id,
|
'id' => $this->resource->id,
|
||||||
@@ -55,18 +47,6 @@ class OrganizationResource extends BaseResource
|
|||||||
'employees_can_see_billable_rates' => $this->resource->employees_can_see_billable_rates,
|
'employees_can_see_billable_rates' => $this->resource->employees_can_see_billable_rates,
|
||||||
/** @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 */
|
|
||||||
'currency_symbol' => $currencyService->getCurrencySymbol($this->resource->currency),
|
|
||||||
/** @var NumberFormat $number_format Number format */
|
|
||||||
'number_format' => $this->resource->number_format->value,
|
|
||||||
/** @var CurrencyFormat $currency_format Currency format */
|
|
||||||
'currency_format' => $this->resource->currency_format->value,
|
|
||||||
/** @var DateFormat $date_format Date format */
|
|
||||||
'date_format' => $this->resource->date_format->value,
|
|
||||||
/** @var IntervalFormat $interval_format Interval format */
|
|
||||||
'interval_format' => $this->resource->interval_format->value,
|
|
||||||
/** @var TimeFormat $time_format Time format */
|
|
||||||
'time_format' => $this->resource->time_format->value,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class DetailedReportResource extends BaseResource
|
|||||||
/** @var bool $is_public Whether the report can be accessed via an external link */
|
/** @var bool $is_public Whether the report can be accessed via an external link */
|
||||||
'is_public' => $this->resource->is_public,
|
'is_public' => $this->resource->is_public,
|
||||||
/** @var string|null $public_until Date until the report is public */
|
/** @var string|null $public_until Date until the report is public */
|
||||||
'public_until' => $this->formatDateTime($this->resource->public_until),
|
'public_until' => $this->resource->public_until?->toIso8601ZuluString(),
|
||||||
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
||||||
'shareable_link' => $this->resource->getShareableLink(),
|
'shareable_link' => $this->resource->getShareableLink(),
|
||||||
'properties' => [
|
'properties' => [
|
||||||
@@ -41,9 +41,9 @@ class DetailedReportResource extends BaseResource
|
|||||||
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
||||||
'history_group' => $this->resource->properties->historyGroup->value,
|
'history_group' => $this->resource->properties->historyGroup->value,
|
||||||
/** @var string $start Start date of the report */
|
/** @var string $start Start date of the report */
|
||||||
'start' => $this->formatDateTime($this->resource->properties->start),
|
'start' => $this->resource->properties->start->toIso8601ZuluString(),
|
||||||
/** @var string $end End date of the report */
|
/** @var string $end End date of the report */
|
||||||
'end' => $this->formatDateTime($this->resource->properties->end),
|
'end' => $this->resource->properties->end->toIso8601ZuluString(),
|
||||||
/** @var bool|null $active Whether the report is active */
|
/** @var bool|null $active Whether the report is active */
|
||||||
'active' => $this->resource->properties->active,
|
'active' => $this->resource->properties->active,
|
||||||
/** @var array<string>|null $member_ids Filter by multiple member IDs, member IDs are OR combined */
|
/** @var array<string>|null $member_ids Filter by multiple member IDs, member IDs are OR combined */
|
||||||
@@ -60,9 +60,9 @@ class DetailedReportResource extends BaseResource
|
|||||||
'task_ids' => $this->resource->properties->taskIds?->toArray(),
|
'task_ids' => $this->resource->properties->taskIds?->toArray(),
|
||||||
],
|
],
|
||||||
/** @var string $created_at Date when the report was created */
|
/** @var string $created_at Date when the report was created */
|
||||||
'created_at' => $this->formatDateTime($this->resource->created_at),
|
'created_at' => $this->resource->created_at?->toIso8601ZuluString(),
|
||||||
/** @var string $updated_at Date when the report was last updated */
|
/** @var string $updated_at Date when the report was last updated */
|
||||||
'updated_at' => $this->formatDateTime($this->resource->updated_at),
|
'updated_at' => $this->resource->updated_at?->toIso8601ZuluString(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Http\Resources\V1\Report;
|
namespace App\Http\Resources\V1\Report;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Http\Resources\V1\BaseResource;
|
use App\Http\Resources\V1\BaseResource;
|
||||||
use App\Models\Report;
|
use App\Models\Report;
|
||||||
use App\Service\CurrencyService;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,20 +18,20 @@ use Illuminate\Http\Request;
|
|||||||
* description: string|null,
|
* description: string|null,
|
||||||
* color: string|null,
|
* color: string|null,
|
||||||
* seconds: int,
|
* seconds: int,
|
||||||
* cost: int|null,
|
* cost: int,
|
||||||
* grouped_type: string|null,
|
* grouped_type: string|null,
|
||||||
* grouped_data: null|array<array{
|
* grouped_data: null|array<array{
|
||||||
* key: string|null,
|
* key: string|null,
|
||||||
* description: string|null,
|
* description: string|null,
|
||||||
* color: string|null,
|
* color: string|null,
|
||||||
* seconds: int,
|
* seconds: int,
|
||||||
* cost: int|null,
|
* cost: int,
|
||||||
* grouped_type: null,
|
* grouped_type: null,
|
||||||
* grouped_data: null
|
* grouped_data: null
|
||||||
* }>
|
* }>
|
||||||
* }>,
|
* }>,
|
||||||
* seconds: int,
|
* seconds: int,
|
||||||
* cost: int|null
|
* cost: int
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
class DetailedWithDataReportResource extends BaseResource
|
class DetailedWithDataReportResource extends BaseResource
|
||||||
@@ -70,29 +64,15 @@ class DetailedWithDataReportResource extends BaseResource
|
|||||||
*/
|
*/
|
||||||
public function toArray(Request $request): array
|
public function toArray(Request $request): array
|
||||||
{
|
{
|
||||||
$currencyService = app(CurrencyService::class);
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
/** @var string $name Name */
|
/** @var string $name Name */
|
||||||
'name' => $this->resource->name,
|
'name' => $this->resource->name,
|
||||||
/** @var string|null $email Description */
|
/** @var string|null $email Description */
|
||||||
'description' => $this->resource->description,
|
'description' => $this->resource->description,
|
||||||
/** @var string|null $public_until Date until the report is public */
|
/** @var string|null $public_until Date until the report is public */
|
||||||
'public_until' => $this->formatDateTime($this->resource->public_until),
|
'public_until' => $this->resource->public_until?->toIso8601ZuluString(),
|
||||||
/** @var string $currency Currency code (ISO 4217) */
|
/** @var string $currency Currency code (ISO 4217) */
|
||||||
'currency' => $this->resource->organization->currency,
|
'currency' => $this->resource->organization->currency,
|
||||||
/** @var NumberFormat $number_format Number format */
|
|
||||||
'number_format' => $this->resource->organization->number_format->value,
|
|
||||||
/** @var CurrencyFormat $currency_format Currency format */
|
|
||||||
'currency_format' => $this->resource->organization->currency_format->value,
|
|
||||||
/** @var string $currency_symbol Currency symbol */
|
|
||||||
'currency_symbol' => $currencyService->getCurrencySymbol($this->resource->organization->currency),
|
|
||||||
/** @var DateFormat $date_format Date format */
|
|
||||||
'date_format' => $this->resource->organization->date_format->value,
|
|
||||||
/** @var IntervalFormat $interval_format Interval format */
|
|
||||||
'interval_format' => $this->resource->organization->interval_format->value,
|
|
||||||
/** @var TimeFormat $time_format Time format */
|
|
||||||
'time_format' => $this->resource->organization->time_format->value,
|
|
||||||
'properties' => [
|
'properties' => [
|
||||||
/** @var string $group Type of first grouping */
|
/** @var string $group Type of first grouping */
|
||||||
'group' => $this->resource->properties->group->value,
|
'group' => $this->resource->properties->group->value,
|
||||||
@@ -101,9 +81,9 @@ class DetailedWithDataReportResource extends BaseResource
|
|||||||
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
/** @var string $history_group Type of grouping of the historic aggregation (time chart) */
|
||||||
'history_group' => $this->resource->properties->historyGroup->value,
|
'history_group' => $this->resource->properties->historyGroup->value,
|
||||||
/** @var string $start Start date of the report */
|
/** @var string $start Start date of the report */
|
||||||
'start' => $this->formatDateTime($this->resource->properties->start),
|
'start' => $this->resource->properties->start->toIso8601ZuluString(),
|
||||||
/** @var string $end End date of the report */
|
/** @var string $end End date of the report */
|
||||||
'end' => $this->formatDateTime($this->resource->properties->end),
|
'end' => $this->resource->properties->end->toIso8601ZuluString(),
|
||||||
],
|
],
|
||||||
/** @var array{
|
/** @var array{
|
||||||
* grouped_type: string|null,
|
* grouped_type: string|null,
|
||||||
|
|||||||
@@ -30,13 +30,13 @@ class ReportResource extends BaseResource
|
|||||||
/** @var bool $is_public Whether the report can be accessed via an external link */
|
/** @var bool $is_public Whether the report can be accessed via an external link */
|
||||||
'is_public' => $this->resource->is_public,
|
'is_public' => $this->resource->is_public,
|
||||||
/** @var string|null $public_until Date until the report is public */
|
/** @var string|null $public_until Date until the report is public */
|
||||||
'public_until' => $this->formatDateTime($this->resource->public_until),
|
'public_until' => $this->resource->public_until?->toIso8601ZuluString(),
|
||||||
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
/** @var string|null $shareable_link Get link to access the report externally, not set if the report is private */
|
||||||
'shareable_link' => $this->resource->getShareableLink(),
|
'shareable_link' => $this->resource->getShareableLink(),
|
||||||
/** @var string $created_at Date when the report was created */
|
/** @var string $created_at Date when the report was created */
|
||||||
'created_at' => $this->formatDateTime($this->resource->created_at),
|
'created_at' => $this->resource->created_at?->toIso8601ZuluString(),
|
||||||
/** @var string $updated_at Date when the report was last updated */
|
/** @var string $updated_at Date when the report was last updated */
|
||||||
'updated_at' => $this->formatDateTime($this->resource->updated_at),
|
'updated_at' => $this->resource->updated_at?->toIso8601ZuluString(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace App\Listeners;
|
|||||||
|
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Service\MemberService;
|
use App\Service\UserService;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Laravel\Jetstream\Events\TeamMemberAdded;
|
use Laravel\Jetstream\Events\TeamMemberAdded;
|
||||||
|
|
||||||
@@ -17,11 +17,8 @@ class RemovePlaceholder
|
|||||||
*/
|
*/
|
||||||
public function handle(TeamMemberAdded $event): void
|
public function handle(TeamMemberAdded $event): void
|
||||||
{
|
{
|
||||||
$memberService = app(MemberService::class);
|
/** @var UserService $userService */
|
||||||
$member = Member::query()
|
$userService = app(UserService::class);
|
||||||
->whereBelongsTo($event->team, 'organization')
|
|
||||||
->whereBelongsTo($event->user, 'user')
|
|
||||||
->firstOrFail();
|
|
||||||
$placeholders = Member::query()
|
$placeholders = Member::query()
|
||||||
->whereHas('user', function (Builder $query) use ($event): void {
|
->whereHas('user', function (Builder $query) use ($event): void {
|
||||||
/** @var Builder<User> $query */
|
/** @var Builder<User> $query */
|
||||||
@@ -35,7 +32,7 @@ class RemovePlaceholder
|
|||||||
foreach ($placeholders as $placeholder) {
|
foreach ($placeholders as $placeholder) {
|
||||||
/** @var Member $placeholder */
|
/** @var Member $placeholder */
|
||||||
$placeholderUser = $placeholder->user;
|
$placeholderUser = $placeholder->user;
|
||||||
$memberService->assignOrganizationEntitiesToDifferentMember($event->team, $placeholder, $member);
|
$userService->assignOrganizationEntitiesToDifferentUser($event->team, $placeholderUser, $event->user);
|
||||||
$placeholder->delete();
|
$placeholder->delete();
|
||||||
$placeholderUser->delete();
|
$placeholderUser->delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace App\Models;
|
|||||||
use App\Models\Concerns\CustomAuditable;
|
use App\Models\Concerns\CustomAuditable;
|
||||||
use App\Models\Concerns\HasUuids;
|
use App\Models\Concerns\HasUuids;
|
||||||
use Database\Factories\MemberFactory;
|
use Database\Factories\MemberFactory;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
@@ -25,8 +24,6 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
* @property Carbon|null $updated_at
|
* @property Carbon|null $updated_at
|
||||||
* @property-read Organization $organization
|
* @property-read Organization $organization
|
||||||
* @property-read User $user
|
* @property-read User $user
|
||||||
* @property-read Collection<ProjectMember> $projectMembers
|
|
||||||
* @property-read Collection<TimeEntry> $timeEntries
|
|
||||||
*
|
*
|
||||||
* @method static MemberFactory factory()
|
* @method static MemberFactory factory()
|
||||||
*/
|
*/
|
||||||
@@ -62,14 +59,6 @@ class Member extends JetstreamMembership implements AuditableContract
|
|||||||
return $this->belongsTo(Organization::class, 'organization_id');
|
return $this->belongsTo(Organization::class, 'organization_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return HasMany<TimeEntry>
|
|
||||||
*/
|
|
||||||
public function timeEntries(): HasMany
|
|
||||||
{
|
|
||||||
return $this->hasMany(TimeEntry::class, 'member_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return HasMany<ProjectMember>
|
* @return HasMany<ProjectMember>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Models\Concerns\CustomAuditable;
|
use App\Models\Concerns\CustomAuditable;
|
||||||
use App\Models\Concerns\HasUuids;
|
use App\Models\Concerns\HasUuids;
|
||||||
use Database\Factories\OrganizationFactory;
|
use Database\Factories\OrganizationFactory;
|
||||||
@@ -23,6 +18,7 @@ use Illuminate\Support\Str;
|
|||||||
use Laravel\Jetstream\Events\TeamCreated;
|
use Laravel\Jetstream\Events\TeamCreated;
|
||||||
use Laravel\Jetstream\Events\TeamDeleted;
|
use Laravel\Jetstream\Events\TeamDeleted;
|
||||||
use Laravel\Jetstream\Events\TeamUpdated;
|
use Laravel\Jetstream\Events\TeamUpdated;
|
||||||
|
use Laravel\Jetstream\Jetstream;
|
||||||
use Laravel\Jetstream\Team as JetstreamTeam;
|
use Laravel\Jetstream\Team as JetstreamTeam;
|
||||||
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
||||||
|
|
||||||
@@ -41,11 +37,6 @@ use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
|
|||||||
* @property Collection<int, User> $realUsers
|
* @property Collection<int, User> $realUsers
|
||||||
* @property-read Collection<int, OrganizationInvitation> $teamInvitations
|
* @property-read Collection<int, OrganizationInvitation> $teamInvitations
|
||||||
* @property Member $membership
|
* @property Member $membership
|
||||||
* @property NumberFormat $number_format
|
|
||||||
* @property CurrencyFormat $currency_format
|
|
||||||
* @property DateFormat $date_format
|
|
||||||
* @property IntervalFormat $interval_format
|
|
||||||
* @property TimeFormat $time_format
|
|
||||||
*
|
*
|
||||||
* @method HasMany<OrganizationInvitation> teamInvitations()
|
* @method HasMany<OrganizationInvitation> teamInvitations()
|
||||||
* @method static OrganizationFactory factory()
|
* @method static OrganizationFactory factory()
|
||||||
@@ -69,11 +60,6 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
'personal_team' => 'boolean',
|
'personal_team' => 'boolean',
|
||||||
'currency' => 'string',
|
'currency' => 'string',
|
||||||
'employees_can_see_billable_rates' => 'boolean',
|
'employees_can_see_billable_rates' => 'boolean',
|
||||||
'number_format' => NumberFormat::class,
|
|
||||||
'currency_format' => CurrencyFormat::class,
|
|
||||||
'date_format' => DateFormat::class,
|
|
||||||
'interval_format' => IntervalFormat::class,
|
|
||||||
'time_format' => TimeFormat::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,6 +89,7 @@ class Organization extends JetstreamTeam implements AuditableContract
|
|||||||
* @var array<string, mixed>
|
* @var array<string, mixed>
|
||||||
*/
|
*/
|
||||||
protected $attributes = [
|
protected $attributes = [
|
||||||
|
'currency' => 'EUR',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
Jetstream::defaultApiTokenPermissions([]);
|
Jetstream::defaultApiTokenPermissions([]);
|
||||||
|
|
||||||
Jetstream::role(Role::Owner->value, 'Owner', [
|
Jetstream::role(Role::Owner->value, 'Owner', [
|
||||||
'charts:view:own',
|
|
||||||
'charts:view:all',
|
|
||||||
'projects:view',
|
'projects:view',
|
||||||
'projects:view:all',
|
'projects:view:all',
|
||||||
'projects:create',
|
'projects:create',
|
||||||
@@ -125,7 +123,6 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
'members:invite-placeholder',
|
'members:invite-placeholder',
|
||||||
'members:change-ownership',
|
'members:change-ownership',
|
||||||
'members:make-placeholder',
|
'members:make-placeholder',
|
||||||
'members:merge-into',
|
|
||||||
'members:update',
|
'members:update',
|
||||||
'members:delete',
|
'members:delete',
|
||||||
'billing',
|
'billing',
|
||||||
@@ -133,18 +130,9 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
'reports:create',
|
'reports:create',
|
||||||
'reports:update',
|
'reports:update',
|
||||||
'reports:delete',
|
'reports:delete',
|
||||||
'invoices:view',
|
|
||||||
'invoices:create',
|
|
||||||
'invoices:update',
|
|
||||||
'invoices:download',
|
|
||||||
'invoices:delete',
|
|
||||||
'invoice-settings:view',
|
|
||||||
'invoice-settings:update',
|
|
||||||
])->description('Owner users can perform any action. There is only one owner per organization.');
|
])->description('Owner users can perform any action. There is only one owner per organization.');
|
||||||
|
|
||||||
Jetstream::role(Role::Admin->value, 'Administrator', [
|
Jetstream::role(Role::Admin->value, 'Administrator', [
|
||||||
'charts:view:own',
|
|
||||||
'charts:view:all',
|
|
||||||
'projects:view',
|
'projects:view',
|
||||||
'projects:view:all',
|
'projects:view:all',
|
||||||
'projects:create',
|
'projects:create',
|
||||||
@@ -184,26 +172,15 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
'invitations:resend',
|
'invitations:resend',
|
||||||
'invitations:remove',
|
'invitations:remove',
|
||||||
'members:view',
|
'members:view',
|
||||||
'members:invite-placeholder',
|
|
||||||
'members:make-placeholder',
|
|
||||||
'members:merge-into',
|
|
||||||
'members:update',
|
'members:update',
|
||||||
|
'members:invite-placeholder',
|
||||||
'reports:view',
|
'reports:view',
|
||||||
'reports:create',
|
'reports:create',
|
||||||
'reports:update',
|
'reports:update',
|
||||||
'reports:delete',
|
'reports:delete',
|
||||||
'invoices:view',
|
|
||||||
'invoices:create',
|
|
||||||
'invoices:update',
|
|
||||||
'invoices:download',
|
|
||||||
'invoices:delete',
|
|
||||||
'invoice-settings:view',
|
|
||||||
'invoice-settings:update',
|
|
||||||
])->description('Administrator users can perform any action, except accessing the billing dashboard.');
|
])->description('Administrator users can perform any action, except accessing the billing dashboard.');
|
||||||
|
|
||||||
Jetstream::role(Role::Manager->value, 'Manager', [
|
Jetstream::role(Role::Manager->value, 'Manager', [
|
||||||
'charts:view:own',
|
|
||||||
'charts:view:all',
|
|
||||||
'projects:view',
|
'projects:view',
|
||||||
'projects:view:all',
|
'projects:view:all',
|
||||||
'projects:create',
|
'projects:create',
|
||||||
@@ -241,17 +218,9 @@ class JetstreamServiceProvider extends ServiceProvider
|
|||||||
'reports:create',
|
'reports:create',
|
||||||
'reports:update',
|
'reports:update',
|
||||||
'reports:delete',
|
'reports:delete',
|
||||||
'invoices:view',
|
|
||||||
'invoices:create',
|
|
||||||
'invoices:update',
|
|
||||||
'invoices:download',
|
|
||||||
'invoices:delete',
|
|
||||||
'invoice-settings:view',
|
|
||||||
'invoice-settings:update',
|
|
||||||
])->description('Managers have full access to all projects, time entries, ect. but cannot manage the organization (add/remove member, edit the organization, ect.).');
|
])->description('Managers have full access to all projects, time entries, ect. but cannot manage the organization (add/remove member, edit the organization, ect.).');
|
||||||
|
|
||||||
Jetstream::role(Role::Employee->value, 'Employee', [
|
Jetstream::role(Role::Employee->value, 'Employee', [
|
||||||
'charts:view:own',
|
|
||||||
'projects:view',
|
'projects:view',
|
||||||
'tags:view',
|
'tags:view',
|
||||||
'tasks:view',
|
'tasks:view',
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ class ColorService
|
|||||||
|
|
||||||
private const string VALID_REGEX = '/^#[0-9a-f]{6}$/';
|
private const string VALID_REGEX = '/^#[0-9a-f]{6}$/';
|
||||||
|
|
||||||
public function isBuiltInColor(string $color): bool
|
|
||||||
{
|
|
||||||
return in_array($color, self::COLORS, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRandomColor(?string $seed = null): string
|
public function getRandomColor(?string $seed = null): string
|
||||||
{
|
{
|
||||||
if ($seed !== null) {
|
if ($seed !== null) {
|
||||||
|
|||||||
@@ -1,377 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use Brick\Money\Money;
|
|
||||||
|
|
||||||
class CurrencyService
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @source https://gist.github.com/stephenfrank/a8245c2486f3e546107c5363706ac93e
|
|
||||||
*
|
|
||||||
* @const array<string, array<{ symbol: string }>>
|
|
||||||
*/
|
|
||||||
private const array CURRENCIES = [
|
|
||||||
'ALL' => [
|
|
||||||
'symbol' => 'L',
|
|
||||||
],
|
|
||||||
'AFN' => [
|
|
||||||
'symbol' => '؋',
|
|
||||||
],
|
|
||||||
'ARS' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'AWG' => [
|
|
||||||
'symbol' => 'ƒ',
|
|
||||||
],
|
|
||||||
'AUD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'AZN' => [
|
|
||||||
'symbol' => '₼',
|
|
||||||
],
|
|
||||||
'BSD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'BBD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'BDT' => [
|
|
||||||
'symbol' => '৳',
|
|
||||||
],
|
|
||||||
'BYR' => [
|
|
||||||
'symbol' => 'Br',
|
|
||||||
],
|
|
||||||
'BZD' => [
|
|
||||||
'symbol' => 'BZ$',
|
|
||||||
],
|
|
||||||
'BMD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'BOB' => [
|
|
||||||
'symbol' => '$b',
|
|
||||||
],
|
|
||||||
'BAM' => [
|
|
||||||
'symbol' => 'KM',
|
|
||||||
],
|
|
||||||
'BWP' => [
|
|
||||||
'symbol' => 'P',
|
|
||||||
],
|
|
||||||
'BGN' => [
|
|
||||||
'symbol' => 'лв',
|
|
||||||
],
|
|
||||||
'BRL' => [
|
|
||||||
'symbol' => 'R$',
|
|
||||||
],
|
|
||||||
'BND' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'KHR' => [
|
|
||||||
'symbol' => '៛',
|
|
||||||
],
|
|
||||||
'CAD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'KYD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'CLP' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'CNY' => [
|
|
||||||
'symbol' => '¥',
|
|
||||||
],
|
|
||||||
'COP' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'CRC' => [
|
|
||||||
'symbol' => '₡',
|
|
||||||
],
|
|
||||||
'HRK' => [
|
|
||||||
'symbol' => 'kn',
|
|
||||||
],
|
|
||||||
'CUP' => [
|
|
||||||
'symbol' => '₱',
|
|
||||||
],
|
|
||||||
'CZK' => [
|
|
||||||
'symbol' => 'Kč',
|
|
||||||
],
|
|
||||||
'DKK' => [
|
|
||||||
'symbol' => 'kr',
|
|
||||||
],
|
|
||||||
'DOP' => [
|
|
||||||
'symbol' => 'RD$',
|
|
||||||
],
|
|
||||||
'XCD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'EGP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'SVC' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'EEK' => [
|
|
||||||
'symbol' => 'kr',
|
|
||||||
],
|
|
||||||
'EUR' => [
|
|
||||||
'symbol' => '€',
|
|
||||||
],
|
|
||||||
'FKP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'FJD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'GHC' => [
|
|
||||||
'symbol' => '₵',
|
|
||||||
],
|
|
||||||
'GIP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'GTQ' => [
|
|
||||||
'symbol' => 'Q',
|
|
||||||
],
|
|
||||||
'GGP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'GYD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'HNL' => [
|
|
||||||
'symbol' => 'L',
|
|
||||||
],
|
|
||||||
'HKD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'HUF' => [
|
|
||||||
'symbol' => 'Ft',
|
|
||||||
],
|
|
||||||
'ISK' => [
|
|
||||||
'symbol' => 'kr',
|
|
||||||
],
|
|
||||||
'INR' => [
|
|
||||||
'symbol' => '₹',
|
|
||||||
],
|
|
||||||
'IDR' => [
|
|
||||||
'symbol' => 'Rp',
|
|
||||||
],
|
|
||||||
'IRR' => [
|
|
||||||
'symbol' => '﷼',
|
|
||||||
],
|
|
||||||
'IMP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'ILS' => [
|
|
||||||
'symbol' => '₪',
|
|
||||||
],
|
|
||||||
'JMD' => [
|
|
||||||
'symbol' => 'J$',
|
|
||||||
],
|
|
||||||
'JPY' => [
|
|
||||||
'symbol' => '¥',
|
|
||||||
],
|
|
||||||
'JEP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'KZT' => [
|
|
||||||
'symbol' => 'лв',
|
|
||||||
],
|
|
||||||
'KPW' => [
|
|
||||||
'symbol' => '₩',
|
|
||||||
],
|
|
||||||
'KRW' => [
|
|
||||||
'symbol' => '₩',
|
|
||||||
],
|
|
||||||
'KGS' => [
|
|
||||||
'symbol' => 'лв',
|
|
||||||
],
|
|
||||||
'LAK' => [
|
|
||||||
'symbol' => '₭',
|
|
||||||
],
|
|
||||||
'LVL' => [
|
|
||||||
'symbol' => 'Ls',
|
|
||||||
],
|
|
||||||
'LBP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'LRD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'LTL' => [
|
|
||||||
'symbol' => 'Lt',
|
|
||||||
],
|
|
||||||
'MKD' => [
|
|
||||||
'symbol' => 'ден',
|
|
||||||
],
|
|
||||||
'MYR' => [
|
|
||||||
'symbol' => 'RM',
|
|
||||||
],
|
|
||||||
'MUR' => [
|
|
||||||
'symbol' => '₨',
|
|
||||||
],
|
|
||||||
'MXN' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'MNT' => [
|
|
||||||
'symbol' => '₮',
|
|
||||||
],
|
|
||||||
'MZN' => [
|
|
||||||
'symbol' => 'MT',
|
|
||||||
],
|
|
||||||
'NAD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'NPR' => [
|
|
||||||
'symbol' => '₨',
|
|
||||||
],
|
|
||||||
'ANG' => [
|
|
||||||
'symbol' => 'ƒ',
|
|
||||||
],
|
|
||||||
'NZD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'NIO' => [
|
|
||||||
'symbol' => 'C$',
|
|
||||||
],
|
|
||||||
'NGN' => [
|
|
||||||
'symbol' => '₦',
|
|
||||||
],
|
|
||||||
'NOK' => [
|
|
||||||
'symbol' => 'kr',
|
|
||||||
],
|
|
||||||
'OMR' => [
|
|
||||||
'symbol' => '﷼',
|
|
||||||
],
|
|
||||||
'PKR' => [
|
|
||||||
'symbol' => '₨',
|
|
||||||
],
|
|
||||||
'PAB' => [
|
|
||||||
'symbol' => 'B/.',
|
|
||||||
],
|
|
||||||
'PYG' => [
|
|
||||||
'symbol' => 'Gs',
|
|
||||||
],
|
|
||||||
'PEN' => [
|
|
||||||
'symbol' => 'S/.',
|
|
||||||
],
|
|
||||||
'PHP' => [
|
|
||||||
'symbol' => '₱',
|
|
||||||
],
|
|
||||||
'PLN' => [
|
|
||||||
'symbol' => 'zł',
|
|
||||||
],
|
|
||||||
'QAR' => [
|
|
||||||
'symbol' => '﷼',
|
|
||||||
],
|
|
||||||
'RON' => [
|
|
||||||
'symbol' => 'lei',
|
|
||||||
],
|
|
||||||
'RUB' => [
|
|
||||||
'symbol' => '₽',
|
|
||||||
],
|
|
||||||
'SHP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'SAR' => [
|
|
||||||
'symbol' => '﷼',
|
|
||||||
],
|
|
||||||
'RSD' => [
|
|
||||||
'symbol' => 'Дин.',
|
|
||||||
],
|
|
||||||
'SCR' => [
|
|
||||||
'symbol' => '₨',
|
|
||||||
],
|
|
||||||
'SGD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'SBD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'SOS' => [
|
|
||||||
'symbol' => 'S',
|
|
||||||
],
|
|
||||||
'ZAR' => [
|
|
||||||
'symbol' => 'R',
|
|
||||||
],
|
|
||||||
'LKR' => [
|
|
||||||
'symbol' => '₨',
|
|
||||||
],
|
|
||||||
'SEK' => [
|
|
||||||
'symbol' => 'kr',
|
|
||||||
],
|
|
||||||
'CHF' => [
|
|
||||||
'symbol' => 'CHF',
|
|
||||||
],
|
|
||||||
'SRD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'SYP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'TWD' => [
|
|
||||||
'symbol' => 'NT$',
|
|
||||||
],
|
|
||||||
'THB' => [
|
|
||||||
'symbol' => '฿',
|
|
||||||
],
|
|
||||||
'TTD' => [
|
|
||||||
'symbol' => 'TT$',
|
|
||||||
],
|
|
||||||
'TRY' => [
|
|
||||||
'symbol' => '₺',
|
|
||||||
],
|
|
||||||
'TRL' => [
|
|
||||||
'symbol' => '₤',
|
|
||||||
],
|
|
||||||
'TVD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'UAH' => [
|
|
||||||
'symbol' => '₴',
|
|
||||||
],
|
|
||||||
'GBP' => [
|
|
||||||
'symbol' => '£',
|
|
||||||
],
|
|
||||||
'UGX' => [
|
|
||||||
'symbol' => 'USh',
|
|
||||||
],
|
|
||||||
'USD' => [
|
|
||||||
'symbol' => '$',
|
|
||||||
],
|
|
||||||
'UYU' => [
|
|
||||||
'symbol' => '$U',
|
|
||||||
],
|
|
||||||
'UZS' => [
|
|
||||||
'symbol' => 'лв',
|
|
||||||
],
|
|
||||||
'VEF' => [
|
|
||||||
'symbol' => 'Bs',
|
|
||||||
],
|
|
||||||
'VND' => [
|
|
||||||
'symbol' => '₫',
|
|
||||||
],
|
|
||||||
'YER' => [
|
|
||||||
'symbol' => '﷼',
|
|
||||||
],
|
|
||||||
'ZWD' => [
|
|
||||||
'symbol' => 'Z$',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
public function getCurrencySymbolForMoney(Money $money): string
|
|
||||||
{
|
|
||||||
return $this->getCurrencySymbol($money->getCurrency()->getCurrencyCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCurrencySymbol(string $currencyCode): string
|
|
||||||
{
|
|
||||||
if (isset(self::CURRENCIES[$currencyCode]['symbol'])) {
|
|
||||||
return self::CURRENCIES[$currencyCode]['symbol'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $currencyCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -100,18 +100,12 @@ class DeletionService
|
|||||||
|
|
||||||
// Make sure all users have at least one organization and delete placeholders
|
// Make sure all users have at least one organization and delete placeholders
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
/** @var User $user */
|
|
||||||
if ($ignoreUser !== null && $user->is($ignoreUser)) {
|
if ($ignoreUser !== null && $user->is($ignoreUser)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($user->is_placeholder) {
|
if ($user->is_placeholder) {
|
||||||
$user->delete();
|
$user->delete();
|
||||||
} else {
|
} else {
|
||||||
if ($user->current_team_id === $organization->getKey()) {
|
|
||||||
$user->currentOrganization()->disassociate();
|
|
||||||
$user->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->userService->makeSureUserHasAtLeastOneOrganization($user);
|
$this->userService->makeSureUserHasAtLeastOneOrganization($user);
|
||||||
$this->userService->makeSureUserHasCurrentOrganization($user);
|
$this->userService->makeSureUserHasCurrentOrganization($user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ class ClockifyProjectsImporter extends DefaultImporter
|
|||||||
if ($record['Project'] !== '') {
|
if ($record['Project'] !== '') {
|
||||||
$projectId = $this->projectImportHelper->getKey([
|
$projectId = $this->projectImportHelper->getKey([
|
||||||
'name' => $record['Project'],
|
'name' => $record['Project'],
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->id,
|
'organization_id' => $this->organization->id,
|
||||||
], [
|
], [
|
||||||
|
'client_id' => $clientId,
|
||||||
'color' => $this->colorService->getRandomColor(),
|
'color' => $this->colorService->getRandomColor(),
|
||||||
'is_billable' => $record['Billability'] === 'Yes',
|
'is_billable' => $record['Billability'] === 'Yes',
|
||||||
'billable_rate' => $billableRateKey !== null && $record[$billableRateKey] !== '' ? (int) (((float) $record[$billableRateKey]) * 100) : null,
|
'billable_rate' => $billableRateKey !== null && $record[$billableRateKey] !== '' ? (int) (((float) $record[$billableRateKey]) * 100) : null,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use App\Models\TimeEntry;
|
|||||||
use Carbon\Exceptions\InvalidFormatException;
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use League\Csv\Exception as CsvException;
|
use League\Csv\Exception as CsvException;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
*/
|
*/
|
||||||
private function getTags(string $tags): array
|
private function getTags(string $tags): array
|
||||||
{
|
{
|
||||||
if (Str::trim($tags) === '') {
|
if (trim($tags) === '') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$tagsParsed = explode(', ', $tags);
|
$tagsParsed = explode(', ', $tags);
|
||||||
@@ -83,9 +82,9 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
if ($record['Project'] !== '') {
|
if ($record['Project'] !== '') {
|
||||||
$projectId = $this->projectImportHelper->getKey([
|
$projectId = $this->projectImportHelper->getKey([
|
||||||
'name' => $record['Project'],
|
'name' => $record['Project'],
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->id,
|
'organization_id' => $this->organization->id,
|
||||||
], [
|
], [
|
||||||
|
'client_id' => $clientId,
|
||||||
'color' => $this->colorService->getRandomColor(),
|
'color' => $this->colorService->getRandomColor(),
|
||||||
'is_billable' => false,
|
'is_billable' => false,
|
||||||
]);
|
]);
|
||||||
@@ -124,59 +123,34 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
|||||||
$timeEntry->is_imported = true;
|
$timeEntry->is_imported = true;
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
$start = null;
|
|
||||||
try {
|
try {
|
||||||
$startDateStr = $record['Start Date'];
|
if (preg_match('/^[0-9]{1,2}:[0-9]{1,2} (AM|PM)$/', $record['Start Time']) === 1) {
|
||||||
$startTimeStr = $record['Start Time'];
|
$start = Carbon::createFromFormat('m/d/Y h:i A', $record['Start Date'].' '.$record['Start Time'], $timezone);
|
||||||
$startStr = $startDateStr.' '.$startTimeStr;
|
} else {
|
||||||
$matches = [];
|
$start = Carbon::createFromFormat('m/d/Y H:i:s A', $record['Start Date'].' '.$record['Start Time'], $timezone);
|
||||||
$checkResult = preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2})(:[0-9]{1,2})? (AM|PM)$/', $startStr, $matches);
|
|
||||||
|
|
||||||
if ($checkResult === 1) {
|
|
||||||
if ((int) $matches[1] > 12) {
|
|
||||||
throw new ImportException('Start date ("'.$startDateStr.'") is invalid, please select the correct date format before exporting from Clockify');
|
|
||||||
}
|
|
||||||
if ($matches[6] === '') {
|
|
||||||
$start = Carbon::createFromFormat('m/d/Y h:i A', $startStr, $timezone);
|
|
||||||
} else {
|
|
||||||
$start = Carbon::createFromFormat('m/d/Y H:i:s A', $startStr, $timezone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (InvalidFormatException) {
|
} catch (InvalidFormatException) {
|
||||||
throw new ImportException('Start date ("'.$startDateStr.'") or time ("'.$startTimeStr.'") are invalid');
|
throw new ImportException('Start date ("'.$record['Start Date'].'") or time ("'.$record['Start Time'].'") are invalid');
|
||||||
}
|
}
|
||||||
if ($start === null) {
|
if ($start === null) {
|
||||||
throw new ImportException('Start date ("'.$startDateStr.'") or time ("'.$startTimeStr.'") are invalid');
|
throw new ImportException('Start date ("'.$record['Start Date'].'") or time ("'.$record['Start Time'].'") are invalid');
|
||||||
}
|
}
|
||||||
$timeEntry->start = $start->utc();
|
$timeEntry->start = $start->utc();
|
||||||
|
|
||||||
// End
|
// End
|
||||||
$end = null;
|
|
||||||
try {
|
try {
|
||||||
$endDateStr = $record['End Date'];
|
if (preg_match('/^[0-9]{1,2}:[0-9]{1,2} (AM|PM)$/', $record['End Time']) === 1) {
|
||||||
$endTimeStr = $record['End Time'];
|
$end = Carbon::createFromFormat('m/d/Y h:i A', $record['End Date'].' '.$record['End Time'], $timezone);
|
||||||
$endStr = $endDateStr.' '.$endTimeStr;
|
} else {
|
||||||
$matches = [];
|
$end = Carbon::createFromFormat('m/d/Y H:i:s A', $record['End Date'].' '.$record['End Time'], $timezone);
|
||||||
$checkResult = preg_match('/^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2})(:[0-9]{1,2})? (AM|PM)$/', $endStr, $matches);
|
|
||||||
|
|
||||||
if ($checkResult === 1) {
|
|
||||||
if ((int) $matches[1] > 12) {
|
|
||||||
throw new ImportException('Start date ("'.$endDateStr.'") is invalid, please select the correct date format before exporting from Clockify');
|
|
||||||
}
|
|
||||||
if ($matches[6] === '') {
|
|
||||||
$end = Carbon::createFromFormat('m/d/Y h:i A', $endStr, $timezone);
|
|
||||||
} else {
|
|
||||||
$end = Carbon::createFromFormat('m/d/Y H:i:s A', $endStr, $timezone);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (InvalidFormatException) {
|
} catch (InvalidFormatException) {
|
||||||
throw new ImportException('End date ("'.$endDateStr.'") or time ("'.$endTimeStr.'") are invalid');
|
throw new ImportException('End date ("'.$record['End Date'].'") or time ("'.$record['End Time'].'") are invalid');
|
||||||
}
|
}
|
||||||
if ($end === null) {
|
if ($end === null) {
|
||||||
throw new ImportException('End date ("'.$endDateStr.'") or time ("'.$endTimeStr.'") are invalid');
|
throw new ImportException('End date ("'.$record['End Date'].'") or time ("'.$record['End Time'].'") are invalid');
|
||||||
}
|
}
|
||||||
$timeEntry->end = $end->utc();
|
$timeEntry->end = $end->utc();
|
||||||
|
|
||||||
$timeEntry->billable_rate = $this->billableRateService->getBillableRateForTimeEntryWithGivenRelations(
|
$timeEntry->billable_rate = $this->billableRateService->getBillableRateForTimeEntryWithGivenRelations(
|
||||||
$timeEntry,
|
$timeEntry,
|
||||||
$projectMember,
|
$projectMember,
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ abstract class DefaultImporter implements ImporterContract
|
|||||||
'in:placeholder',
|
'in:placeholder',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->projectImportHelper = new ImportDatabaseHelper(Project::class, ['name', 'client_id', 'organization_id'], true, function (Builder $builder) {
|
$this->projectImportHelper = new ImportDatabaseHelper(Project::class, ['name', '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);
|
||||||
}, validate: [
|
}, validate: [
|
||||||
@@ -114,11 +114,6 @@ abstract class DefaultImporter implements ImporterContract
|
|||||||
'integer',
|
'integer',
|
||||||
'max:2147483647',
|
'max:2147483647',
|
||||||
],
|
],
|
||||||
'client_id' => [
|
|
||||||
'nullable',
|
|
||||||
'string',
|
|
||||||
'uuid',
|
|
||||||
],
|
|
||||||
], beforeSave: function (Project $project): void {
|
], beforeSave: function (Project $project): void {
|
||||||
if ($project->billable_rate === 0) {
|
if ($project->billable_rate === 0) {
|
||||||
$project->billable_rate = null;
|
$project->billable_rate = null;
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service\Import\Importers;
|
|
||||||
|
|
||||||
use App\Service\ColorService;
|
|
||||||
use Carbon\Exceptions\InvalidFormatException;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use League\Csv\Exception as CsvException;
|
|
||||||
use League\Csv\Reader;
|
|
||||||
use Override;
|
|
||||||
|
|
||||||
class GenericProjectsImporter extends DefaultImporter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array<string>
|
|
||||||
*/
|
|
||||||
private const array REQUIRED_FIELDS = [
|
|
||||||
'name',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
#[Override]
|
|
||||||
public function importData(string $data, string $timezone): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$reader = Reader::createFromString($data);
|
|
||||||
$reader->setHeaderOffset(0);
|
|
||||||
$reader->setDelimiter(',');
|
|
||||||
$reader->setEnclosure('"');
|
|
||||||
$reader->setEscape('');
|
|
||||||
$header = $reader->getHeader();
|
|
||||||
$this->validateHeader($header);
|
|
||||||
$records = $reader->getRecords();
|
|
||||||
foreach ($records as $record) {
|
|
||||||
$clientId = null;
|
|
||||||
if (isset($record['client']) && $record['client'] !== '') {
|
|
||||||
$clientId = $this->clientImportHelper->getKey([
|
|
||||||
'name' => $record['client'],
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if ($record['name'] !== '') {
|
|
||||||
$archivedAt = null;
|
|
||||||
if (isset($record['archived_at']) && $record['archived_at'] !== '') {
|
|
||||||
try {
|
|
||||||
$archivedAt = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $record['archived_at'], 'UTC');
|
|
||||||
} catch (InvalidFormatException) {
|
|
||||||
throw new ImportException('Value of archived_at ("'.$record['archived_at'].'") is invalid');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$this->projectImportHelper->getKey([
|
|
||||||
'name' => $record['name'],
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
], [
|
|
||||||
'color' => isset($record['color']) && $record['color'] !== '' ? $record['color'] : app(ColorService::class)->getRandomColor(),
|
|
||||||
'billable_rate' => isset($record['billable_rate']) && $record['billable_rate'] !== '' ? (int) $record['billable_rate'] : null,
|
|
||||||
'is_public' => isset($record['is_public']) && $record['is_public'] === 'true',
|
|
||||||
'is_billable' => isset($record['billable_default']) && $record['billable_default'] === 'true',
|
|
||||||
'estimated_time' => isset($record['estimated_time']) && $record['estimated_time'] !== '' && is_numeric($record['estimated_time']) && ((int) $record['estimated_time'] !== 0) ? (int) $record['estimated_time'] : null,
|
|
||||||
'archived_at' => $archivedAt,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (ImportException $exception) {
|
|
||||||
throw $exception;
|
|
||||||
} catch (CsvException $exception) {
|
|
||||||
throw new ImportException('Invalid CSV data');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
report($exception);
|
|
||||||
throw new ImportException('Unknown error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string> $header
|
|
||||||
*
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function validateHeader(array $header): void
|
|
||||||
{
|
|
||||||
foreach (self::REQUIRED_FIELDS as $requiredField) {
|
|
||||||
if (! in_array($requiredField, $header, true)) {
|
|
||||||
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Override]
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return __('importer.generic_projects.name');
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Override]
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return __('importer.generic_projects.description');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service\Import\Importers;
|
|
||||||
|
|
||||||
use App\Enums\Role;
|
|
||||||
use App\Jobs\RecalculateSpentTimeForProject;
|
|
||||||
use App\Jobs\RecalculateSpentTimeForTask;
|
|
||||||
use App\Models\TimeEntry;
|
|
||||||
use Carbon\Exceptions\InvalidFormatException;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use League\Csv\Exception as CsvException;
|
|
||||||
use League\Csv\Reader;
|
|
||||||
|
|
||||||
class GenericTimeEntriesImporter extends DefaultImporter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array<string>
|
|
||||||
*/
|
|
||||||
private const array REQUIRED_FIELDS = [
|
|
||||||
'description',
|
|
||||||
'billable',
|
|
||||||
'client',
|
|
||||||
'project',
|
|
||||||
'tags',
|
|
||||||
'start',
|
|
||||||
'end',
|
|
||||||
'task',
|
|
||||||
'user_name',
|
|
||||||
'user_email',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string>
|
|
||||||
*
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function getTags(string $tags): array
|
|
||||||
{
|
|
||||||
if (Str::trim($tags) === '') {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
$tagsParsed = explode(',', $tags);
|
|
||||||
$tagIds = [];
|
|
||||||
foreach ($tagsParsed as $tagParsed) {
|
|
||||||
$tagId = $this->tagImportHelper->getKey([
|
|
||||||
'name' => Str::trim($tagParsed),
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
$tagIds[] = $tagId;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tagIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
#[\Override]
|
|
||||||
public function importData(string $data, string $timezone): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$reader = Reader::createFromString($data);
|
|
||||||
$reader->setHeaderOffset(0);
|
|
||||||
$reader->setDelimiter(',');
|
|
||||||
$reader->setEnclosure('"');
|
|
||||||
$reader->setEscape('');
|
|
||||||
$header = $reader->getHeader();
|
|
||||||
$this->validateHeader($header);
|
|
||||||
$records = $reader->getRecords();
|
|
||||||
foreach ($records as $record) {
|
|
||||||
$userId = $this->userImportHelper->getKey([
|
|
||||||
'email' => $record['user_email'],
|
|
||||||
], [
|
|
||||||
'name' => $record['user_name'],
|
|
||||||
'timezone' => 'UTC',
|
|
||||||
'is_placeholder' => true,
|
|
||||||
]);
|
|
||||||
$memberId = $this->memberImportHelper->getKey([
|
|
||||||
'user_id' => $userId,
|
|
||||||
'organization_id' => $this->organization->getKey(),
|
|
||||||
], [
|
|
||||||
'role' => Role::Placeholder->value,
|
|
||||||
]);
|
|
||||||
$member = $this->memberImportHelper->getModelById($memberId);
|
|
||||||
$clientId = null;
|
|
||||||
if ($record['client'] !== '') {
|
|
||||||
$clientId = $this->clientImportHelper->getKey([
|
|
||||||
'name' => $record['client'],
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$projectId = null;
|
|
||||||
$project = null;
|
|
||||||
$projectMember = null;
|
|
||||||
if ($record['project'] !== '') {
|
|
||||||
$projectId = $this->projectImportHelper->getKey([
|
|
||||||
'name' => $record['project'],
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
], [
|
|
||||||
'is_billable' => false,
|
|
||||||
'color' => $this->colorService->getRandomColor(),
|
|
||||||
]);
|
|
||||||
$project = $this->projectImportHelper->getModelById($projectId);
|
|
||||||
$projectMember = $this->projectMemberImportHelper->getModel([
|
|
||||||
'project_id' => $projectId,
|
|
||||||
'member_id' => $memberId,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$taskId = null;
|
|
||||||
if ($record['task'] !== '') {
|
|
||||||
$taskId = $this->taskImportHelper->getKey([
|
|
||||||
'name' => $record['task'],
|
|
||||||
'project_id' => $projectId,
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
$this->taskImportHelper->getModelById($taskId);
|
|
||||||
}
|
|
||||||
$timeEntry = new TimeEntry;
|
|
||||||
$timeEntry->disableAuditing();
|
|
||||||
$timeEntry->user_id = $userId;
|
|
||||||
$timeEntry->member_id = $memberId;
|
|
||||||
$timeEntry->task_id = $taskId;
|
|
||||||
$timeEntry->project_id = $projectId;
|
|
||||||
$timeEntry->client_id = $clientId;
|
|
||||||
$timeEntry->organization_id = $this->organization->id;
|
|
||||||
$timeEntry->description = $record['description'];
|
|
||||||
if (! in_array($record['billable'], ['true', 'false'], true)) {
|
|
||||||
throw new ImportException('Invalid billable value');
|
|
||||||
}
|
|
||||||
$timeEntry->billable = $record['billable'] === 'true';
|
|
||||||
$timeEntry->tags = $this->getTags($record['tags']);
|
|
||||||
$timeEntry->is_imported = true;
|
|
||||||
try {
|
|
||||||
$start = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $record['start'], 'UTC');
|
|
||||||
} catch (InvalidFormatException) {
|
|
||||||
throw new ImportException('Value of start ("'.$record['start'].'") is invalid');
|
|
||||||
}
|
|
||||||
if ($start === null) {
|
|
||||||
throw new ImportException('Value of start ("'.$record['start'].'") is invalid');
|
|
||||||
}
|
|
||||||
$timeEntry->start = $start->utc();
|
|
||||||
|
|
||||||
try {
|
|
||||||
$end = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $record['end'], 'UTC');
|
|
||||||
} catch (InvalidFormatException) {
|
|
||||||
throw new ImportException('Value of end ("'.$record['end'].'") is invalid');
|
|
||||||
}
|
|
||||||
if ($end === null) {
|
|
||||||
throw new ImportException('Value of end ("'.$record['end'].'") is invalid');
|
|
||||||
}
|
|
||||||
$timeEntry->end = $end->utc();
|
|
||||||
$timeEntry->billable_rate = $this->billableRateService->getBillableRateForTimeEntryWithGivenRelations(
|
|
||||||
$timeEntry,
|
|
||||||
$projectMember,
|
|
||||||
$project,
|
|
||||||
$member,
|
|
||||||
$this->organization
|
|
||||||
);
|
|
||||||
$timeEntry->save();
|
|
||||||
$this->timeEntriesCreated++;
|
|
||||||
}
|
|
||||||
foreach ($this->projectImportHelper->getCachedModels() as $usedProject) {
|
|
||||||
RecalculateSpentTimeForProject::dispatch($usedProject);
|
|
||||||
}
|
|
||||||
foreach ($this->taskImportHelper->getCachedModels() as $usedTask) {
|
|
||||||
RecalculateSpentTimeForTask::dispatch($usedTask);
|
|
||||||
}
|
|
||||||
} catch (ImportException $exception) {
|
|
||||||
throw $exception;
|
|
||||||
} catch (CsvException $exception) {
|
|
||||||
throw new ImportException('Invalid CSV data');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
report($exception);
|
|
||||||
throw new ImportException('Unknown error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string> $header
|
|
||||||
*
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function validateHeader(array $header): void
|
|
||||||
{
|
|
||||||
foreach (self::REQUIRED_FIELDS as $requiredField) {
|
|
||||||
if (! in_array($requiredField, $header, true)) {
|
|
||||||
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[\Override]
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return __('importer.generic_time_entries.name');
|
|
||||||
}
|
|
||||||
|
|
||||||
#[\Override]
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return __('importer.generic_time_entries.description');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service\Import\Importers;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use League\Csv\Exception as CsvException;
|
|
||||||
use League\Csv\Reader;
|
|
||||||
|
|
||||||
class HarvestClientsImporter extends DefaultImporter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array<string>
|
|
||||||
*/
|
|
||||||
private const array REQUIRED_FIELDS = [
|
|
||||||
'Client Name',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
#[\Override]
|
|
||||||
public function importData(string $data, string $timezone): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$reader = Reader::createFromString($data);
|
|
||||||
$reader->setHeaderOffset(0);
|
|
||||||
$reader->setDelimiter(',');
|
|
||||||
$reader->setEnclosure('"');
|
|
||||||
$reader->setEscape('');
|
|
||||||
$header = $reader->getHeader();
|
|
||||||
$this->validateHeader($header);
|
|
||||||
$records = $reader->getRecords();
|
|
||||||
foreach ($records as $record) {
|
|
||||||
$this->clientImportHelper->getKey([
|
|
||||||
'name' => $record['Client Name'],
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
} catch (ImportException $exception) {
|
|
||||||
throw $exception;
|
|
||||||
} catch (CsvException $exception) {
|
|
||||||
throw new ImportException('Invalid CSV data');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
report($exception);
|
|
||||||
throw new ImportException('Unknown error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string> $header
|
|
||||||
*
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function validateHeader(array $header): void
|
|
||||||
{
|
|
||||||
foreach (self::REQUIRED_FIELDS as $requiredField) {
|
|
||||||
if (! in_array($requiredField, $header, true)) {
|
|
||||||
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[\Override]
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return __('importer.harvest_clients.name');
|
|
||||||
}
|
|
||||||
|
|
||||||
#[\Override]
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return __('importer.harvest_clients.description');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service\Import\Importers;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use League\Csv\Exception as CsvException;
|
|
||||||
use League\Csv\Reader;
|
|
||||||
|
|
||||||
class HarvestProjectsImporter extends DefaultImporter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array<string>
|
|
||||||
*/
|
|
||||||
private const array REQUIRED_FIELDS = [
|
|
||||||
'Client',
|
|
||||||
'Project',
|
|
||||||
'Budget',
|
|
||||||
'Billable Hours',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
#[\Override]
|
|
||||||
public function importData(string $data, string $timezone): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$reader = Reader::createFromString($data);
|
|
||||||
$reader->setHeaderOffset(0);
|
|
||||||
$reader->setDelimiter(',');
|
|
||||||
$reader->setEnclosure('"');
|
|
||||||
$reader->setEscape('');
|
|
||||||
$header = $reader->getHeader();
|
|
||||||
$this->validateHeader($header);
|
|
||||||
$records = $reader->getRecords();
|
|
||||||
foreach ($records as $record) {
|
|
||||||
$clientId = null;
|
|
||||||
if ($record['Client'] !== '') {
|
|
||||||
$clientId = $this->clientImportHelper->getKey([
|
|
||||||
'name' => $record['Client'],
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
if ($record['Project'] !== '') {
|
|
||||||
if (! isset($record['Budget']) || ! is_string($record['Budget'])) {
|
|
||||||
throw new ImportException('The value for "Budget" is invalid');
|
|
||||||
}
|
|
||||||
$estimatedTimeField = Str::replace(',', '.', $record['Budget']);
|
|
||||||
$estimatedTime = $estimatedTimeField !== '' && is_numeric($estimatedTimeField) ? (int) (((float) $estimatedTimeField) * 60 * 60) : null;
|
|
||||||
if ($estimatedTime === 0) {
|
|
||||||
$estimatedTime = null;
|
|
||||||
}
|
|
||||||
if (! isset($record['Billable Hours']) || ! is_string($record['Billable Hours'])) {
|
|
||||||
throw new ImportException('The value for "Billable Hours" is invalid');
|
|
||||||
}
|
|
||||||
$billableHoursField = Str::replace(',', '.', $record['Billable Hours']);
|
|
||||||
$billableHours = $billableHoursField !== '' && is_numeric($billableHoursField) ? (int) ((float) $billableHoursField) : null;
|
|
||||||
$this->projectImportHelper->getKey([
|
|
||||||
'name' => $record['Project'],
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
], [
|
|
||||||
'color' => $this->colorService->getRandomColor(),
|
|
||||||
'estimated_time' => $estimatedTime,
|
|
||||||
'is_billable' => $billableHours > 0,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (ImportException $exception) {
|
|
||||||
throw $exception;
|
|
||||||
} catch (CsvException $exception) {
|
|
||||||
throw new ImportException('Invalid CSV data');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
report($exception);
|
|
||||||
throw new ImportException('Unknown error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string> $header
|
|
||||||
*
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function validateHeader(array $header): void
|
|
||||||
{
|
|
||||||
foreach (self::REQUIRED_FIELDS as $requiredField) {
|
|
||||||
if (! in_array($requiredField, $header, true)) {
|
|
||||||
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[\Override]
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return __('importer.harvest_projects.name');
|
|
||||||
}
|
|
||||||
|
|
||||||
#[\Override]
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return __('importer.harvest_projects.description');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service\Import\Importers;
|
|
||||||
|
|
||||||
use App\Enums\Role;
|
|
||||||
use App\Jobs\RecalculateSpentTimeForProject;
|
|
||||||
use App\Jobs\RecalculateSpentTimeForTask;
|
|
||||||
use App\Models\TimeEntry;
|
|
||||||
use Carbon\Exceptions\InvalidFormatException;
|
|
||||||
use Exception;
|
|
||||||
use Illuminate\Support\Carbon;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use League\Csv\Exception as CsvException;
|
|
||||||
use League\Csv\Reader;
|
|
||||||
use Override;
|
|
||||||
|
|
||||||
class HarvestTimeEntriesImporter extends DefaultImporter
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array<string>
|
|
||||||
*/
|
|
||||||
private const array REQUIRED_FIELDS = [
|
|
||||||
'Date',
|
|
||||||
'Hours',
|
|
||||||
'Client',
|
|
||||||
'Project',
|
|
||||||
'Task',
|
|
||||||
'Billable?',
|
|
||||||
'First Name',
|
|
||||||
'Last Name',
|
|
||||||
'Notes',
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
#[Override]
|
|
||||||
public function importData(string $data, string $timezone): void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$reader = Reader::createFromString($data);
|
|
||||||
$reader->setHeaderOffset(0);
|
|
||||||
$reader->setDelimiter(',');
|
|
||||||
$reader->setEnclosure('"');
|
|
||||||
$reader->setEscape('');
|
|
||||||
$header = $reader->getHeader();
|
|
||||||
$this->validateHeader($header);
|
|
||||||
$records = $reader->getRecords();
|
|
||||||
foreach ($records as $record) {
|
|
||||||
$firstname = $record['First Name'];
|
|
||||||
$lastname = $record['Last Name'];
|
|
||||||
$userId = $this->userImportHelper->getKey([
|
|
||||||
'email' => Str::slug($firstname).'.'.Str::slug($lastname).'@solidtime-import.test',
|
|
||||||
], [
|
|
||||||
'name' => $firstname.' '.$lastname,
|
|
||||||
'timezone' => 'UTC',
|
|
||||||
'is_placeholder' => true,
|
|
||||||
]);
|
|
||||||
$memberId = $this->memberImportHelper->getKey([
|
|
||||||
'user_id' => $userId,
|
|
||||||
'organization_id' => $this->organization->getKey(),
|
|
||||||
], [
|
|
||||||
'role' => Role::Placeholder->value,
|
|
||||||
]);
|
|
||||||
$member = $this->memberImportHelper->getModelById($memberId);
|
|
||||||
$clientId = null;
|
|
||||||
if ($record['Client'] !== '') {
|
|
||||||
$clientId = $this->clientImportHelper->getKey([
|
|
||||||
'name' => $record['Client'],
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$projectId = null;
|
|
||||||
$project = null;
|
|
||||||
$projectMember = null;
|
|
||||||
if ($record['Project'] !== '') {
|
|
||||||
$projectId = $this->projectImportHelper->getKey([
|
|
||||||
'name' => $record['Project'],
|
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
], [
|
|
||||||
'color' => $this->colorService->getRandomColor(),
|
|
||||||
'is_billable' => true,
|
|
||||||
]);
|
|
||||||
$project = $this->projectImportHelper->getModelById($projectId);
|
|
||||||
$projectMember = $this->projectMemberImportHelper->getModel([
|
|
||||||
'project_id' => $projectId,
|
|
||||||
'member_id' => $memberId,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$taskId = null;
|
|
||||||
if ($record['Task'] !== '') {
|
|
||||||
$taskId = $this->taskImportHelper->getKey([
|
|
||||||
'name' => $record['Task'],
|
|
||||||
'project_id' => $projectId,
|
|
||||||
'organization_id' => $this->organization->id,
|
|
||||||
]);
|
|
||||||
$this->taskImportHelper->getModelById($taskId);
|
|
||||||
}
|
|
||||||
$timeEntry = new TimeEntry;
|
|
||||||
$timeEntry->disableAuditing();
|
|
||||||
$timeEntry->user_id = $userId;
|
|
||||||
$timeEntry->member_id = $memberId;
|
|
||||||
$timeEntry->task_id = $taskId;
|
|
||||||
$timeEntry->project_id = $projectId;
|
|
||||||
$timeEntry->client_id = $clientId;
|
|
||||||
$timeEntry->organization_id = $this->organization->id;
|
|
||||||
if (strlen($record['Notes']) > 500) {
|
|
||||||
throw new ImportException('Time entry note is too long');
|
|
||||||
}
|
|
||||||
$timeEntry->description = $record['Notes'];
|
|
||||||
if (! in_array($record['Billable?'], ['Yes', 'No'], true)) {
|
|
||||||
throw new ImportException('Invalid billable value');
|
|
||||||
}
|
|
||||||
$timeEntry->billable = $record['Billable?'] === 'Yes';
|
|
||||||
$timeEntry->tags = [];
|
|
||||||
$timeEntry->is_imported = true;
|
|
||||||
|
|
||||||
// Start & End
|
|
||||||
try {
|
|
||||||
$date = Carbon::createFromFormat('Y-m-d', $record['Date'], $timezone);
|
|
||||||
} catch (InvalidFormatException) {
|
|
||||||
throw new ImportException('Date ("'.$record['Date'].'") is invalid');
|
|
||||||
}
|
|
||||||
if ($date === null) {
|
|
||||||
throw new ImportException('Date ("'.$record['Date'].'") is invalid');
|
|
||||||
}
|
|
||||||
if (! isset($record['Hours']) || ! is_string($record['Hours'])) {
|
|
||||||
throw new ImportException('Hours ("'.($record['Hours'] ?? '<null>').'") is invalid');
|
|
||||||
}
|
|
||||||
$hoursField = Str::replace(',', '.', $record['Hours']);
|
|
||||||
if (! is_numeric($hoursField)) {
|
|
||||||
throw new ImportException('Hours ("'.$record['Hours'].'") is invalid');
|
|
||||||
}
|
|
||||||
$hours = (float) $hoursField;
|
|
||||||
$timeEntry->start = $date->copy()->startOfDay()->utc();
|
|
||||||
$timeEntry->end = $date->copy()->startOfDay()->addHours($hours)->utc();
|
|
||||||
$timeEntry->billable_rate = $this->billableRateService->getBillableRateForTimeEntryWithGivenRelations(
|
|
||||||
$timeEntry,
|
|
||||||
$projectMember,
|
|
||||||
$project,
|
|
||||||
$member,
|
|
||||||
$this->organization
|
|
||||||
);
|
|
||||||
$timeEntry->save();
|
|
||||||
$this->timeEntriesCreated++;
|
|
||||||
}
|
|
||||||
foreach ($this->projectImportHelper->getCachedModels() as $usedProject) {
|
|
||||||
RecalculateSpentTimeForProject::dispatch($usedProject);
|
|
||||||
}
|
|
||||||
foreach ($this->taskImportHelper->getCachedModels() as $usedTask) {
|
|
||||||
RecalculateSpentTimeForTask::dispatch($usedTask);
|
|
||||||
}
|
|
||||||
} catch (ImportException $exception) {
|
|
||||||
throw $exception;
|
|
||||||
} catch (CsvException $exception) {
|
|
||||||
throw new ImportException('Invalid CSV data');
|
|
||||||
} catch (Exception $exception) {
|
|
||||||
report($exception);
|
|
||||||
throw new ImportException('Unknown error');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string> $header
|
|
||||||
*
|
|
||||||
* @throws ImportException
|
|
||||||
*/
|
|
||||||
private function validateHeader(array $header): void
|
|
||||||
{
|
|
||||||
foreach (self::REQUIRED_FIELDS as $requiredField) {
|
|
||||||
if (! in_array($requiredField, $header, true)) {
|
|
||||||
throw new ImportException('Invalid CSV header, missing field: '.$requiredField);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Override]
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return __('importer.harvest_time_entries.name');
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Override]
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return __('importer.harvest_time_entries.description');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,11 +15,6 @@ class ImporterProvider
|
|||||||
'clockify_time_entries' => ClockifyTimeEntriesImporter::class,
|
'clockify_time_entries' => ClockifyTimeEntriesImporter::class,
|
||||||
'clockify_projects' => ClockifyProjectsImporter::class,
|
'clockify_projects' => ClockifyProjectsImporter::class,
|
||||||
'solidtime' => SolidtimeImporter::class,
|
'solidtime' => SolidtimeImporter::class,
|
||||||
'harvest_projects' => HarvestProjectsImporter::class,
|
|
||||||
'harvest_time_entries' => HarvestTimeEntriesImporter::class,
|
|
||||||
'harvest_clients' => HarvestClientsImporter::class,
|
|
||||||
'generic_projects' => GenericProjectsImporter::class,
|
|
||||||
'generic_time_entries' => GenericTimeEntriesImporter::class,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -176,12 +176,12 @@ class SolidtimeImporter extends DefaultImporter
|
|||||||
|
|
||||||
$this->projectImportHelper->getKey([
|
$this->projectImportHelper->getKey([
|
||||||
'name' => $project['name'],
|
'name' => $project['name'],
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->getKey(),
|
'organization_id' => $this->organization->getKey(),
|
||||||
], [
|
], [
|
||||||
'color' => $project['color'],
|
'color' => $project['color'],
|
||||||
'billable_rate' => $project['billable_rate'] === '' ? null : (int) $project['billable_rate'],
|
'billable_rate' => $project['billable_rate'] === '' ? null : (int) $project['billable_rate'],
|
||||||
'is_public' => $project['is_public'] === 'true',
|
'is_public' => $project['is_public'] === 'true',
|
||||||
|
'client_id' => $clientId,
|
||||||
'is_billable' => $project['is_billable'] === 'true',
|
'is_billable' => $project['is_billable'] === 'true',
|
||||||
'archived_at' => $project['archived_at'] !== '' ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $project['archived_at'], 'UTC') : null,
|
'archived_at' => $project['archived_at'] !== '' ? Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $project['archived_at'], 'UTC') : null,
|
||||||
], $project['id']);
|
], $project['id']);
|
||||||
@@ -328,7 +328,7 @@ class SolidtimeImporter extends DefaultImporter
|
|||||||
*/
|
*/
|
||||||
private function getTags(string $tags): array
|
private function getTags(string $tags): array
|
||||||
{
|
{
|
||||||
if (Str::trim($tags) === '') {
|
if (trim($tags) === '') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$tagsParsed = json_decode($tags);
|
$tagsParsed = json_decode($tags);
|
||||||
|
|||||||
@@ -137,9 +137,9 @@ class TogglDataImporter extends DefaultImporter
|
|||||||
|
|
||||||
$projectId = $this->projectImportHelper->getKey([
|
$projectId = $this->projectImportHelper->getKey([
|
||||||
'name' => $project->name,
|
'name' => $project->name,
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->getKey(),
|
'organization_id' => $this->organization->getKey(),
|
||||||
], [
|
], [
|
||||||
|
'client_id' => $clientId,
|
||||||
'color' => $project->color,
|
'color' => $project->color,
|
||||||
'is_billable' => $project->billable,
|
'is_billable' => $project->billable,
|
||||||
'is_public' => ! $project->is_private,
|
'is_public' => ! $project->is_private,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use App\Models\TimeEntry;
|
|||||||
use Carbon\Exceptions\InvalidFormatException;
|
use Carbon\Exceptions\InvalidFormatException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use League\Csv\Exception as CsvException;
|
use League\Csv\Exception as CsvException;
|
||||||
use League\Csv\Reader;
|
use League\Csv\Reader;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ class TogglTimeEntriesImporter extends DefaultImporter
|
|||||||
*/
|
*/
|
||||||
private function getTags(string $tags): array
|
private function getTags(string $tags): array
|
||||||
{
|
{
|
||||||
if (Str::trim($tags) === '') {
|
if (trim($tags) === '') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$tagsParsed = explode(', ', $tags);
|
$tagsParsed = explode(', ', $tags);
|
||||||
@@ -83,9 +82,9 @@ class TogglTimeEntriesImporter extends DefaultImporter
|
|||||||
if ($record['Project'] !== '') {
|
if ($record['Project'] !== '') {
|
||||||
$projectId = $this->projectImportHelper->getKey([
|
$projectId = $this->projectImportHelper->getKey([
|
||||||
'name' => $record['Project'],
|
'name' => $record['Project'],
|
||||||
'client_id' => $clientId,
|
|
||||||
'organization_id' => $this->organization->id,
|
'organization_id' => $this->organization->id,
|
||||||
], [
|
], [
|
||||||
|
'client_id' => $clientId,
|
||||||
'is_billable' => false,
|
'is_billable' => false,
|
||||||
'color' => $this->colorService->getRandomColor(),
|
'color' => $this->colorService->getRandomColor(),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Service;
|
|
||||||
|
|
||||||
use App\Enums\CurrencyFormat;
|
|
||||||
use App\Enums\DateFormat;
|
|
||||||
use App\Enums\IntervalFormat;
|
|
||||||
use App\Enums\NumberFormat;
|
|
||||||
use App\Enums\TimeFormat;
|
|
||||||
use App\Models\Organization;
|
|
||||||
use Brick\Math\BigDecimal;
|
|
||||||
use Brick\Money\Money;
|
|
||||||
use Carbon\CarbonInterface;
|
|
||||||
use Carbon\CarbonInterval;
|
|
||||||
|
|
||||||
class LocalizationService
|
|
||||||
{
|
|
||||||
private CurrencyFormat $currencyFormat;
|
|
||||||
|
|
||||||
private IntervalFormat $intervalFormat;
|
|
||||||
|
|
||||||
private DateFormat $dateFormat;
|
|
||||||
|
|
||||||
private TimeFormat $timeFormat;
|
|
||||||
|
|
||||||
private NumberFormat $numberFormat;
|
|
||||||
|
|
||||||
public function __construct(CurrencyFormat $currencyFormat, DateFormat $dateFormat, TimeFormat $timeFormat, NumberFormat $numberFormat, IntervalFormat $intervalFormat)
|
|
||||||
{
|
|
||||||
$this->currencyFormat = $currencyFormat;
|
|
||||||
$this->dateFormat = $dateFormat;
|
|
||||||
$this->timeFormat = $timeFormat;
|
|
||||||
$this->numberFormat = $numberFormat;
|
|
||||||
$this->intervalFormat = $intervalFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function forOrganization(Organization $organization): self
|
|
||||||
{
|
|
||||||
return new LocalizationService(
|
|
||||||
$organization->currency_format,
|
|
||||||
$organization->date_format,
|
|
||||||
$organization->time_format,
|
|
||||||
$organization->number_format,
|
|
||||||
$organization->interval_format
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatNumber(BigDecimal|float $number): string
|
|
||||||
{
|
|
||||||
$numberFloat = $number instanceof BigDecimal ? $number->toFloat() : $number;
|
|
||||||
|
|
||||||
if ($this->numberFormat === NumberFormat::ThousandsPointDecimalComma) {
|
|
||||||
return number_format($numberFloat, 2, ',', '.');
|
|
||||||
} elseif ($this->numberFormat === NumberFormat::ThousandsSpaceDecimalPoint) {
|
|
||||||
return number_format($numberFloat, 2, '.', ' ');
|
|
||||||
} elseif ($this->numberFormat === NumberFormat::ThousandsCommaDecimalPoint) {
|
|
||||||
return number_format($numberFloat, 2, '.', ',');
|
|
||||||
} elseif ($this->numberFormat === NumberFormat::ThousandsSpaceDecimalComma) {
|
|
||||||
return number_format($numberFloat, 2, ',', ' ');
|
|
||||||
} elseif ($this->numberFormat === NumberFormat::ThousandsApostropheDecimalPoint) {
|
|
||||||
return number_format($numberFloat, 2, '.', '\'');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatNumberWithoutTrailingZeros(BigDecimal|float $number): string
|
|
||||||
{
|
|
||||||
$number = $this->formatNumber($number);
|
|
||||||
|
|
||||||
$number = rtrim($number, '0');
|
|
||||||
$number = rtrim($number, '.');
|
|
||||||
$number = rtrim($number, ',');
|
|
||||||
|
|
||||||
return $number;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatInterval(CarbonInterval $interval): string
|
|
||||||
{
|
|
||||||
if ($this->intervalFormat === IntervalFormat::Decimal) {
|
|
||||||
$interval->cascade();
|
|
||||||
|
|
||||||
return $this->formatNumber($interval->totalHours).' h';
|
|
||||||
} elseif ($this->intervalFormat === IntervalFormat::HoursMinutes) {
|
|
||||||
$interval->cascade();
|
|
||||||
|
|
||||||
return ((int) floor($interval->totalHours)).'h '.$interval->format('%I').'m';
|
|
||||||
} elseif ($this->intervalFormat === IntervalFormat::HoursMinutesColonSeparated) {
|
|
||||||
$interval->cascade();
|
|
||||||
|
|
||||||
return ((int) floor($interval->totalHours)).':'.$interval->format('%I');
|
|
||||||
} elseif ($this->intervalFormat === IntervalFormat::HoursMinutesSecondsColonSeparated) {
|
|
||||||
$interval->cascade();
|
|
||||||
|
|
||||||
return ((int) floor($interval->totalHours)).':'.$interval->format('%I:%S');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatCurrency(Money $money): string
|
|
||||||
{
|
|
||||||
$currencyService = app(CurrencyService::class);
|
|
||||||
if ($this->currencyFormat === CurrencyFormat::ISOCodeAfterWithSpace) {
|
|
||||||
return $this->formatNumber($money->getAmount()).' '.$money->getCurrency()->getCurrencyCode();
|
|
||||||
} elseif ($this->currencyFormat === CurrencyFormat::ISOCodeBeforeWithSpace) {
|
|
||||||
return $money->getCurrency()->getCurrencyCode().' '.$this->formatNumber($money->getAmount());
|
|
||||||
} elseif ($this->currencyFormat === CurrencyFormat::SymbolAfter) {
|
|
||||||
return $this->formatNumber($money->getAmount()).$currencyService->getCurrencySymbolForMoney($money);
|
|
||||||
} elseif ($this->currencyFormat === CurrencyFormat::SymbolBefore) {
|
|
||||||
return $currencyService->getCurrencySymbolForMoney($money).$this->formatNumber($money->getAmount());
|
|
||||||
} elseif ($this->currencyFormat === CurrencyFormat::SymbolBeforeWithSpace) {
|
|
||||||
return $currencyService->getCurrencySymbolForMoney($money).' '.$this->formatNumber($money->getAmount());
|
|
||||||
} elseif ($this->currencyFormat === CurrencyFormat::SymbolAfterWithSpace) {
|
|
||||||
return $this->formatNumber($money->getAmount()).' '.$currencyService->getCurrencySymbolForMoney($money);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatTime(CarbonInterface $time): string
|
|
||||||
{
|
|
||||||
if ($this->timeFormat === TimeFormat::TwelveHours) {
|
|
||||||
return $time->format('h:i a'); // Examples: "11:01 am", "1:02 am"
|
|
||||||
} elseif ($this->timeFormat === TimeFormat::TwentyFourHours) {
|
|
||||||
return $time->format('H:i'); // Examples: "23:01", "01:02"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function formatDate(CarbonInterface $date): string
|
|
||||||
{
|
|
||||||
return $date->format($this->dateFormat->toCarbonFormat());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDateFormat(DateFormat $dateFormat): void
|
|
||||||
{
|
|
||||||
$this->dateFormat = $dateFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setCurrencyFormat(CurrencyFormat $currencyFormat): void
|
|
||||||
{
|
|
||||||
$this->currencyFormat = $currencyFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIntervalFormat(IntervalFormat $intervalFormat): void
|
|
||||||
{
|
|
||||||
$this->intervalFormat = $intervalFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTimeFormat(TimeFormat $timeFormat): void
|
|
||||||
{
|
|
||||||
$this->timeFormat = $timeFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNumberFormat(NumberFormat $numberFormat): void
|
|
||||||
{
|
|
||||||
$this->numberFormat = $numberFormat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,18 +7,15 @@ namespace App\Service;
|
|||||||
use App\Enums\Role;
|
use App\Enums\Role;
|
||||||
use App\Events\MemberRemoved;
|
use App\Events\MemberRemoved;
|
||||||
use App\Exceptions\Api\CanNotRemoveOwnerFromOrganization;
|
use App\Exceptions\Api\CanNotRemoveOwnerFromOrganization;
|
||||||
use App\Exceptions\Api\ChangingRoleOfPlaceholderIsNotAllowed;
|
|
||||||
use App\Exceptions\Api\ChangingRoleToPlaceholderIsNotAllowed;
|
use App\Exceptions\Api\ChangingRoleToPlaceholderIsNotAllowed;
|
||||||
use App\Exceptions\Api\EntityStillInUseApiException;
|
use App\Exceptions\Api\EntityStillInUseApiException;
|
||||||
use App\Exceptions\Api\OnlyOwnerCanChangeOwnership;
|
use App\Exceptions\Api\OnlyOwnerCanChangeOwnership;
|
||||||
use App\Exceptions\Api\OrganizationNeedsAtLeastOneOwner;
|
use App\Exceptions\Api\OrganizationNeedsAtLeastOneOwner;
|
||||||
use App\Models\Member;
|
use App\Models\Member;
|
||||||
use App\Models\Organization;
|
use App\Models\Organization;
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\ProjectMember;
|
use App\Models\ProjectMember;
|
||||||
use App\Models\TimeEntry;
|
use App\Models\TimeEntry;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Laravel\Jetstream\Events\AddingTeamMember;
|
use Laravel\Jetstream\Events\AddingTeamMember;
|
||||||
@@ -78,7 +75,6 @@ class MemberService
|
|||||||
* @throws ChangingRoleToPlaceholderIsNotAllowed
|
* @throws ChangingRoleToPlaceholderIsNotAllowed
|
||||||
* @throws OnlyOwnerCanChangeOwnership
|
* @throws OnlyOwnerCanChangeOwnership
|
||||||
* @throws OrganizationNeedsAtLeastOneOwner
|
* @throws OrganizationNeedsAtLeastOneOwner
|
||||||
* @throws ChangingRoleOfPlaceholderIsNotAllowed
|
|
||||||
*/
|
*/
|
||||||
public function changeRole(Member $member, Organization $organization, Role $newRole, bool $allowOwnerChange): void
|
public function changeRole(Member $member, Organization $organization, Role $newRole, bool $allowOwnerChange): void
|
||||||
{
|
{
|
||||||
@@ -86,9 +82,6 @@ class MemberService
|
|||||||
if ($oldRole === Role::Owner) {
|
if ($oldRole === Role::Owner) {
|
||||||
throw new OrganizationNeedsAtLeastOneOwner;
|
throw new OrganizationNeedsAtLeastOneOwner;
|
||||||
}
|
}
|
||||||
if ($oldRole === Role::Placeholder) {
|
|
||||||
throw new ChangingRoleOfPlaceholderIsNotAllowed;
|
|
||||||
}
|
|
||||||
if ($newRole === Role::Placeholder) {
|
if ($newRole === Role::Placeholder) {
|
||||||
throw new ChangingRoleToPlaceholderIsNotAllowed;
|
throw new ChangingRoleToPlaceholderIsNotAllowed;
|
||||||
}
|
}
|
||||||
@@ -103,39 +96,6 @@ class MemberService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assignOrganizationEntitiesToDifferentMember(Organization $organization, Member $fromMember, Member $toMember): void
|
|
||||||
{
|
|
||||||
// Time entries
|
|
||||||
TimeEntry::query()
|
|
||||||
->whereBelongsTo($organization, 'organization')
|
|
||||||
->whereBelongsTo($fromMember, 'member')
|
|
||||||
->update([
|
|
||||||
'user_id' => $toMember->user_id,
|
|
||||||
'member_id' => $toMember->getKey(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Project members
|
|
||||||
ProjectMember::query()
|
|
||||||
->whereBelongsToOrganization($organization)
|
|
||||||
->whereBelongsTo($fromMember, 'member')
|
|
||||||
->whereDoesntHave('project', function (Builder $builder) use ($toMember): void {
|
|
||||||
/** @var Builder<Project> $builder */
|
|
||||||
$builder->whereHas('members', function (Builder $builder) use ($toMember): void {
|
|
||||||
/** @var Builder<ProjectMember> $builder */
|
|
||||||
$builder->where('member_id', $toMember->getKey());
|
|
||||||
});
|
|
||||||
})
|
|
||||||
->update([
|
|
||||||
'user_id' => $toMember->user_id,
|
|
||||||
'member_id' => $toMember->getKey(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
ProjectMember::query()
|
|
||||||
->whereBelongsToOrganization($organization)
|
|
||||||
->whereBelongsTo($fromMember, 'member')
|
|
||||||
->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the ownership of an organization to a new user.
|
* Change the ownership of an organization to a new user.
|
||||||
* The previous owner will be demoted to an admin.
|
* The previous owner will be demoted to an admin.
|
||||||
@@ -164,11 +124,6 @@ class MemberService
|
|||||||
public function makeMemberToPlaceholder(Member $member, bool $makeSureUserHasAtLeastOneOrganization = true): void
|
public function makeMemberToPlaceholder(Member $member, bool $makeSureUserHasAtLeastOneOrganization = true): void
|
||||||
{
|
{
|
||||||
$user = $member->user;
|
$user = $member->user;
|
||||||
if ($user->current_team_id === $member->organization_id) {
|
|
||||||
$user->currentTeam()->disassociate();
|
|
||||||
$user->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
$placeholderUser = $user->replicate();
|
$placeholderUser = $user->replicate();
|
||||||
$placeholderUser->is_placeholder = true;
|
$placeholderUser->is_placeholder = true;
|
||||||
$placeholderUser->save();
|
$placeholderUser->save();
|
||||||
@@ -177,10 +132,9 @@ class MemberService
|
|||||||
$member->role = Role::Placeholder->value;
|
$member->role = Role::Placeholder->value;
|
||||||
$member->save();
|
$member->save();
|
||||||
|
|
||||||
$this->userService->assignOrganizationEntitiesToDifferentUser($member->organization, $user, $placeholderUser);
|
$this->userService->assignOrganizationEntitiesToDifferentMember($member->organization, $user, $placeholderUser, $member);
|
||||||
if ($makeSureUserHasAtLeastOneOrganization) {
|
if ($makeSureUserHasAtLeastOneOrganization) {
|
||||||
$this->userService->makeSureUserHasAtLeastOneOrganization($user);
|
$this->userService->makeSureUserHasAtLeastOneOrganization($user);
|
||||||
$this->userService->makeSureUserHasCurrentOrganization($user);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user