- Dark indigo header and tinted page background; the mobile main menu gets its own row, in the same order as the keyboard reaches it. - Page titles with an icon chip (x-page-title, x-page, x-page-header) and card sections (x-panel, the card utility); x-table styled as a card with an indigo header row in AppServiceProvider::styleTables(). - Job and task statuses, late work, unapproved hours and stock states as badges with icon and text (x-status-badge, x-jobs.status, x-jobs.task-status), never colour alone. - Empty lists as x-empty-state; dashboard quick link tiles, week hour bars and trend arrows; Kanban columns and task cards edged by status; calendar today column and bar accents; quick sale, reports and machine console restyled; signed-out pages show the app name. - Focus rings use the primary colour in both themes (white in the header). - Document the components in CLAUDE.md; test the status badges. Co-Authored-By: Claude Opus 5.5 <[email protected]>
220 lines
12 KiB
PHP
220 lines
12 KiB
PHP
<?php
|
|
|
|
use App\Modules\Reports\Application\DTOs\SalesReport;
|
|
use App\Modules\Reports\Application\UseCases\QuickSalesReport;
|
|
use App\Modules\Reports\Presentation\Livewire\Concerns\ReportPage;
|
|
use App\Modules\Shared\Domain\ValueObjects\VatPercentage;
|
|
use App\Modules\Users\Application\Contracts\Clock;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* Quick sales in a period (spec 7, 13): by cash day, product, seller and
|
|
* VAT rate. They are counter sales apart from the billing material.
|
|
*/
|
|
new class extends Component
|
|
{
|
|
use ReportPage;
|
|
|
|
public function mount(Clock $clock): void
|
|
{
|
|
$this->startPeriod($clock);
|
|
}
|
|
|
|
#[Computed]
|
|
public function report(): ?SalesReport
|
|
{
|
|
$period = $this->period();
|
|
|
|
return $period === null ? null : app(QuickSalesReport::class)->execute($period);
|
|
}
|
|
|
|
public function updated(): void
|
|
{
|
|
$this->authorize('reports.view');
|
|
unset($this->report);
|
|
}
|
|
|
|
public function vatRate(int $basisPoints): string
|
|
{
|
|
return (new VatPercentage($basisPoints))->format();
|
|
}
|
|
|
|
public function seriesLabel(string $key): string
|
|
{
|
|
return strlen($key) === 7
|
|
? ((int) substr($key, 5, 2)).'/'.substr($key, 0, 4)
|
|
: $this->dateLabel($key);
|
|
}
|
|
|
|
public function render(): mixed
|
|
{
|
|
return $this->view()->title(__('reports.sales.title'));
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div class="mx-auto max-w-6xl space-y-6 p-4 sm:p-6">
|
|
<x-page-title icon="shopping-cart">{{ __('reports.sales.title') }}</x-page-title>
|
|
|
|
<x-reports.period-filter :presets="$this->periodPresets()" :valid="$this->period !== null" />
|
|
|
|
@php($report = $this->report)
|
|
|
|
@if ($report !== null)
|
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
<h2 class="text-xl font-semibold"><span role="status" aria-live="polite">{{ $this->periodLabel() }}</span></h2>
|
|
<x-button :href="$this->csvUrl('sales')" subtle color="black" icon="arrow-down-tray" :text="__('reports.download_csv')" />
|
|
</div>
|
|
|
|
@if ($report->days === [])
|
|
<x-empty-state icon="chart-bar">{{ __('reports.sales.none') }}</x-empty-state>
|
|
@else
|
|
@if ($report->openDays > 0)
|
|
<p class="flex items-start gap-2 text-sm">
|
|
<x-icon name="exclamation-triangle" class="size-5 shrink-0" aria-hidden="true" />
|
|
{{ trans_choice('reports.sales.open_days', $report->openDays, ['count' => $report->openDays]) }}
|
|
</p>
|
|
@endif
|
|
|
|
<div class="grid gap-6 md:grid-cols-2">
|
|
<table class="w-full text-sm">
|
|
<caption class="mb-2 text-left text-base font-semibold">{{ __('reports.sales.totals') }}</caption>
|
|
<thead class="sr-only">
|
|
<tr>
|
|
<th scope="col">{{ __('reports.sales.item') }}</th>
|
|
<th scope="col">{{ __('reports.sales.amount') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
|
|
<tr>
|
|
<th scope="row" class="py-1 text-left font-normal">{{ __('reports.sales.count') }}</th>
|
|
<td class="py-1 text-right">{{ $report->count }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" class="py-1 text-left font-normal">{{ __('reports.sales.cash') }}</th>
|
|
<td class="py-1 text-right whitespace-nowrap">{{ $this->money($report->cashCents) }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" class="py-1 text-left font-normal">{{ __('reports.sales.card') }}</th>
|
|
<td class="py-1 text-right whitespace-nowrap">{{ $this->money($report->cardCents) }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th scope="row" class="py-1 text-left font-semibold">{{ __('reports.sales.total') }}</th>
|
|
<td class="py-1 text-right font-semibold whitespace-nowrap">{{ $this->money($report->totalCents()) }}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<table class="w-full text-sm">
|
|
<caption class="mb-2 text-left text-base font-semibold">{{ __('reports.sales.by_vat') }}</caption>
|
|
<thead>
|
|
<tr class="text-left">
|
|
<th scope="col" class="py-1">{{ __('reports.sales.vat_rate') }}</th>
|
|
<th scope="col" class="py-1 text-right">{{ __('reports.sales.gross') }}</th>
|
|
<th scope="col" class="py-1 text-right">{{ __('reports.sales.net') }}</th>
|
|
<th scope="col" class="py-1 text-right">{{ __('reports.sales.vat') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
|
|
@foreach ($report->vatTotals as $vat)
|
|
<tr wire:key="vat-{{ $vat['vatBasisPoints'] }}">
|
|
<th scope="row" class="py-1 text-left font-normal">{{ $this->vatRate($vat['vatBasisPoints']) }}</th>
|
|
<td class="py-1 text-right whitespace-nowrap">{{ $this->money($vat['grossCents']) }}</td>
|
|
<td class="py-1 text-right whitespace-nowrap">{{ $this->money($vat['netCents']) }}</td>
|
|
<td class="py-1 text-right whitespace-nowrap">{{ $this->money($vat['vatCents']) }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<x-reports.chart
|
|
:title="__($report->seriesByMonth ? 'reports.sales.chart_months' : 'reports.sales.chart_days')"
|
|
:summary="implode(', ', array_map(fn ($key, $cents) => $this->seriesLabel($key).' '.$this->money($cents), array_keys($report->series), $report->series))"
|
|
:labels="array_map(fn ($key) => $this->seriesLabel((string) $key), array_keys($report->series))"
|
|
:values="array_map(fn ($cents) => $cents / 100, array_values($report->series))"
|
|
:formatter="fn (float $value) => number_format($value, 0, ',', ' ').' €'"
|
|
/>
|
|
|
|
<div class="grid gap-6 md:grid-cols-2">
|
|
<table class="w-full text-sm">
|
|
<caption class="mb-2 text-left text-base font-semibold">{{ __('reports.sales.by_product') }}</caption>
|
|
<thead>
|
|
<tr class="text-left">
|
|
<th scope="col" class="py-1">{{ __('reports.sales.product') }}</th>
|
|
<th scope="col" class="py-1 text-right">{{ __('reports.sales.quantity') }}</th>
|
|
<th scope="col" class="py-1 text-right">{{ __('reports.sales.gross') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
|
|
@foreach ($report->products as $product)
|
|
<tr>
|
|
<th scope="row" class="py-1 text-left font-normal">{{ $product['name'] }}</th>
|
|
<td class="py-1 text-right">{{ $product['quantity'] }}</td>
|
|
<td class="py-1 text-right whitespace-nowrap">{{ $this->money($product['grossCents']) }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
|
|
<table class="w-full text-sm">
|
|
<caption class="mb-2 text-left text-base font-semibold">{{ __('reports.sales.by_seller') }}</caption>
|
|
<thead>
|
|
<tr class="text-left">
|
|
<th scope="col" class="py-1">{{ __('reports.sales.seller') }}</th>
|
|
<th scope="col" class="py-1 text-right">{{ __('reports.sales.count') }}</th>
|
|
<th scope="col" class="py-1 text-right">{{ __('reports.sales.gross') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
|
|
@foreach ($report->sellers as $seller)
|
|
<tr>
|
|
<th scope="row" class="py-1 text-left font-normal">{{ $seller['name'] }}</th>
|
|
<td class="py-1 text-right">{{ $seller['count'] }}</td>
|
|
<td class="py-1 text-right whitespace-nowrap">{{ $this->money($seller['grossCents']) }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="card overflow-x-auto focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-600" tabindex="0" role="region" aria-label="{{ __('reports.sales.by_day') }}">
|
|
<table class="w-full text-sm">
|
|
<caption class="mb-2 text-left text-base font-semibold">{{ __('reports.sales.by_day') }}</caption>
|
|
<thead>
|
|
<tr class="border-b-2 border-primary-200 text-left text-primary-900 dark:border-primary-800 dark:text-primary-100">
|
|
<th scope="col" class="py-2 pr-3">{{ __('reports.sales.day') }}</th>
|
|
<th scope="col" class="py-2 pr-3 text-right">{{ __('reports.sales.count') }}</th>
|
|
<th scope="col" class="py-2 pr-3 text-right">{{ __('reports.sales.cash') }}</th>
|
|
<th scope="col" class="py-2 pr-3 text-right">{{ __('reports.sales.card') }}</th>
|
|
<th scope="col" class="py-2 pr-3 text-right">{{ __('reports.sales.total') }}</th>
|
|
<th scope="col" class="py-2">{{ __('reports.sales.cash_day') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-zinc-200 dark:divide-zinc-700">
|
|
@foreach ($report->days as $day)
|
|
<tr wire:key="day-{{ $day['day'] }}">
|
|
<th scope="row" class="py-2 pr-3 text-left font-normal">
|
|
<x-link :href="route('sales.index', ['paiva' => $day['day']])" navigate>{{ $this->dateLabel($day['day']) }}</x-link>
|
|
</th>
|
|
<td class="py-2 pr-3 text-right">{{ $day['count'] }}</td>
|
|
<td class="py-2 pr-3 text-right whitespace-nowrap">{{ $this->money($day['cashCents']) }}</td>
|
|
<td class="py-2 pr-3 text-right whitespace-nowrap">{{ $this->money($day['cardCents']) }}</td>
|
|
<td class="py-2 pr-3 text-right whitespace-nowrap">{{ $this->money($day['totalCents']) }}</td>
|
|
<td class="py-2">
|
|
@if ($day['isClosed'])
|
|
<span class="inline-flex items-center gap-1"><x-icon name="lock-closed" class="size-4" aria-hidden="true" />{{ __('reports.sales.closed') }}</span>
|
|
@else
|
|
<span class="inline-flex items-center gap-1"><x-icon name="exclamation-triangle" class="size-4" aria-hidden="true" />{{ __('reports.sales.open') }}</span>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
@endif
|
|
@endif
|
|
</div>
|