Add quick sales with cash days, credits and PDF receipts

Quick sales (pikamyynti) of active consumer products at the counter, in a
new Sales module:

- Product buttons add one to the sale's list per press; quantities can be
  lowered, raised or removed. Payment by cash or card, optional customer.
- Product durations are booked as the seller's hours on the yearly
  "Pikamyynnit" job (internal customer, not billed) through Jobs'
  ProvideQuickSaleTask and TimeTracking's AddTaskHours. The sale stands
  even when the hours cannot be booked, and the seller is told.
- Sales are never deleted: a credit records the lines negated on today's
  cash day, once per sale, by the seller or management.
- Closing a cash day stores its balance by payment method and VAT rate and
  stops sales on it; only management reopens a day.
- A printable A5 PDF receipt (barryvdh/laravel-dompdf) with the company's
  details, business ID, VAT number, lines and VAT breakdown.

Company details are kept in the settings and edited by the admin only on
the new Yritystiedot page. BusinessId moves from Customers to Shared so
both use the same check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 12:33:46 +02:00
co-authored by Claude Opus 5.5
parent c149c56388
commit 6de5d9bef1
101 changed files with 4768 additions and 29 deletions
@@ -0,0 +1,110 @@
<?php
use App\Modules\Shared\Application\DTOs\CompanyDetails;
use App\Modules\Shared\Application\UseCases\CompanyDetailsStore;
use App\Modules\Shared\Domain\Exceptions\CompanyNameRequired;
use App\Modules\Shared\Domain\Exceptions\InvalidBusinessId;
use App\Modules\Shared\Domain\Exceptions\InvalidEmailAddress;
use Livewire\Attributes\Locked;
use Livewire\Component;
/**
* The company's own details (Yritystiedot) for receipts and other
* documents. Only admins change settings (spec 2).
*/
new class extends Component
{
public string $name = '';
public string $business_id = '';
public string $address = '';
public string $phone = '';
public string $email = '';
#[Locked]
public string $statusMessage = '';
public function mount(CompanyDetailsStore $store): void
{
$this->authorize('settings.manage');
$details = $store->get();
if ($details !== null) {
$this->name = $details->name;
$this->business_id = $details->businessId;
$this->address = $details->address ?? '';
$this->phone = $details->phone ?? '';
$this->email = $details->email ?? '';
}
}
public function save(CompanyDetailsStore $store): void
{
$this->authorize('settings.manage');
$this->statusMessage = '';
$this->validate([
'name' => ['required', 'string', 'max:255'],
'business_id' => ['required', 'string', 'max:20'],
'address' => ['nullable', 'string', 'max:500'],
'phone' => ['nullable', 'string', 'max:50'],
'email' => ['nullable', 'string', 'max:255'],
], [
'name.required' => __('company.errors.name'),
'name.max' => __('company.errors.name'),
'business_id.required' => __('company.errors.business_id'),
'business_id.max' => __('company.errors.business_id'),
'address.max' => __('company.errors.address'),
'phone.max' => __('company.errors.phone'),
'email.max' => __('company.errors.email'),
]);
try {
$store->save(new CompanyDetails($this->name, $this->business_id, $this->address, $this->phone, $this->email));
} catch (CompanyNameRequired) {
$this->addError('name', __('company.errors.name'));
return;
} catch (InvalidBusinessId) {
$this->addError('business_id', __('company.errors.business_id'));
return;
} catch (InvalidEmailAddress) {
$this->addError('email', __('company.errors.email'));
return;
}
$this->business_id = (string) $store->get()?->businessId;
$this->statusMessage = __('company.saved');
}
public function render(): mixed
{
return $this->view()->title(__('company.title'));
}
};
?>
<div class="mx-auto max-w-lg space-y-6 p-4 sm:p-6">
<div class="space-y-1">
<h1 class="text-2xl font-semibold">{{ __('company.title') }}</h1>
<p class="text-sm text-zinc-600 dark:text-zinc-300">{{ __('company.intro') }}</p>
</div>
<p role="status" aria-live="polite" class="text-sm font-medium">{{ $statusMessage }}</p>
<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="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" />
<x-input wire:model="email" type="email" :label="__('company.fields.email')" autocomplete="email" />
<x-button submit :text="__('company.save')" />
</form>
</div>