Add the profitability report and the internal hourly cost
Profitability by job and service unit from a period's hours, expenses and the created billing materials of its months. Hours are costed at one internal hourly cost, set on the price list maintenance page; a job of several service units is shared evenly between them. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Modules\Catalog\Application\UseCases\MoveProduct;
|
||||
use App\Modules\Catalog\Application\UseCases\MoveVatRate;
|
||||
use App\Modules\Catalog\Application\UseCases\SetDefaultExpenseMarkup;
|
||||
use App\Modules\Catalog\Application\UseCases\SetHourlyRate;
|
||||
use App\Modules\Catalog\Application\UseCases\SetInternalHourlyCost;
|
||||
use App\Modules\Catalog\Application\UseCases\SetMileageRate;
|
||||
use App\Modules\Catalog\Application\UseCases\SetProductActive;
|
||||
use App\Modules\Catalog\Application\UseCases\SetVatRateActive;
|
||||
@@ -51,6 +52,8 @@ new class extends Component
|
||||
|
||||
public string $expenseMarkup = '';
|
||||
|
||||
public string $internalHourlyCost = '';
|
||||
|
||||
protected PriceListQueries $priceList;
|
||||
|
||||
public function boot(PriceListQueries $priceList): void
|
||||
@@ -63,6 +66,7 @@ new class extends Component
|
||||
$this->authorize('catalog.manage');
|
||||
|
||||
$this->mileageRate = $this->inputValue($this->priceList->mileageRateCents());
|
||||
$this->internalHourlyCost = $this->inputValue($this->priceList->internalHourlyCostCents());
|
||||
$markup = $this->priceList->defaultExpenseMarkupBasisPoints();
|
||||
$this->expenseMarkup = $markup === 0 ? '' : (new VatPercentage($markup))->inputValue();
|
||||
}
|
||||
@@ -223,6 +227,26 @@ new class extends Component
|
||||
: __('catalog.mileage.saved', ['rate' => $rate->format()]);
|
||||
}
|
||||
|
||||
public function saveInternalHourlyCost(SetInternalHourlyCost $setInternalHourlyCost): void
|
||||
{
|
||||
$this->authorize('catalog.manage');
|
||||
|
||||
$this->resetErrorBag('internalHourlyCost');
|
||||
|
||||
try {
|
||||
$cost = $setInternalHourlyCost->execute($this->internalHourlyCost);
|
||||
} catch (InvalidMoneyAmount) {
|
||||
$this->addError('internalHourlyCost', __('catalog.errors.invalid_price'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->internalHourlyCost = $cost?->inputValue() ?? '';
|
||||
$this->statusMessage = $cost === null
|
||||
? __('catalog.internal_cost.removed')
|
||||
: __('catalog.internal_cost.saved', ['cost' => $cost->format()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{index: string, label: string, sortable: bool, align?: string}>
|
||||
*/
|
||||
@@ -527,4 +551,21 @@ new class extends Component
|
||||
<x-button submit :text="__('catalog.save')" />
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="internal-cost-heading" class="space-y-4">
|
||||
<h2 id="internal-cost-heading" class="text-xl font-semibold">{{ __('catalog.internal_cost.section') }}</h2>
|
||||
|
||||
<form wire:submit="saveInternalHourlyCost" class="flex max-w-md flex-wrap items-end gap-3" novalidate>
|
||||
<div class="min-w-40 flex-1">
|
||||
<x-input
|
||||
wire:model="internalHourlyCost"
|
||||
:label="__('catalog.internal_cost.label')"
|
||||
:hint="__('catalog.internal_cost.help')"
|
||||
inputmode="decimal"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</div>
|
||||
<x-button submit :text="__('catalog.save')" />
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user