Add an editable menu name and reserve billing material numbers on creation
- Company details get an optional "Valikon nimi", shown at the left of the main menu; it falls back to the application name when empty. - A billing material gets its running number (billing_exports.number) only when it is created, so discarded drafts leave no gaps. Drafts have no number; existing created materials are numbered by the migration, and the CSV file name uses the number. - TaskAssigneeMigrationTest rolls back from its own migration onward instead of assuming it is the last one. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -16,6 +16,7 @@ final readonly class CompanyDetails
|
||||
public ?string $address = null,
|
||||
public ?string $phone = null,
|
||||
public ?string $email = null,
|
||||
public ?string $menuName = null,
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ final class CompanyDetailsStore
|
||||
'address' => 'shared.company_address',
|
||||
'phone' => 'shared.company_phone',
|
||||
'email' => 'shared.company_email',
|
||||
'menu_name' => 'shared.company_menu_name',
|
||||
];
|
||||
|
||||
public function __construct(private Settings $settings) {}
|
||||
@@ -47,6 +48,7 @@ final class CompanyDetailsStore
|
||||
$this->settings->get(self::KEYS['address']),
|
||||
$this->settings->get(self::KEYS['phone']),
|
||||
$this->settings->get(self::KEYS['email']),
|
||||
$this->settings->get(self::KEYS['menu_name']),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -72,6 +74,15 @@ final class CompanyDetailsStore
|
||||
$this->settings->put(self::KEYS['address'], self::text($details->address));
|
||||
$this->settings->put(self::KEYS['phone'], self::text($details->phone));
|
||||
$this->settings->put(self::KEYS['email'], $email);
|
||||
$this->settings->put(self::KEYS['menu_name'], self::text($details->menuName));
|
||||
}
|
||||
|
||||
/**
|
||||
* The name shown at the left of the main menu: the saved one, or the application name.
|
||||
*/
|
||||
public function menuName(): string
|
||||
{
|
||||
return $this->settings->get(self::KEYS['menu_name']) ?? (string) config('app.name');
|
||||
}
|
||||
|
||||
private static function text(?string $value): ?string
|
||||
|
||||
@@ -16,6 +16,8 @@ new class extends Component
|
||||
{
|
||||
public string $name = '';
|
||||
|
||||
public string $menu_name = '';
|
||||
|
||||
public string $business_id = '';
|
||||
|
||||
public string $address = '';
|
||||
@@ -35,6 +37,7 @@ new class extends Component
|
||||
|
||||
if ($details !== null) {
|
||||
$this->name = $details->name;
|
||||
$this->menu_name = $details->menuName ?? '';
|
||||
$this->business_id = $details->businessId;
|
||||
$this->address = $details->address ?? '';
|
||||
$this->phone = $details->phone ?? '';
|
||||
@@ -49,6 +52,7 @@ new class extends Component
|
||||
|
||||
$this->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'menu_name' => ['nullable', 'string', 'max:100'],
|
||||
'business_id' => ['required', 'string', 'max:20'],
|
||||
'address' => ['nullable', 'string', 'max:500'],
|
||||
'phone' => ['nullable', 'string', 'max:50'],
|
||||
@@ -56,6 +60,7 @@ new class extends Component
|
||||
], [
|
||||
'name.required' => __('company.errors.name'),
|
||||
'name.max' => __('company.errors.name'),
|
||||
'menu_name.max' => __('company.errors.menu_name'),
|
||||
'business_id.required' => __('company.errors.business_id'),
|
||||
'business_id.max' => __('company.errors.business_id'),
|
||||
'address.max' => __('company.errors.address'),
|
||||
@@ -64,7 +69,7 @@ new class extends Component
|
||||
]);
|
||||
|
||||
try {
|
||||
$store->save(new CompanyDetails($this->name, $this->business_id, $this->address, $this->phone, $this->email));
|
||||
$store->save(new CompanyDetails($this->name, $this->business_id, $this->address, $this->phone, $this->email, $this->menu_name));
|
||||
} catch (CompanyNameRequired) {
|
||||
$this->addError('name', __('company.errors.name'));
|
||||
|
||||
@@ -100,6 +105,7 @@ new class extends Component
|
||||
|
||||
<form wire:submit="save" class="space-y-6" novalidate>
|
||||
<x-input wire:model="name" :label="__('company.fields.name')" autocomplete="organization" required />
|
||||
<x-input wire:model="menu_name" :label="__('company.fields.menu_name')" :hint="__('company.fields.menu_name_hint')" autocomplete="off" />
|
||||
<x-input wire:model="business_id" :label="__('company.fields.business_id')" :hint="__('company.fields.business_id_hint')" autocomplete="off" required />
|
||||
<x-textarea wire:model="address" :label="__('company.fields.address')" :hint="__('company.fields.address_hint')" rows="3" autocomplete="street-address" />
|
||||
<x-input wire:model="phone" type="tel" :label="__('company.fields.phone')" autocomplete="tel" />
|
||||
|
||||
Reference in New Issue
Block a user