Add the price list: hourly rates, products and mileage rate

- Work types get an hourly rate (VAT 0), set on the work type form or in
  the hourly rate grid of the new Hinnasto page (/catalog/prices), which
  saves a cell when focus leaves it.
- Fixed-price products with a unit from a list, consumer product flag and
  automatic hours, which need a work type. Products are moved and
  deactivated, never deleted.
- The mileage rate is stored in a new settings table through the shared
  Settings contract.
- Shared Money value object keeps amounts in cents, parses "85,50" and
  formats "85,50 €".
- Prices are read only through PriceListQueries, not CatalogQueries, so
  personal money permissions can be added in one place next.
- Only admins and management can open the pages for now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 07:30:49 +02:00
co-authored by Claude Opus 5.5
parent 1acdaa5b19
commit dc2612cf46
58 changed files with 2577 additions and 32 deletions
@@ -0,0 +1,57 @@
<?php
namespace App\Modules\Catalog\Infrastructure\Persistence\Eloquent;
use Database\Factories\ProductFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Attributes\UseFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* Persistence model, used only inside the Catalog Infrastructure layer.
*
* @property int $id
* @property string $name
* @property string $unit
* @property int $price_cents
* @property bool $is_consumer_product
* @property string $auto_hours
* @property int|null $work_type_id
* @property bool $is_active
* @property int $sort_order
* @property-read WorkTypeModel|null $workType
*/
#[Table('products')]
#[Fillable(['name', 'unit', 'price_cents', 'is_consumer_product', 'auto_hours', 'work_type_id', 'is_active', 'sort_order'])]
#[UseFactory(ProductFactory::class)]
class ProductModel extends Model
{
/** @use HasFactory<ProductFactory> */
use HasFactory;
/**
* @return BelongsTo<WorkTypeModel, $this>
*/
public function workType(): BelongsTo
{
return $this->belongsTo(WorkTypeModel::class, 'work_type_id');
}
/**
* @return array<string, string>
*/
protected function casts(): array
{
return [
'price_cents' => 'integer',
'is_consumer_product' => 'boolean',
'auto_hours' => 'decimal:2',
'work_type_id' => 'integer',
'is_active' => 'boolean',
'sort_order' => 'integer',
];
}
}
@@ -16,11 +16,12 @@ use Illuminate\Database\Eloquent\Model;
* @property int $service_unit_id
* @property int|null $service_id
* @property string $name
* @property int|null $hourly_rate_cents
* @property bool $is_active
* @property int $sort_order
*/
#[Table('work_types')]
#[Fillable(['service_unit_id', 'service_id', 'name', 'is_active', 'sort_order'])]
#[Fillable(['service_unit_id', 'service_id', 'name', 'hourly_rate_cents', 'is_active', 'sort_order'])]
#[UseFactory(WorkTypeFactory::class)]
class WorkTypeModel extends Model
{
@@ -35,6 +36,7 @@ class WorkTypeModel extends Model
return [
'service_unit_id' => 'integer',
'service_id' => 'integer',
'hourly_rate_cents' => 'integer',
'is_active' => 'boolean',
'sort_order' => 'integer',
];