- 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]>
87 lines
3.2 KiB
PHP
87 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Jobs\Infrastructure\Persistence\Eloquent;
|
|
|
|
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;
|
|
use Carbon\CarbonImmutable;
|
|
use Database\Factories\CustomerJobFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\Table;
|
|
use Illuminate\Database\Eloquent\Attributes\UseFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Persistence model of a customer job, used only inside the Jobs
|
|
* Infrastructure layer. Service units, members, tags and links are in
|
|
* their own tables, read and written by the repository.
|
|
*
|
|
* @property int $id
|
|
* @property string $number
|
|
* @property string $name
|
|
* @property string|null $description
|
|
* @property int $customer_id
|
|
* @property CarbonImmutable|null $starts_on
|
|
* @property CarbonImmutable|null $due_on
|
|
* @property CarbonImmutable|null $planned_from
|
|
* @property CarbonImmutable|null $planned_to
|
|
* @property JobKind $kind
|
|
* @property JobStatus $status
|
|
* @property Priority $priority
|
|
* @property PaymentBasis|null $payment_basis
|
|
* @property string|null $estimated_hours
|
|
* @property string|null $customer_reference
|
|
* @property string|null $instructions
|
|
* @property int $responsible_user_id
|
|
* @property int|null $contact_user_id
|
|
* @property int|null $customer_contact_id
|
|
* @property int|null $biller_user_id
|
|
* @property int|null $billing_unit_id
|
|
* @property int $created_by
|
|
* @property int|null $quoted_amount_cents
|
|
* @property CarbonImmutable|null $completed_at
|
|
* @property CarbonImmutable $created_at
|
|
*/
|
|
#[Table('customer_jobs')]
|
|
#[Fillable([
|
|
'number', 'name', 'description', 'customer_id', 'starts_on', 'due_on', 'planned_from', 'planned_to',
|
|
'kind', 'status', 'priority', 'payment_basis', 'estimated_hours', 'quoted_amount_cents', 'customer_reference', 'instructions',
|
|
'responsible_user_id', 'contact_user_id', 'customer_contact_id', 'biller_user_id', 'billing_unit_id', 'created_by', 'completed_at',
|
|
])]
|
|
#[UseFactory(CustomerJobFactory::class)]
|
|
class CustomerJobModel extends Model
|
|
{
|
|
/** @use HasFactory<CustomerJobFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'customer_id' => 'integer',
|
|
'quoted_amount_cents' => 'integer',
|
|
'completed_at' => 'immutable_datetime',
|
|
'starts_on' => 'immutable_date',
|
|
'due_on' => 'immutable_date',
|
|
'planned_from' => 'immutable_date',
|
|
'planned_to' => 'immutable_date',
|
|
'kind' => JobKind::class,
|
|
'status' => JobStatus::class,
|
|
'priority' => Priority::class,
|
|
'payment_basis' => PaymentBasis::class,
|
|
'responsible_user_id' => 'integer',
|
|
'contact_user_id' => 'integer',
|
|
'customer_contact_id' => 'integer',
|
|
'biller_user_id' => 'integer',
|
|
'billing_unit_id' => 'integer',
|
|
'created_by' => 'integer',
|
|
'created_at' => 'immutable_datetime',
|
|
];
|
|
}
|
|
}
|