@extends('agency.layouts.app') @section('title', 'Faturalar') @section('content') @php $dtColumns = [ ['key' => 'invoice_number', 'label' => 'Fatura No', 'sortable' => true, 'sort' => 'invoice_number'], ['key' => 'issue_date', 'label' => 'Tarih', 'sortable' => true, 'sort' => 'issue_date', 'width' => '105px'], ['key' => 'billing', 'label' => 'Muhatap'], ['key' => 'source', 'label' => 'Kaynak', 'width' => '120px'], ['key' => 'items', 'label' => 'Kalem', 'align' => 'center', 'width' => '70px', 'visible' => false], ['key' => 'amount', 'label' => 'Tutar', 'sortable' => true, 'sort' => 'amount', 'align' => 'end', 'width' => '130px'], ['key' => 'status', 'label' => 'Durum', 'sortable' => true, 'sort' => 'status', 'align' => 'center', 'width' => '100px'], ['key' => 'official', 'label' => 'Resmi Fatura', 'sortable' => true, 'sort' => 'official_status', 'align' => 'center', 'width' => '130px'], ['key' => '_actions', 'label' => '', 'fixed' => true, 'align' => 'end', 'width' => '190px'], ]; $dtFilters = [ ['key' => 'date_from', 'label' => 'Başlangıç', 'type' => 'date', 'value' => request('date_from')], ['key' => 'date_to', 'label' => 'Bitiş', 'type' => 'date', 'value' => request('date_to')], ['key' => 'status', 'label' => 'Durum', 'value' => request('status'), 'options' => \App\Models\Sale\SaleInvoice::STATUSES], ['key' => 'official_status', 'label' => 'Resmi Fatura', 'value' => request('official_status'), 'options' => \App\Models\Sale\SaleInvoice::OFFICIAL_STATUSES], ['key' => 'invoice_type', 'label' => 'Tür', 'value' => request('invoice_type'), 'options' => \App\Models\Sale\SaleInvoice::TYPES], ['key' => 'billing_type', 'label' => 'Muhatap', 'value' => request('billing_type'), 'options' => ['individual' => 'Şahıs', 'company' => 'Şirket']], ['key' => 'product_type', 'label' => 'Ürün Tipi', 'value' => request('product_type'), 'options' => $productTypes->pluck('name', 'id')->all()], ]; $dtStats = [ ['label' => 'Toplam Fatura', 'value' => number_format($stats['total'], 0, ',', '.'), 'icon' => 'fa-file-invoice', 'color' => '#059669'], ['label' => 'Bu Ay Kesilen', 'value' => number_format($stats['month_count'], 0, ',', '.'), 'icon' => 'fa-calendar-check', 'color' => '#2563eb'], ['label' => 'Kesilen Tutar (tüm birimler)', 'value' => number_format((float) $stats['issued_sum'], 2, ',', '.'), 'icon' => 'fa-coins', 'color' => '#0f766e'], ['label' => 'Resmi Fatura Bekleyen', 'value' => number_format($stats['official_pending'], 0, ',', '.'), 'icon' => 'fa-triangle-exclamation', 'color' => '#d97706'], ]; @endphp
@forelse($invoices as $inv) {{ $inv->invoice_number }} @if($inv->invoice_type === 'refund') İade @endif {{ $inv->issue_date?->format('d.m.Y') }}
{{ $inv->billing_name }}
{{ $inv->billing_type_label }} @if(($inv->billing_snapshot['tax_number'] ?? null)) · {{ $inv->billing_snapshot['tax_number'] }} @endif
@if($inv->sale_id) Satış #{{ $inv->sale_id }} @if($inv->sale?->productType?->name)
{{ $inv->sale->productType->name }}
@endif @else Serbest @endif {{ is_array($inv->items) ? count($inv->items) : 0 }} {{ number_format((float) $inv->amount, 2, ',', '.') }} {{ $inv->currency }} {{ $inv->status_label }} @if($inv->official_status === 'pending' && $inv->status !== 'cancelled') Bekliyor @else {{ $inv->official_status_label }} @endif
@if($inv->official_status === 'pending' && $inv->status !== 'cancelled') @endif
@empty
Henüz fatura yok
Sağ üstteki "Yeni Fatura Oluştur" ile ilk faturanızı oluşturun.
@endforelse
@endsection