- 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]>
35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Modules\Catalog\Application\UseCases;
|
||
|
||
use App\Modules\Shared\Application\Contracts\Settings;
|
||
use App\Modules\Shared\Domain\Exceptions\InvalidVatPercentage;
|
||
use App\Modules\Shared\Domain\ValueObjects\VatPercentage;
|
||
|
||
/**
|
||
* Sets the markup suggested for new purchase expenses, e.g. "15" for 15 %;
|
||
* an empty value means no markup. Stored in hundredths of a percent.
|
||
*/
|
||
final class SetDefaultExpenseMarkup
|
||
{
|
||
public const string SETTING_KEY = 'catalog.expense_markup_basis_points';
|
||
|
||
public function __construct(private Settings $settings) {}
|
||
|
||
/**
|
||
* @return int The stored markup in hundredths of a percent.
|
||
*
|
||
* @throws InvalidVatPercentage When the value is not 0–100 % with at most two decimals.
|
||
*/
|
||
public function execute(string $markup): int
|
||
{
|
||
$basisPoints = trim($markup) === '' ? 0 : VatPercentage::parse($markup)->basisPoints;
|
||
|
||
$this->settings->put(self::SETTING_KEY, $basisPoints === 0 ? null : (string) $basisPoints);
|
||
|
||
return $basisPoints;
|
||
}
|
||
}
|