- Jobs get a budget / quoted amount (cents, VAT 0). Only users who may see quotes see and edit it on the job form and page, and only they see its changes in the history. Others' saves keep the stored amount: the server decides whether the amount is set, not the browser. - Jobs record when they were done: set when a job first reaches a status that locks its hours, kept through the billing statuses, cleared when management opens the lock. The billing export will use it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Jobs\Application\DTOs;
|
|
|
|
use App\Modules\Jobs\Domain\Enums\JobKind;
|
|
use App\Modules\Jobs\Domain\Enums\JobStatus;
|
|
use App\Modules\Jobs\Domain\Enums\PaymentBasis;
|
|
use App\Modules\Jobs\Domain\Enums\Priority;
|
|
|
|
/**
|
|
* Everything the job page and the edit form show, with names resolved.
|
|
*/
|
|
final readonly class CustomerJobDetails
|
|
{
|
|
/**
|
|
* @param list<NamedId> $serviceUnits
|
|
* @param list<NamedId> $members
|
|
* @param list<string> $tags
|
|
* @param list<array{title: string, url: string}> $links
|
|
*/
|
|
public function __construct(
|
|
public int $id,
|
|
public string $number,
|
|
public string $name,
|
|
public ?string $description,
|
|
public NamedId $customer,
|
|
public array $serviceUnits,
|
|
public ?string $startsOn,
|
|
public ?string $dueOn,
|
|
public ?string $plannedFrom,
|
|
public ?string $plannedTo,
|
|
public JobKind $kind,
|
|
public JobStatus $status,
|
|
public Priority $priority,
|
|
public ?PaymentBasis $paymentBasis,
|
|
public ?string $estimatedHours,
|
|
public ?string $customerReference,
|
|
public ?string $instructions,
|
|
public NamedId $responsible,
|
|
public ?NamedId $contactUser,
|
|
public ?NamedId $customerContact,
|
|
public ?NamedId $biller,
|
|
public ?NamedId $billingUnit,
|
|
public array $members,
|
|
public array $tags,
|
|
public array $links,
|
|
public string $createdAt,
|
|
public string $createdByName,
|
|
public ?int $quotedAmountCents = null,
|
|
public ?string $completedAt = null,
|
|
) {}
|
|
|
|
/**
|
|
* Whether the user is a named member of the job in any role.
|
|
*/
|
|
public function involves(int $userId): bool
|
|
{
|
|
return in_array($userId, [$this->responsible->id, $this->contactUser?->id, $this->biller?->id], true)
|
|
|| in_array($userId, array_map(fn (NamedId $member): int => $member->id, $this->members), true);
|
|
}
|
|
}
|