- New Expenses module: purchases (materials, other) with a description and cost, and mileage priced with the price list's mileage rate. - Who paid and whether the expense is billed are separate: an employee's own payments are reimbursed elsewhere. A billed expense has a markup and a billed amount, cost plus markup unless given. - A job's expenses page lists, adds, edits and removes them; amounts of others' expenses need the expenses permission, own ones always show. Done jobs lock their expenses. - The Kulut menu shows the user's own expenses by month. Management records subcontractors' expenses, which they see but cannot change. - The price list gets a default markup for new purchases. - Number fields that update a calculation now use wire:model.live.blur: in Livewire 4 plain .blur no longer sends the value to the server, which also fixes the product form's VAT calculation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
64 lines
1.4 KiB
PHP
64 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Expenses\Domain\Entities;
|
|
|
|
use App\Modules\Expenses\Domain\ValueObjects\ExpenseDetails;
|
|
|
|
/**
|
|
* An expense on a customer job: whose it is, who recorded it (management
|
|
* records subcontractors' expenses) and what it is.
|
|
*/
|
|
final class Expense
|
|
{
|
|
private function __construct(
|
|
private ?int $id,
|
|
private int $jobId,
|
|
private int $userId,
|
|
private int $recordedBy,
|
|
private ExpenseDetails $details,
|
|
) {}
|
|
|
|
public static function record(int $jobId, int $userId, int $recordedBy, ExpenseDetails $details): self
|
|
{
|
|
return new self(null, $jobId, $userId, $recordedBy, $details);
|
|
}
|
|
|
|
public static function reconstitute(int $id, int $jobId, int $userId, int $recordedBy, ExpenseDetails $details): self
|
|
{
|
|
return new self($id, $jobId, $userId, $recordedBy, $details);
|
|
}
|
|
|
|
public function change(int $userId, ExpenseDetails $details): void
|
|
{
|
|
$this->userId = $userId;
|
|
$this->details = $details;
|
|
}
|
|
|
|
public function id(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function jobId(): int
|
|
{
|
|
return $this->jobId;
|
|
}
|
|
|
|
public function userId(): int
|
|
{
|
|
return $this->userId;
|
|
}
|
|
|
|
public function recordedBy(): int
|
|
{
|
|
return $this->recordedBy;
|
|
}
|
|
|
|
public function details(): ExpenseDetails
|
|
{
|
|
return $this->details;
|
|
}
|
|
}
|