Files
petriandClaude Opus 5.5 f4b58f6b1d Darken the dark canvas, add customer colours, the ongoing status and the board model
- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 /
  primary-100 and TallStackUI's dark labels, hints and checkbox labels are
  lightened so everything stays at 4.5:1.
- Shared HexColor picks white or black text by the higher WCAG contrast; a
  native-dialog colour picker and a large work dialog component.
- Customers get a header colour (customers.header_color), set on the
  customer page.
- New job status Jatkuvat / Kausi (ongoing): open, never late, billed
  monthly like running jobs.
- Kanban model: board columns and views, urgent threshold, per-user board
  preferences (density, column colours and sort), card positions, tasks of
  continuing jobs pinned to the board, MoveBoardCard and board queries with
  logged hours from TimeTracking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 06:11:49 +02:00

139 lines
4.8 KiB
PHP

<?php
use App\Modules\Catalog\Application\Contracts\PriceListQueries;
use App\Modules\Catalog\Application\UseCases\AddVatRate;
use App\Modules\Catalog\Application\UseCases\UpdateVatRate;
use App\Modules\Catalog\Domain\Exceptions\InvalidCatalogName;
use App\Modules\Catalog\Domain\Exceptions\VatRateNameTaken;
use App\Modules\Catalog\Domain\Exceptions\VatRateNotFound;
use App\Modules\Shared\Domain\Exceptions\InvalidVatPercentage;
use App\Modules\Shared\Domain\ValueObjects\VatPercentage;
use Livewire\Attributes\Locked;
use Livewire\Component;
/**
* Add page (no {vatRate}) and edit page (with {vatRate}) of a VAT rate.
*/
new class extends Component
{
#[Locked]
public ?int $vatRateId = null;
/**
* Whether the edited rate already is the default, which can only be moved to another rate.
*/
#[Locked]
public bool $isDefault = false;
public string $name = '';
public string $percentage = '';
public bool $makeDefault = false;
public function mount(PriceListQueries $priceList, ?int $vatRate = null): void
{
$this->authorize('catalog.manage');
if ($vatRate === null) {
return;
}
$summary = $priceList->findVatRate($vatRate);
abort_if($summary === null, 404);
$this->vatRateId = $summary->id;
$this->isDefault = $summary->isDefault;
$this->name = $summary->name;
$this->percentage = (new VatPercentage($summary->basisPoints))->inputValue();
}
public function save(AddVatRate $addVatRate, UpdateVatRate $updateVatRate): void
{
$this->authorize('catalog.manage');
$this->validate(
['name' => ['required', 'string', 'max:100'], 'percentage' => ['required', 'string', 'max:10'], 'makeDefault' => ['boolean']],
[
'name.required' => __('catalog.errors.name_required'),
'name.max' => __('catalog.errors.invalid_name'),
'percentage.required' => __('catalog.errors.vat_percentage_required'),
'percentage.max' => __('catalog.errors.invalid_vat_percentage'),
],
);
try {
if ($this->vatRateId === null) {
$addVatRate->execute($this->name, $this->percentage, $this->makeDefault);
session()->flash('status', __('catalog.status.created', ['name' => trim($this->name)]));
} else {
$updateVatRate->execute($this->vatRateId, $this->name, $this->percentage, $this->makeDefault);
session()->flash('status', __('catalog.status.updated', ['name' => trim($this->name)]));
}
} catch (VatRateNotFound) {
abort(404);
} catch (InvalidCatalogName) {
$this->addError('name', __('catalog.errors.invalid_name'));
return;
} catch (VatRateNameTaken) {
$this->addError('name', __('catalog.errors.vat_rate_name_taken'));
return;
} catch (InvalidVatPercentage) {
$this->addError('percentage', __('catalog.errors.invalid_vat_percentage'));
return;
}
$this->redirectRoute('catalog.prices', navigate: true);
}
public function heading(): string
{
return __($this->vatRateId === null ? 'catalog.vat_rates.create_title' : 'catalog.vat_rates.edit_title');
}
public function render(): mixed
{
return $this->view()->title($this->heading());
}
};
?>
<div class="mx-auto max-w-2xl space-y-6 p-4 sm:p-6">
<x-page-title icon="receipt-percent">{{ $this->heading() }}</x-page-title>
@if ($vatRateId !== null)
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('catalog.vat_rates.change_help') }}</p>
@endif
<form wire:submit="save" class="card space-y-6" novalidate>
<x-input wire:model="name" :label="__('catalog.fields.name')" :hint="__('catalog.vat_rates.name_help')" autocomplete="off" required />
<x-input
wire:model="percentage"
:label="__('catalog.vat_rates.percentage')"
:hint="__('catalog.vat_rates.percentage_help')"
inputmode="decimal"
autocomplete="off"
required
/>
@if ($isDefault)
<p class="text-sm">{{ __('catalog.vat_rates.is_default_help') }}</p>
@else
<div class="space-y-1">
<x-checkbox id="vat-rate-default" wire:model="makeDefault" :label="__('catalog.vat_rates.make_default')" />
<p class="text-sm text-zinc-600 dark:text-zinc-200">{{ __('catalog.vat_rates.make_default_help') }}</p>
</div>
@endif
<div class="flex flex-wrap gap-3">
<x-button submit :text="__('catalog.save')" />
<x-button :href="route('catalog.prices')" wire:navigate subtle color="black" :text="__('catalog.cancel')" />
</div>
</form>
</div>