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:
2026-11-24 11:46:36 +02:00
co-authored by Claude Opus 5.5
parent d5cbf9d6eb
commit c149c56388
24 changed files with 284 additions and 15 deletions
@@ -18,6 +18,9 @@ use App\Modules\Jobs\Domain\Exceptions\InvalidTag;
use App\Modules\Jobs\Domain\Exceptions\PlanEndsBeforeStart;
use App\Modules\Jobs\Domain\Exceptions\ServiceUnitRequired;
use App\Modules\Shared\Domain\Exceptions\DomainException;
use App\Modules\Shared\Domain\Exceptions\InvalidMoneyAmount;
use App\Modules\Shared\Domain\ValueObjects\Money;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
use Livewire\Form;
@@ -54,6 +57,11 @@ class JobForm extends Form
public string $estimated_hours = '';
/**
* Only for users who may see quoted amounts; filled and sent only for them.
*/
public string $quoted_amount = '';
public string $customer_reference = '';
public string $instructions = '';
@@ -92,6 +100,7 @@ class JobForm extends Form
$this->priority = $job->priority->value;
$this->payment_basis = $job->paymentBasis->value ?? '';
$this->estimated_hours = $job->estimatedHours ?? '';
$this->quoted_amount = $job->quotedAmountCents === null || ! Gate::allows('money.quotes') ? '' : Money::fromCents($job->quotedAmountCents)->inputValue();
$this->customer_reference = $job->customerReference ?? '';
$this->instructions = $job->instructions ?? '';
$this->responsible_user_id = (string) $job->responsible->id;
@@ -135,6 +144,8 @@ class JobForm extends Form
memberUserIds: array_map('intval', $this->member_user_ids),
tags: $this->tags,
links: array_values(array_filter($this->links, fn (array $link): bool => trim($link['title']) !== '' || trim($link['url']) !== '')),
quotedAmount: $text($this->quoted_amount),
setsQuotedAmount: Gate::allows('money.quotes'),
);
}
@@ -149,6 +160,7 @@ class JobForm extends Form
$exception instanceof DueBeforeStart => ['due_on', 'jobs.errors.due_before_start'],
$exception instanceof PlanEndsBeforeStart => ['planned_to', 'jobs.errors.plan_ends_before_start'],
$exception instanceof InvalidEstimatedHours => ['estimated_hours', 'jobs.errors.invalid_hours'],
$exception instanceof InvalidMoneyAmount => ['quoted_amount', 'jobs.errors.invalid_amount'],
$exception instanceof InvalidTag => ['tags', 'jobs.errors.invalid_tag'],
$exception instanceof InvalidJobLink => ['links', 'jobs.errors.invalid_link'],
$exception instanceof InvalidJobReference => [self::referenceField($exception->field), 'jobs.errors.invalid_reference'],
@@ -188,6 +200,7 @@ class JobForm extends Form
'priority' => ['required', Rule::enum(Priority::class)],
'payment_basis' => ['nullable', Rule::enum(PaymentBasis::class)],
'estimated_hours' => ['nullable', 'numeric', 'min:0', 'max:99999'],
'quoted_amount' => ['nullable', 'string', 'max:20'],
'customer_reference' => ['nullable', 'string', 'max:255'],
'instructions' => ['nullable', 'string', 'max:10000'],
'responsible_user_id' => ['required', 'integer'],
@@ -226,6 +239,7 @@ class JobForm extends Form
'estimated_hours.numeric' => __('jobs.errors.invalid_hours'),
'estimated_hours.min' => __('jobs.errors.invalid_hours'),
'estimated_hours.max' => __('jobs.errors.invalid_hours'),
'quoted_amount.max' => __('jobs.errors.invalid_amount'),
'customer_reference.max' => __('jobs.errors.too_long', ['max' => 255]),
'instructions.max' => __('jobs.errors.too_long', ['max' => 10000]),
'responsible_user_id.required' => __('jobs.errors.responsible_required'),