{{-- Daily Sales Review Tab --}} @php $reviewDateFrom = request()->query('ds_from', now()->startOfMonth()->toDateString()); $reviewDateTo = request()->query('ds_to', now()->toDateString()); $dailySalesRows = \App\Models\Transaction::query() ->where('txn_type', 'DailySales') ->where('status', 'Active') ->when(session('location_id'), function ($q) { $q->where(function ($w) { $w->where('location_id', session('location_id')) ->orWhereNull('location_id'); }); }) ->whereDate('txn_date', '>=', $reviewDateFrom) ->whereDate('txn_date', '<=', $reviewDateTo) ->orderByDesc('txn_date') ->get(['id', 'txn_date', 'amount', 'cash_amount', 'pos_amount', 'credit_amount', 'description', 'auto_note', 'user_id']); // Get offpos data for these dates $offposData = []; if (\Illuminate\Support\Facades\Schema::hasTable('offpos_day_summaries')) { $offposRows = \Illuminate\Support\Facades\DB::table('offpos_day_summaries') ->where('location_id', session('location_id')) ->whereBetween('sale_date', [$reviewDateFrom, $reviewDateTo]) ->get(['sale_date', 'offpos_cash_total', 'offpos_card_total', 'genie_card_total']); foreach ($offposRows as $opr) { $offposData[$opr->sale_date] = $opr; } } // Calculate totals $totalCash = $dailySalesRows->sum('cash_amount'); $totalPos = $dailySalesRows->sum('pos_amount'); $totalCredit = $dailySalesRows->sum('credit_amount'); $grandTotal = $dailySalesRows->sum('amount'); $totalOffposCash = array_sum(array_column($offposData, 'offpos_cash_total')); $totalOffposCard = array_sum(array_column($offposData, 'offpos_card_total')); @endphp
{{-- Summary Cards --}}
Total Cash
{{ number_format($totalCash, 2) }}
Total POS/Card
{{ number_format($totalPos, 2) }}
Total Credit
{{ number_format($totalCredit, 2) }}
Off-POS Cash
{{ number_format($totalOffposCash, 2) }}
Off-POS Card
{{ number_format($totalOffposCard, 2) }}
Grand Total
{{ number_format($grandTotal, 2) }}
{{-- Daily Sales Table --}}
@forelse ($dailySalesRows as $ds) @php $txnDateOnly = \Carbon\Carbon::parse($ds->txn_date)->format('Y-m-d'); $offpos = $offposData[$txnDateOnly] ?? null; $offposCash = $offpos ? (float) $offpos->offpos_cash_total : 0; $offposCard = $offpos ? (float) $offpos->offpos_card_total : 0; @endphp @empty @endforelse @if($dailySalesRows->count() > 0) @endif
Date Cash POS/Card Credit Total Off-POS Cash Off-POS Card Note Action
{{ \Carbon\Carbon::parse($ds->txn_date)->format('M d, Y') }}
{{ \Carbon\Carbon::parse($ds->txn_date)->format('l') }}
{{ number_format((float) $ds->cash_amount, 2) }} {{ number_format((float) $ds->pos_amount, 2) }} {{ number_format((float) $ds->credit_amount, 2) }} {{ number_format((float) $ds->amount, 2) }} @if($offposCash > 0) {{ number_format($offposCash, 2) }} @else - @endif @if($offposCard > 0) {{ number_format($offposCard, 2) }} @else - @endif {{ $ds->description ?? '-' }} View
No daily sales found for this period.
Total ({{ $dailySalesRows->count() }} days) {{ number_format($totalCash, 2) }} {{ number_format($totalPos, 2) }} {{ number_format($totalCredit, 2) }} {{ number_format($grandTotal, 2) }} {{ number_format($totalOffposCash, 2) }} {{ number_format($totalOffposCard, 2) }}
Note: Off-POS amounts are from the Off-POS day summaries (captured during Daily Sales submission). Cash and POS totals include both system sales and Off-POS amounts.