@extends('layouts.app') @section('content')

{{ $vehicle->vehicle_brand }} {{ $vehicle->vehicle_model }}

Muokkaa @php $inventoryLabels = [ 'in_stock' => 'Varastossa', 'reserved' => 'Varattu', 'offered' => 'Tarjouksella', 'under_contract' => 'Sopimuksella', 'invoiced' => 'Laskutettu', 'delivered' => 'Toimitettu', ]; $conditionLabels = [ 'new' => 'Uusi', 'used' => 'Käytetty', ]; $vehicleTypeLabels = [ 'esteeton_taksi' => 'Esteetön taksi', 'monitoimibussi' => 'Monitoimibussi', 'turistibussi' => 'Turistibussi', 'henkiloauto' => 'Henkilöauto', 'pakettiauto' => 'Pakettiauto', 'matkailuauto' => 'Matkailuauto', 'muu' => 'Muu', ]; $invoiceStatusLabels = [ 'not_created' => 'Ei luotu', 'created' => 'Luotu', 'sent' => 'Lähetetty', 'paid_partially' => 'Osittain maksettu', 'paid' => 'Maksettu', 'cancelled' => 'Peruttu', ]; $salesVatPercent = (float) ($vehicle->sales_vat_percent ?? 25.5); $salesVatPercentLabel = rtrim(rtrim(str_replace('.', ',', number_format($salesVatPercent, 2, '.', '')), '0'), ','); $vat = 1 + ($salesVatPercent / 100); $salesVatStored = (float) ($vehicle->sales_price_vat ?? 0); $salesVat0Stored = (float) ($vehicle->sales_price_vat0 ?? 0); $salesVat0 = $salesVat0Stored > 0 ? $salesVat0Stored : ($salesVatStored > 0 ? $salesVatStored / ($vat > 0 ? $vat : 1) : null); $salesVat = $salesVat0 !== null ? $salesVat0 * ($vat > 0 ? $vat : 1) : ($salesVatStored > 0 ? $salesVatStored : null); $purchaseVat0 = (float) ($vehicle->purchase_price_vat0 ?? 0); $purchaseVat = $purchaseVat0 > 0 ? $purchaseVat0 * $vat : null; $customerPermitLabel = 'Lupanumero'; if ((string) ($vehicle->vehicle_type ?? '') === 'esteeton_taksi') { $customerPermitLabel = 'Taksilupa'; } elseif (in_array((string) ($vehicle->vehicle_type ?? ''), ['monitoimibussi', 'turistibussi'], true)) { $customerPermitLabel = 'Joukkoliikennelupa'; } $isBusType = in_array((string) ($vehicle->vehicle_type ?? ''), ['monitoimibussi', 'turistibussi'], true); @endphp
@php $historyCompany = $vehicle->ownershipHistory->sortByDesc('started_at')->first()?->company; $displayCompany = $vehicle->company ?? $historyCompany; @endphp

Perustiedot

Asiakas@if($displayCompany){{ $displayCompany->name }}@if(!$vehicle->company) (historia)@endif @else - @endif
VIN{{ $vehicle->vin ?: '-' }}
Rekisterinumero{{ $vehicle->registration_number ?: '-' }}
Ajoneuvotyyppi{{ $vehicleTypeLabels[$vehicle->vehicle_type] ?? '-' }}
Käyttöönottopäivä{{ $vehicle->first_registration_date ? $vehicle->first_registration_date->format('d.m.Y') : '-' }}
Kunto{{ $conditionLabels[$vehicle->condition_type] ?? '-' }}
{{ $customerPermitLabel }}{{ $vehicle->category_based_customer_permit ?: '-' }}
Valmistaja{{ $vehicle->manufacturer_name ?: '-' }}
Rahoitusyhtiö{{ $vehicle->financing_company_name ?: '-' }}

Status

Tila{{ $inventoryLabels[$vehicle->inventory_status] ?? $vehicle->inventory_status }}
Varastopaikka{{ $vehicle->stock_location_label }}
Maahantuotu{{ $vehicle->imported_flag ? 'Kyllä' : 'Ei' }}{{ $vehicle->imported_at ? ' (' . $vehicle->imported_at->format('d.m.Y') . ')' : '' }}{{ $vehicle->imported_note ? ' - ' . $vehicle->imported_note : '' }}
Tullattu{{ $vehicle->customs_cleared_flag ? 'Kyllä' : 'Ei' }}{{ $vehicle->customs_cleared_at ? ' (' . $vehicle->customs_cleared_at->format('d.m.Y') . ')' : '' }}
Autoveroilmoitus{{ $isBusType ? 'Ei käytössä (monitoimibussi/turistibussi)' : (($vehicle->car_tax_filed_flag ? 'Kyllä' : 'Ei') . ($vehicle->car_tax_filed_at ? ' (' . $vehicle->car_tax_filed_at->format('d.m.Y') . ')' : '')) }}
Luovutuspäivä{{ $vehicle->delivered_at ? $vehicle->delivered_at->format('d.m.Y') : '-' }}
Laskun tila{{ $invoiceStatusLabels[$vehicle->invoice_status] ?? ($vehicle->invoice_status ?: '-') }}
Lasku lähetetty{{ $vehicle->invoice_sent_at ? $vehicle->invoice_sent_at->format('d.m.Y H:i') : '-' }}

