Add the quoted amount and completion time to customer jobs
- 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]>
This commit is contained in:
@@ -15,6 +15,7 @@ use App\Modules\Jobs\Domain\Exceptions\TaskNotFound;
|
||||
use App\Modules\Users\Application\Contracts\UserAccountQueries;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use App\Modules\Shared\Domain\ValueObjects\Money;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Attributes\Locked;
|
||||
use Livewire\Component;
|
||||
@@ -61,7 +62,12 @@ new class extends Component
|
||||
#[Computed]
|
||||
public function changes(): array
|
||||
{
|
||||
return app(CustomerJobQueries::class)->changes($this->jobId);
|
||||
$changes = app(CustomerJobQueries::class)->changes($this->jobId);
|
||||
|
||||
// Changes of the quoted amount are shown only to those who may see quotes (spec 5.7).
|
||||
return Gate::allows('money.quotes')
|
||||
? $changes
|
||||
: array_values(array_filter($changes, fn (JobChangeEntry $change): bool => $change->field !== 'quoted_amount'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,6 +171,7 @@ new class extends Component
|
||||
|
||||
return match ($field) {
|
||||
'starts_on', 'due_on', 'planned_from', 'planned_to' => $this->formatDate($value),
|
||||
'quoted_amount' => Money::fromCents((int) $value)->format(),
|
||||
'kind' => __('jobs.kinds.'.$value),
|
||||
'status' => __('jobs.statuses.'.$value),
|
||||
'priority' => __('jobs.priorities.'.$value),
|
||||
@@ -235,12 +242,22 @@ new class extends Component
|
||||
<dt class="font-medium">{{ __('jobs.fields.estimated_hours') }}</dt>
|
||||
<dd>{{ $job->estimatedHours === null ? __('jobs.not_set') : str_replace('.', ',', $job->estimatedHours).' h' }}</dd>
|
||||
|
||||
@can('money.quotes')
|
||||
<dt class="font-medium">{{ __('jobs.fields.quoted_amount') }}</dt>
|
||||
<dd>{{ $job->quotedAmountCents === null ? __('jobs.not_set') : Money::fromCents($job->quotedAmountCents)->format().' '.__('jobs.vat_excluded') }}</dd>
|
||||
@endcan
|
||||
|
||||
<dt class="font-medium">{{ __('jobs.fields.customer_reference') }}</dt>
|
||||
<dd class="break-words">{{ $job->customerReference ?? __('jobs.not_set') }}</dd>
|
||||
|
||||
<dt class="font-medium">{{ __('jobs.fields.tags') }}</dt>
|
||||
<dd>{{ $job->tags === [] ? __('jobs.tags.none') : implode(', ', $job->tags) }}</dd>
|
||||
|
||||
@if ($job->completedAt !== null)
|
||||
<dt class="font-medium">{{ __('jobs.fields.completed_at') }}</dt>
|
||||
<dd>{{ CarbonImmutable::parse($job->completedAt)->format('j.n.Y H.i') }}</dd>
|
||||
@endif
|
||||
|
||||
<dt class="font-medium">{{ __('jobs.fields.created_at') }}</dt>
|
||||
<dd>{{ CarbonImmutable::parse($job->createdAt)->format('j.n.Y H.i') }}, {{ $job->createdByName }}</dd>
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user