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:
@@ -33,6 +33,14 @@ interface CustomerJobQueries
|
||||
|
||||
public function findDetails(int $id): ?CustomerJobDetails;
|
||||
|
||||
/**
|
||||
* Summaries of the given jobs, keyed by id; unknown ids are left out.
|
||||
*
|
||||
* @param list<int> $ids
|
||||
* @return array<int, CustomerJobSummary>
|
||||
*/
|
||||
public function summariesByIds(array $ids): array;
|
||||
|
||||
/**
|
||||
* The job's history, newest first.
|
||||
*
|
||||
|
||||
+17
@@ -101,6 +101,23 @@ class EloquentCustomerJobQueries implements CustomerJobQueries
|
||||
);
|
||||
}
|
||||
|
||||
public function summariesByIds(array $ids): array
|
||||
{
|
||||
if ($ids === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$models = CustomerJobModel::query()->whereIn('id', $ids)->get();
|
||||
$toSummary = $this->summaryMapper($models);
|
||||
$summaries = [];
|
||||
|
||||
foreach ($models as $model) {
|
||||
$summaries[$model->id] = $toSummary($model);
|
||||
}
|
||||
|
||||
return $summaries;
|
||||
}
|
||||
|
||||
public function findDetails(int $id): ?CustomerJobDetails
|
||||
{
|
||||
$model = CustomerJobModel::query()->find($id);
|
||||
|
||||
@@ -405,6 +405,13 @@ new class extends Component
|
||||
</x-confirm-dialog>
|
||||
</section>
|
||||
|
||||
@can('expenses.record')
|
||||
<section aria-labelledby="expenses-heading" class="space-y-3">
|
||||
<h2 id="expenses-heading" class="text-xl font-semibold">{{ __('jobs.sections.expenses') }}</h2>
|
||||
<x-link :href="route('expenses.job', $job->id)" navigate>{{ __('expenses.job_page.link') }}</x-link>
|
||||
</section>
|
||||
@endcan
|
||||
|
||||
<section aria-labelledby="links-heading" class="space-y-3">
|
||||
<h2 id="links-heading" class="text-xl font-semibold">{{ __('jobs.sections.links') }}</h2>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user