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]>
36 lines
973 B
PHP
36 lines
973 B
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\InvalidMoneyAmount;
|
|
use App\Modules\Shared\Domain\ValueObjects\Money;
|
|
|
|
/**
|
|
* Sets the company's internal cost of an hour of work (wages and
|
|
* overheads, VAT 0), one rate for everyone, which the profitability report
|
|
* charges for the hours worked. An empty value removes it.
|
|
*/
|
|
final class SetInternalHourlyCost
|
|
{
|
|
public const string SETTING_KEY = 'catalog.internal_hourly_cost_cents';
|
|
|
|
public function __construct(private Settings $settings) {}
|
|
|
|
/**
|
|
* @return Money|null The stored cost.
|
|
*
|
|
* @throws InvalidMoneyAmount
|
|
*/
|
|
public function execute(string $hourlyCost): ?Money
|
|
{
|
|
$cost = Money::parse($hourlyCost);
|
|
|
|
$this->settings->put(self::SETTING_KEY, $cost === null ? null : (string) $cost->cents);
|
|
|
|
return $cost;
|
|
}
|
|
}
|