@php $orders = collect($orders ?? []); $dailyData = collect($dailyData ?? []); $paidCustomersList = collect($paidCustomers ?? []); $receivableCustomersList = collect($receivableCustomers ?? []); $paidRevenue = (float) ($summary['paid_revenue'] ?? 0); $receivableRevenue = (float) ($summary['receivable_revenue'] ?? 0); $totalRevenue = (float) ($summary['total_revenue'] ?? ($paidRevenue + $receivableRevenue)); $paidOrders = (int) ($summary['paid_orders'] ?? 0); $receivableOrders = (int) ($summary['receivable_orders'] ?? 0); $paidCustomersCount = (int) ($summary['paid_customers'] ?? $paidCustomersList->count()); $receivableCustomersCount = (int) ($summary['receivable_customers'] ?? $receivableCustomersList->count()); $shopLogoUrl = null; if (!empty($shopLogo)) { $shopLogoUrl = \Illuminate\Support\Str::startsWith($shopLogo, ['http://', 'https://', '/']) ? $shopLogo : asset('storage/' . ltrim($shopLogo, '/')); } $formatQty = function ($value) { $value = (float) $value; if (floor($value) == $value) { return number_format($value, 0, ',', '.'); } return number_format($value, 2, ',', '.'); }; @endphp
@if($shopLogoUrl) @endif
{{ $shopName }}
@if(!empty($shopAddress))
{{ $shopAddress }}
@endif
LAPORAN OMSET PENJUALAN
Periode: {{ \Carbon\Carbon::parse($startDate)->format('d M Y') }} - {{ \Carbon\Carbon::parse($endDate)->format('d M Y') }}
Total Omset
Rp {{ number_format($totalRevenue, 0, ',', '.') }}
Gabungan order lunas + piutang
Total Order
{{ number_format($summary['total_orders'] ?? 0, 0, ',', '.') }}
Semua transaksi pada periode ini
Total Qty
{{ $formatQty($summary['total_qty'] ?? 0) }}
Total qty seluruh item
Omset Piutang
Rp {{ number_format($receivableRevenue, 0, ',', '.') }}
{{ $receivableOrders }} order • {{ $receivableCustomersCount }} pelanggan
@if($dailyData->count() > 0)
Ringkasan Harian
@foreach($dailyData as $daily) @endforeach
Tanggal Jumlah Order Omset
{{ \Carbon\Carbon::parse($daily->date)->format('d M Y') }} {{ $daily->total_orders }} Rp {{ number_format((float) $daily->total_revenue, 0, ',', '.') }}
Total Harian Rp {{ number_format((float) $dailyData->sum('total_revenue'), 0, ',', '.') }}
@endif @if($paidCustomersList->count() > 0 || $receivableCustomersList->count() > 0)
Ringkasan Pelanggan
Pelanggan Lunas
@forelse($paidCustomersList->take(8) as $customer) @php $customerName = is_array($customer) ? ($customer['customer_name'] ?? '-') : ($customer->customer_name ?? '-'); $customerOrders = is_array($customer) ? ($customer['total_orders'] ?? 0) : ($customer->total_orders ?? 0); $customerAmount = is_array($customer) ? ($customer['total_amount'] ?? 0) : ($customer->total_amount ?? 0); @endphp
{{ $customerName }}
{{ number_format((float) $customerOrders, 0, ',', '.') }} order
Rp {{ number_format((float) $customerAmount, 0, ',', '.') }}
@empty
Tidak ada data pelanggan lunas.
@endforelse
Pelanggan Piutang
@forelse($receivableCustomersList->take(8) as $customer) @php $customerName = is_array($customer) ? ($customer['customer_name'] ?? '-') : ($customer->customer_name ?? '-'); $customerOrders = is_array($customer) ? ($customer['total_orders'] ?? 0) : ($customer->total_orders ?? 0); $customerAmount = is_array($customer) ? ($customer['total_amount'] ?? 0) : ($customer->total_amount ?? 0); @endphp
{{ $customerName }}
{{ number_format((float) $customerOrders, 0, ',', '.') }} order
Rp {{ number_format((float) $customerAmount, 0, ',', '.') }}
@empty
Tidak ada data pelanggan piutang.
@endforelse
@endif
Detail Order
@forelse($orders as $order) @php $printItems = collect($order->items ?? [])->filter(function ($item) { return !(bool) ($item->is_cancelled ?? false); })->values(); $firstItem = $printItems->first(); $extraItemsCount = max($printItems->count() - 1, 0); $summaryFileName = $firstItem->file_name ?? '-'; $summaryQty = (float) ($firstItem->qty ?? 0); $summarySizeUnit = strtolower(trim((string) ($firstItem->size_unit ?? ''))); if ($summarySizeUnit === 'm²') { $summarySizeUnit = 'm2'; } if ($summarySizeUnit === 'pcs') { $summarySizeUnit = 'lembar'; } $summarySizeDescription = $firstItem->size_description ?? '-'; $summarySizeValue = (float) ($firstItem->size_value ?? 0); $displayTotal = (float) ($order->report_total_price ?? $order->total_price ?? 0); $isReceivable = false; if ( (isset($order->report_remaining_balance) && (float) $order->report_remaining_balance > 0) || (isset($order->remaining_balance) && (float) $order->remaining_balance > 0) || (isset($order->payment_status) && in_array($order->payment_status, ['partial', 'unpaid', 'receivable'])) ) { $isReceivable = true; } $statusLabel = $isReceivable ? 'Piutang' : 'Lunas'; $statusClass = $isReceivable ? 'badge-receivable' : 'badge-paid'; $tanggalTampil = $order->paid_at ?? $order->created_at ?? null; $qtyLine = '-'; if ($summaryQty > 0) { $qtyLine = $formatQty($summaryQty); if (!empty($summarySizeUnit)) { $qtyLine .= ' ' . $summarySizeUnit; } } $sizeLine = $summarySizeDescription ?: '-'; if ($summarySizeUnit === 'm2' && $summarySizeValue > 0) { $sizeLine .= ' • nilai ' . $formatQty($summarySizeValue) . ' m2'; } @endphp @empty @endforelse
Tanggal Invoice Pelanggan Ringkasan Item Status Total
{{ $tanggalTampil ? \Carbon\Carbon::parse($tanggalTampil)->format('d/m/Y') : '-' }} {{ $order->invoice_number }}
{{ $order->customer_name }}
@if(!empty($order->customer_phone))
{{ $order->customer_phone }}
@endif
{{ $summaryFileName }}
{{ $sizeLine }}
Qty: {{ $qtyLine }}
@if($extraItemsCount > 0)
+{{ $extraItemsCount }} item lagi
@endif
{{ $statusLabel }} Rp {{ number_format($displayTotal, 0, ',', '.') }}
Tidak ada data order pada periode ini.
Total Lunas Rp {{ number_format($paidRevenue, 0, ',', '.') }}
Total Piutang Rp {{ number_format($receivableRevenue, 0, ',', '.') }}
Grand Total Omset Rp {{ number_format($totalRevenue, 0, ',', '.') }}
Keterangan:
- Omset dihitung dari gabungan transaksi lunas dan piutang.
- Nilai item m2 mengikuti perhitungan ulang dari ukuran aktual item order.
- Jika filter mesin tidak tersedia di sistem bahan, laporan tetap aman dicetak tanpa memaksa relasi mesin.