@include('filament.components.currency-conveter')
@foreach($paymentItems as $item) @php $serviceName = $item->service_name ?? 'Hizmet adı bulunamadı'; $doctorName = $item->doctor_name ?? 'Personel adı bulunamadı'; $unitPrice = $item->unit_price ?? 0; $quantity = $item->quantity ?? 1; $discount = $item->discount ?? 0; $total = $item->total ?? 0; $currencyCode = $item->currency_code ?? 'TRY'; $discountApproved = $item->discount_approved ? 'Onaylı' : 'Onay Bekliyor'; $subtotal = $unitPrice * $quantity; $discountPercent = $subtotal > 0 ? ($discount / $subtotal) * 100 : 0; @endphp @if ($loop->last) @endif @endforeach @php $groupedItems = collect($paymentItems)->groupBy('currency_code'); @endphp @foreach($groupedItems as $currencyCode => $currencyItems) @endforeach @foreach($groupedItems as $currencyCode => $currencyItems) @php // Item subtotal ve discount $subtotal = $currencyItems->sum(fn($item) => $item->unit_price * $item->quantity); $itemDiscountTotal = $currencyItems->sum('discount'); // Genel indirim (Payment'tan) $globalDiscount = $record?->global_discount ?? 0; // Toplam indirim $totalDiscount = $itemDiscountTotal + $globalDiscount; // Genel toplam $grandTotal = $subtotal - $totalDiscount; $discountPercent = $subtotal > 0 ? ($totalDiscount / $subtotal) * 100 : 0; // Ödenen tutar $paidTotal = 0; if ($record && $record->transactions) { $paidTotal = $record->transactions() ->where('currency_id', $currencyItems->first()->currency_id ?? 1) ->sum('amount'); } $remaining = $grandTotal - $paidTotal; @endphp @endforeach
Personel Hizmet Birim Fiyat Miktar İndirim Tutarı İndirim % Toplam Yeni Hizmet
{{ $doctorName }} {{ $serviceName }} {{ number_format($unitPrice, 2) }} {{ $currencyCode }}
{{ $currencyCode }}
%
{{ number_format($total, 2) }} {{ $currencyCode }}
Genel Toplam İndirim ({{ $currencyCode }})
{{ $currencyCode }}
0.00 % {{ number_format($record?->global_discount ?? 0, 2) }} {{ $currencyCode }}
Ara Toplam ({{ $currencyCode }}) {{ number_format($subtotal, 2) }} {{ $currencyCode }}
Hizmet İndirimleri ({{ $currencyCode }}) {{ number_format($itemDiscountTotal, 2) }} {{ $currencyCode }}
Genel İndirim ({{ $currencyCode }})
Toplam İndirim ({{ $currencyCode }}) {{ number_format($totalDiscount, 2) }} {{ $currencyCode }}
Toplam İndirim Yüzdesi ({{ $currencyCode }}) {{ number_format($discountPercent, 2) }} %
Genel Toplam ({{ $currencyCode }}) {{ number_format($grandTotal, 2) }} {{ $currencyCode }}
Alınan Tutar ({{ $currencyCode }})
Kalan Tutar ({{ $currencyCode }}) {{ number_format($remaining, 2) }} {{ $currencyCode }}