Hinnat

Myyntihinta alv {{ $salesVatPercentLabel }}%{{ $salesVat ? number_format($salesVat, 2, ',', ' ') . ' EUR' : '-' }}
Myyntihinta alv 0%{{ $salesVat0 ? number_format($salesVat0, 2, ',', ' ') . ' EUR' : '-' }}
Ostohinta alv 0%{{ $purchaseVat0 ? number_format($purchaseVat0, 2, ',', ' ') . ' EUR' : '-' }}
Ostohinta alv {{ $salesVatPercentLabel }}%{{ $purchaseVat ? number_format($purchaseVat, 2, ',', ' ') . ' EUR' : '-' }}
Kasiraha valmistajalle{{ $vehicle->manufacturer_down_payment_amount ? number_format((float)$vehicle->manufacturer_down_payment_amount, 2, ',', ' ') . ' EUR' : '-' }}

Nopea kuittaus

@php $importLocked = (bool) $vehicle->imported_flag || $vehicle->imported_at !== null; $deliveryLocked = $vehicle->delivered_at !== null; @endphp
@csrf
@csrf

Dokumentit

@csrf
Rekisteriote (PDF)
Pudota tiedosto tähän tai klikkaa valitaksesi
-
Lasku (PDF)
Pudota tiedosto tähän tai klikkaa valitaksesi
-
Rahoitussopimus (PDF)
Pudota tiedosto tähän tai klikkaa valitaksesi
-
Muut liitteet (PDF)
Pudota tiedosto tähän tai klikkaa valitaksesi
-
@forelse($vehicle->documents as $doc)
{{ $doc->original_filename }} | {{ ($doc->type === 'registration_certificate') ? 'Rekisteriote' : (($doc->extraction_meta['document_kind'] ?? null) === 'invoice' ? 'Lasku' : (($doc->extraction_meta['document_kind'] ?? null) === 'finance_agreement' ? 'Rahoitussopimus' : 'Muu')) }} | tunnistettu käyttöönottopäivä: {{ optional($doc->extracted_first_registration_date)->format('d.m.Y') ?: '-' }} | tunnistus: {{ $doc->extraction_meta['method'] ?? '-' }}
@empty
Ei dokumentteja vielä.
@endforelse

Laskusta poimitut lisätiedot

@php $invoiceInfo = $vehicle->invoice_additional_info ?? []; @endphp @forelse($invoiceInfo as $info)
Dokumentti: {{ $info['document'] ?? '-' }}
Poimittu ostohinta alv 0%: {{ isset($info['purchase_price_vat0']) && $info['purchase_price_vat0'] !== null ? number_format((float)$info['purchase_price_vat0'], 2, ',', ' ') . ' EUR' : '-' }}
Poimittu rahti alv 0%: {{ isset($info['freight_vat0']) && $info['freight_vat0'] !== null ? number_format((float)$info['freight_vat0'], 2, ',', ' ') . ' EUR' : '-' }}
Poimittu VIN: {{ $info['vin'] ?? '-' }}
Poimittu toimittajan tilausnumero: {{ $info['supplier_order_number'] ?? '-' }}
Tunnistusmenetelmä: {{ $info['meta']['method'] ?? '-' }}
@empty
Ei laskusta poimittuja lisätietoja vielä.
@endforelse

Asiakashistoria

@php $history = $vehicle->ownershipHistory->sortByDesc('started_at'); @endphp @forelse($history as $entry) @php $unknownBackfillStart = $entry->source === 'backfill_current' && !$vehicle->imported_at && !$vehicle->customs_cleared_at && !$vehicle->car_tax_filed_at && !$vehicle->first_registration_date; @endphp
{{ $entry->company->name ?? '-' }} | alkaen {{ $unknownBackfillStart ? '-' : ($entry->started_at ? $entry->started_at->format('d.m.Y') : '-') }} | asti {{ $entry->ended_at ? $entry->ended_at->format('d.m.Y') : 'nykyinen' }} | lähde: {{ $entry->source }}
@empty
Ei aiempia asiakkaita tallennettu.
@endforelse
@endsection