@extends('layouts.finance') @section('title', 'Store Credit Detail') @section('subtitle', 'Available store credit from the v3 database') @section('content') @php $rows = $details['rows'] ?? collect(); $amountColumn = $details['amount_column'] ?? null; $nameColumns = $details['name_columns'] ?? ['name']; $businessColumns = $details['business_columns'] ?? ['business_name']; $statusColumns = $details['status_columns'] ?? ['status']; $source = $details['source'] ?? null; $rowCount = (int) ($details['row_count'] ?? $rows->count()); $dateFilter = $dateFilter ?? ['active' => false, 'from' => null, 'to' => null, 'label' => null]; $dashboardRouteParams = ($dateFilter['active'] ?? false) ? ['from' => $dateFilter['from'], 'to' => $dateFilter['to']] : []; @endphp
Back to Dashboard
@include('dashboard.cards._date-filter', ['dateFilter' => $dateFilter, 'filterRoute' => 'dashboard.cards.store-credit'])
Available Store Credit
{{ $metrics->money($details['amount'] ?? 0, 'PKR') }}
All positive available balances
Source
{{ $source ?: 'Not found' }}
v3 database lookup
Users / Rows
{{ number_format($rowCount) }}
Rows with positive credit

Available Store Credit Rows

PKR
@if(! $source)
No v3 store credit source was detected. Add the correct table and amount column to the store credit candidates in the metrics service.
@else @forelse($rows as $row) @php $firstName = trim((string) ($row->first_name ?? '')); $lastName = trim((string) ($row->last_name ?? '')); $name = trim($firstName.' '.$lastName); if ($name === '') { foreach ($nameColumns as $column) { if (isset($row->{$column}) && trim((string) $row->{$column}) !== '') { $name = $row->{$column}; break; } } } $businessName = $row->BusinessName ?? null; if (trim((string) $businessName) === '') { foreach ($businessColumns as $column) { if (isset($row->{$column}) && trim((string) $row->{$column}) !== '') { $businessName = $row->{$column}; break; } } } $status = null; foreach ($statusColumns as $column) { if (isset($row->{$column}) && trim((string) $row->{$column}) !== '') { $status = $row->{$column}; break; } } $name = $name ?? ($row->user_id ?? ($row->id ?? 'Unknown')); $businessName = $businessName ?? '-'; $status = $status ?? '-'; $statusValue = trim((string) $status); $statusLabel = match ($statusValue) { '1' => 'Active', '0' => 'Pending', default => $statusValue !== '' ? ucfirst($statusValue) : '-', }; $statusPill = match ($statusValue) { '1' => 'pill-green', '0' => 'pill-red', default => strtolower($statusValue) === 'active' ? 'pill-green' : (strtolower($statusValue) === 'pending' ? 'pill-red' : ''), }; $amount = $amountColumn ? ($row->{$amountColumn} ?? 0) : 0; @endphp @empty @endforelse
ID User Name Business Name Status Available Credit
{{ $row->id ?? '-' }} {{ $name }} {{ $businessName }} {{ $statusLabel }} {{ $metrics->money($amount, 'PKR') }}
No positive store credit rows found.
@if($rowCount > $rows->count())
Showing top {{ number_format($rows->count()) }} rows by available credit.
@endif @endif
@endsection