Files
Toiminnanohjaus/app/Modules/Jobs/Application/DTOs/CustomerJobDetails.php
T
petriandClaude Opus 5.5 5f9423a3c3 Add monthly fee billing lines to the billing material
Jobs billed by a fixed monthly fee get a monthly fee field, kept behind
the quotes permission like the quoted amount. A billing material now has
a billing month: a new draft adds every monthly fee job with something
to bill, each on an invoice of its own, and bills one line for every
unbilled month from the job's start up to the billing month (or its end
or completion), so skipped months are caught up and no month is billed
twice. Their expenses are billed alongside, their hours are covered by
the fee and marked billed, and the job keeps running.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 13:23:46 +02:00

65 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 ?int $monthlyFeeCents = 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);
}
}