Add the task calendar, holidays, workflow templates and customer removal

Task calendar (/jobs/calendar) replaces per-unit task Kanban columns
(K34): a two-week Gantt of tasks per person. Bars move, resize and
change person by dragging or through a keyboard dialog. Each task's
estimate is booked evenly over working days into task_bookings, and
what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves
to the next working day. Tasks get planned_from/planned_to on the form.

Holidays (/settings/holidays): Finnish public holidays calculated per
year, which the admin can take out of use, plus company days off.

Also includes the earlier uncommitted work: workflow templates with
adding tasks from a template, and removing customers no module refers to.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 18:13:11 +02:00
co-authored by Claude Opus 5.5
parent dfe4941f02
commit b4f2f1cfaa
134 changed files with 6930 additions and 45 deletions
@@ -4,12 +4,17 @@ use App\Modules\Customers\Application\Contracts\CustomerQueries;
use App\Modules\Customers\Application\DTOs\BillingUnitSummary;
use App\Modules\Customers\Application\DTOs\ContactSummary;
use App\Modules\Customers\Application\DTOs\CustomerSummary;
use App\Modules\Customers\Application\Services\CustomerRemoval;
use App\Modules\Customers\Application\UseCases\RemoveBillingUnit;
use App\Modules\Customers\Application\UseCases\RemoveContact;
use App\Modules\Customers\Application\UseCases\RemoveCustomer;
use App\Modules\Customers\Domain\Exceptions\BillingUnitInUse;
use App\Modules\Customers\Domain\Exceptions\BillingUnitNotFound;
use App\Modules\Customers\Domain\Exceptions\ContactInUse;
use App\Modules\Customers\Domain\Exceptions\ContactNotFound;
use App\Modules\Customers\Domain\Exceptions\CustomerInUse;
use App\Modules\Customers\Domain\Exceptions\CustomerNotFound;
use App\Modules\Customers\Domain\Exceptions\InternalCustomerCannotBeRemoved;
use App\Modules\Customers\Domain\Enums\CustomerType;
use Illuminate\Support\Facades\Gate;
use Livewire\Attributes\Computed;
@@ -17,7 +22,8 @@ use Livewire\Attributes\Locked;
use Livewire\Component;
/**
* A customer's page: details, contacts and billing units.
* A customer's page: details, contacts and billing units. A customer with
* nothing linked to it can be removed here.
*/
new class extends Component
{
@@ -27,7 +33,7 @@ new class extends Component
public int $customerId;
/**
* The row the remove dialog asks about: 'contact' or 'billing_unit'.
* What the remove dialog asks about: 'customer', 'contact' or 'billing_unit'.
*/
#[Locked]
public ?string $removalType = null;
@@ -42,9 +48,12 @@ new class extends Component
protected CustomerQueries $customerQueries;
public function boot(CustomerQueries $customerQueries): void
protected CustomerRemoval $customerRemoval;
public function boot(CustomerQueries $customerQueries, CustomerRemoval $customerRemoval): void
{
$this->customerQueries = $customerQueries;
$this->customerRemoval = $customerRemoval;
}
public function mount(int $customer): void
@@ -77,6 +86,15 @@ new class extends Component
return $this->customer->personalIdentityCodeMasked;
}
/**
* Whether nothing is linked to this customer, so the remove button is shown.
*/
#[Computed]
public function canBeRemoved(): bool
{
return $this->customerRemoval->canRemove($this->customerId);
}
/**
* @return list<ContactSummary>
*/
@@ -96,13 +114,15 @@ new class extends Component
}
/**
* Opens the remove dialog for a contact or a billing unit of this customer.
* Opens the remove dialog for this customer, or for one of its contacts
* or billing units.
*/
public function confirmRemoval(string $type, int $id): void
{
$this->authorize('customers.use');
$name = match ($type) {
'customer' => $id === $this->customerId ? $this->customerQueries->findSummary($id)?->name : null,
'contact' => $this->customerQueries->findContact($this->customerId, $id)?->name,
'billing_unit' => $this->customerQueries->findBillingUnit($this->customerId, $id)?->name,
default => null,
@@ -122,7 +142,7 @@ new class extends Component
$this->js("document.getElementById('".self::REMOVE_DIALOG."').showModal()");
}
public function remove(RemoveContact $removeContact, RemoveBillingUnit $removeBillingUnit): void
public function remove(RemoveContact $removeContact, RemoveBillingUnit $removeBillingUnit, RemoveCustomer $removeCustomer): void
{
$this->authorize('customers.use');
@@ -130,6 +150,12 @@ new class extends Component
return;
}
if ($this->removalType === 'customer') {
$this->removeCustomer($removeCustomer);
return;
}
try {
match ($this->removalType) {
'contact' => $removeContact->execute($this->customerId, $this->removalId),
@@ -150,6 +176,32 @@ new class extends Component
$this->reset('removalType', 'removalId', 'removalName');
}
/**
* Removes this customer and returns to the customer list, or tells why
* it was kept and moves focus back to the page heading.
*/
private function removeCustomer(RemoveCustomer $removeCustomer): void
{
try {
$removeCustomer->execute($this->customerId);
session()->flash('status', __('customers.removal.removed_customer', ['name' => $this->removalName]));
$this->redirectRoute('customers.index', navigate: true);
return;
} catch (CustomerNotFound) {
$this->statusMessage = __('customers.removal.already_removed');
} catch (InternalCustomerCannotBeRemoved) {
$this->statusMessage = __('customers.removal.internal_customer');
} catch (CustomerInUse) {
$this->statusMessage = __('customers.removal.in_use_customer', ['name' => $this->removalName]);
}
$this->js("document.getElementById('".self::REMOVE_DIALOG."').close(); document.getElementById('customer-heading').focus()");
$this->reset('removalType', 'removalId', 'removalName');
}
public function render(): mixed
{
return $this->view()->title($this->customer->name);
@@ -160,16 +212,28 @@ new class extends Component
<div class="mx-auto max-w-5xl space-y-8 p-4 sm:p-6">
<div class="space-y-4">
<div class="flex flex-wrap items-center justify-between gap-4">
<h1 class="text-2xl font-semibold break-words">{{ $this->customer->name }}</h1>
<h1 id="customer-heading" tabindex="-1" class="text-2xl font-semibold break-words focus:outline-none">{{ $this->customer->name }}</h1>
<x-button
:href="route('customers.edit', $customerId)"
wire:navigate
subtle
color="black"
icon="pencil"
:text="__('customers.edit_details')"
/>
<div class="flex flex-wrap gap-2">
<x-button
:href="route('customers.edit', $customerId)"
wire:navigate
subtle
color="black"
icon="pencil"
:text="__('customers.edit_details')"
/>
@if ($this->canBeRemoved)
<x-button
wire:click="confirmRemoval('customer', {{ $customerId }})"
subtle
color="black"
icon="trash"
:text="__('customers.remove_customer')"
/>
@endif
</div>
</div>
@if (session('status'))