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]>
121 lines
5.3 KiB
PHP
121 lines
5.3 KiB
PHP
{{--
|
|
PDF receipt of a quick sale, rendered by dompdf (no Tailwind or
|
|
JavaScript; DejaVu Sans has the € sign and Finnish letters). Amounts of
|
|
a credit are negative.
|
|
--}}
|
|
@use('App\Modules\Shared\Domain\ValueObjects\Money')
|
|
@use('App\Modules\Shared\Domain\ValueObjects\VatPercentage')
|
|
@use('Carbon\CarbonImmutable')
|
|
@php
|
|
$money = fn (int $cents): string => ($cents < 0 ? '-' : '').Money::fromCents(abs($cents))->format();
|
|
$title = $sale->isCredit() ? __('sales.receipt.credit_title') : __('sales.receipt.title');
|
|
@endphp
|
|
<!DOCTYPE html>
|
|
<html lang="fi">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>{{ $title }} {{ $sale->id }}</title>
|
|
<style>
|
|
@page { margin: 14mm 12mm; }
|
|
body { font-family: "DejaVu Sans", sans-serif; font-size: 9.5pt; color: #000; }
|
|
h1 { font-size: 14pt; margin: 0 0 2mm; }
|
|
h2 { font-size: 10.5pt; margin: 5mm 0 1.5mm; }
|
|
p { margin: 0 0 1mm; }
|
|
.company { margin-bottom: 5mm; }
|
|
.company .name { font-size: 12pt; font-weight: bold; }
|
|
table { width: 100%; border-collapse: collapse; }
|
|
th, td { padding: 1.2mm 1mm; vertical-align: top; }
|
|
thead th { border-bottom: 0.6pt solid #000; text-align: left; }
|
|
.num { text-align: right; white-space: nowrap; }
|
|
.meta th { text-align: left; font-weight: normal; width: 35%; }
|
|
.total td, .total th { border-top: 0.6pt solid #000; font-weight: bold; font-size: 11pt; }
|
|
.footer { margin-top: 8mm; text-align: center; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="company">
|
|
@if ($company !== null)
|
|
<p class="name">{{ $company->name }}</p>
|
|
@if ($company->address !== null)
|
|
<p>{!! nl2br(e($company->address)) !!}</p>
|
|
@endif
|
|
@if ($company->phone !== null)
|
|
<p>{{ $company->phone }}</p>
|
|
@endif
|
|
@if ($company->email !== null)
|
|
<p>{{ $company->email }}</p>
|
|
@endif
|
|
<p>{{ __('sales.receipt.business_id') }}: {{ $company->businessId }} {{ __('sales.receipt.vat_number') }}: {{ $company->vatNumber() }}</p>
|
|
@else
|
|
<p>{{ __('sales.receipt.company_missing') }}</p>
|
|
@endif
|
|
</div>
|
|
|
|
<h1>{{ $title }}</h1>
|
|
|
|
<table class="meta">
|
|
<tr><th scope="row">{{ __('sales.receipt.number') }}</th><td>{{ $sale->id }}</td></tr>
|
|
<tr><th scope="row">{{ __('sales.receipt.date') }}</th><td>{{ CarbonImmutable::createFromFormat('Y-m-d H:i', $sale->soldAt)->format('j.n.Y H.i') }}</td></tr>
|
|
<tr><th scope="row">{{ __('sales.receipt.seller') }}</th><td>{{ $sale->sellerName }}</td></tr>
|
|
@if ($sale->customerName !== null)
|
|
<tr><th scope="row">{{ __('sales.receipt.customer') }}</th><td>{{ $sale->customerName }}</td></tr>
|
|
@endif
|
|
<tr><th scope="row">{{ __('sales.receipt.payment_method') }}</th><td>{{ __('sales.payment_methods.'.$sale->paymentMethod->value) }}</td></tr>
|
|
@if ($sale->isCredit())
|
|
<tr><th scope="row"></th><td>{{ __('sales.receipt.credits', ['number' => $sale->creditsSaleId]) }}</td></tr>
|
|
@endif
|
|
</table>
|
|
|
|
<table style="margin-top: 5mm;">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">{{ __('sales.receipt.product') }}</th>
|
|
<th scope="col" class="num">{{ __('sales.receipt.quantity') }}</th>
|
|
<th scope="col" class="num">{{ __('sales.receipt.unit_price') }}</th>
|
|
<th scope="col" class="num">{{ __('sales.receipt.vat_rate') }}</th>
|
|
<th scope="col" class="num">{{ __('sales.receipt.line_total') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($sale->lines as $line)
|
|
<tr>
|
|
<td>{{ $line->productName }}</td>
|
|
<td class="num">{{ $line->quantity }}</td>
|
|
<td class="num">{{ $money($line->unitPriceCents) }}</td>
|
|
<td class="num">{{ (new VatPercentage($line->vatBasisPoints))->format() }}</td>
|
|
<td class="num">{{ $money($line->totalCents) }}</td>
|
|
</tr>
|
|
@endforeach
|
|
<tr class="total">
|
|
<th scope="row" colspan="4" style="text-align: left;">{{ __('sales.receipt.total') }}</th>
|
|
<td class="num">{{ $money($sale->totalCents) }}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<h2>{{ __('sales.receipt.vat_heading') }}</h2>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">{{ __('sales.receipt.vat_rate') }}</th>
|
|
<th scope="col" class="num">{{ __('sales.receipt.net') }}</th>
|
|
<th scope="col" class="num">{{ __('sales.receipt.vat') }}</th>
|
|
<th scope="col" class="num">{{ __('sales.receipt.gross') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($sale->vatTotals() as $vatTotal)
|
|
<tr>
|
|
<td>{{ (new VatPercentage($vatTotal->vatBasisPoints))->format() }}</td>
|
|
<td class="num">{{ $money($vatTotal->netCents) }}</td>
|
|
<td class="num">{{ $money($vatTotal->vatCents) }}</td>
|
|
<td class="num">{{ $money($vatTotal->grossCents) }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
|
|
<p class="footer">{{ __('sales.receipt.thanks') }}</p>
|
|
</body>
|
|
</html>
|