Add expenses on customer jobs
- 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]>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Modules\Expenses\Application\Contracts\ExpenseJobs;
|
||||
use App\Modules\Expenses\Application\DTOs\ExpenseJob;
|
||||
|
||||
class FakeExpenseJobs implements ExpenseJobs
|
||||
{
|
||||
/** @var array<int, ExpenseJob> */
|
||||
public array $jobs = [];
|
||||
|
||||
public function add(int $id, bool $locked = false): void
|
||||
{
|
||||
$this->jobs[$id] = new ExpenseJob($id, '2026-'.str_pad((string) $id, 4, '0', STR_PAD_LEFT), 'Työ '.$id, $locked);
|
||||
}
|
||||
|
||||
public function find(int $jobId): ?ExpenseJob
|
||||
{
|
||||
return $this->jobs[$jobId] ?? null;
|
||||
}
|
||||
|
||||
public function findMany(array $jobIds): array
|
||||
{
|
||||
return array_intersect_key($this->jobs, array_flip($jobIds));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Modules\Expenses\Application\Contracts\ExpensePricing;
|
||||
|
||||
class FakeExpensePricing implements ExpensePricing
|
||||
{
|
||||
public function __construct(
|
||||
public ?int $mileageRateCents = 59,
|
||||
public int $defaultMarkupBasisPoints = 0,
|
||||
) {}
|
||||
|
||||
public function mileageRateCents(): ?int
|
||||
{
|
||||
return $this->mileageRateCents;
|
||||
}
|
||||
|
||||
public function defaultMarkupBasisPoints(): int
|
||||
{
|
||||
return $this->defaultMarkupBasisPoints;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Fakes;
|
||||
|
||||
use App\Modules\Expenses\Domain\Contracts\ExpenseRepository;
|
||||
use App\Modules\Expenses\Domain\Entities\Expense;
|
||||
|
||||
class InMemoryExpenseRepository implements ExpenseRepository
|
||||
{
|
||||
/** @var array<int, Expense> */
|
||||
public array $items = [];
|
||||
|
||||
private int $nextId = 1;
|
||||
|
||||
public function findById(int $id): ?Expense
|
||||
{
|
||||
return isset($this->items[$id]) ? clone $this->items[$id] : null;
|
||||
}
|
||||
|
||||
public function save(Expense $expense): Expense
|
||||
{
|
||||
$id = $expense->id() ?? $this->nextId++;
|
||||
$this->items[$id] = Expense::reconstitute($id, $expense->jobId(), $expense->userId(), $expense->recordedBy(), $expense->details());
|
||||
|
||||
return clone $this->items[$id];
|
||||
}
|
||||
|
||||
public function delete(Expense $expense): void
|
||||
{
|
||||
unset($this->items[$expense->id()]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user