@extends('layouts.finance') @section('title', 'Business Total Detail') @section('subtitle', 'Verification breakdown before net worth') @section('content') @php $currency = $verification['currency'] ?? 'PKR'; $dateFilter = $dateFilter ?? ['active' => false, 'from' => null, 'to' => null, 'label' => null]; $filterActive = (bool) ($dateFilter['active'] ?? false); $dashboardRouteParams = $filterActive ? ['from' => $dateFilter['from'], 'to' => $dateFilter['to']] : []; $gatewayDateParams = [ 'mode' => 'date', 'from' => $filterActive ? $dateFilter['from'] : now()->toDateString(), 'to' => $filterActive ? $dateFilter['to'] : now()->toDateString(), ]; $settings = $metrics->settings(); $lockedInvestment = (float) ($settings['business_investment'] ?? 36459362); $businessTotal = (float) ($verification['business_total'] ?? 0); $businessGross = (float) ($verification['business_total_before_liabilities'] ?? $businessTotal); // Daily business position for the tracking year: opens at Total Investment // on 1 Jul 2026, then 1 Jan each year after. $positionYear = $metrics->businessPositionYear($businessTotal); $latestPosition = $businessTotal; $latestDailyNet = (float) (collect($positionYear['daily_net'] ?? [])->last() ?? 0); $profitLoss = $latestPosition - $lockedInvestment; $profitLossPercent = $lockedInvestment > 0 ? ($profitLoss / $lockedInvestment) * 100 : 0; $profitColor = $profitLoss >= 0 ? '#10b981' : '#ef4444'; $profitLabel = $profitLoss >= 0 ? 'Profit' : 'Loss'; $profitDirection = $profitLoss >= 0 ? 'above investment' : 'below investment'; $componentCards = [ ['label' => 'Bank Balance', 'amount' => $verification['bank_balance_excluding_wallets'] ?? ($verification['bank_balance'] ?? 0), 'route' => route('dashboard.cards.bank', $dashboardRouteParams), 'type' => 'Asset', 'color' => '#7c3aed', 'icon' => 'bank'], ['label' => 'Wallets', 'amount' => $verification['wallet_balance'] ?? 0, 'route' => route('dashboard.cards.bank', $dashboardRouteParams), 'type' => 'Asset', 'color' => '#0891b2', 'icon' => 'wallet'], ['label' => 'Inventory Amount', 'amount' => $verification['inventory_amount'] ?? 0, 'route' => route('dashboard.cards.inventory', $dashboardRouteParams), 'type' => 'Asset', 'color' => '#06b6d4', 'icon' => 'box'], ['label' => 'Lent Amount', 'amount' => $verification['lent_amount'] ?? 0, 'route' => route('dashboard.cards.collectible', $dashboardRouteParams), 'type' => 'Receivable', 'color' => '#0d9488', 'icon' => 'file'], ['label' => 'In Transit Amount', 'amount' => $verification['transit_amount'] ?? 0, 'route' => route('dashboard.cards.transit', $dashboardRouteParams), 'type' => 'Asset', 'color' => '#d97706', 'icon' => 'clock'], ['label' => 'Saving Amount', 'amount' => $verification['saving_amount'] ?? 0, 'route' => route('dashboard.cards.saving', $dashboardRouteParams), 'type' => 'Asset', 'color' => '#10b981', 'icon' => 'bank'], ['label' => $filterActive ? 'KuickPay Filtered Net' : 'KuickPay Today Net', 'amount' => $verification['kuickpay_today_net'] ?? 0, 'route' => route('dashboard.cards.kuickpay', $gatewayDateParams), 'type' => 'Collection', 'color' => '#10b981', 'icon' => 'card'], ['label' => 'KuickPay Pending Balance', 'amount' => $verification['kuickpay_pending_balance'] ?? 0, 'route' => route('dashboard.cards.kuickpay-pending', $dashboardRouteParams), 'type' => 'Collection', 'color' => '#e11d48', 'icon' => 'clock'], ['label' => $filterActive ? 'PayFast Filtered Net' : 'PayFast Today Net', 'amount' => $verification['payfast_today_net'] ?? 0, 'route' => route('dashboard.cards.payfast', $gatewayDateParams), 'type' => 'Collection', 'color' => '#0ea5e9', 'icon' => 'card'], ['label' => 'PayFast Pending Balance', 'amount' => $verification['payfast_pending_balance'] ?? 0, 'route' => route('dashboard.cards.payfast-pending', $dashboardRouteParams), 'type' => 'Collection', 'color' => '#0284c7', 'icon' => 'clock'], ['label' => 'Credit Card Debt', 'amount' => $verification['credit_card_debt'] ?? 0, 'route' => route('dashboard.cards.debt', $dashboardRouteParams), 'type' => 'Liability', 'color' => '#ef4444', 'icon' => 'card', 'negative' => true], ['label' => 'Loans & Debts', 'amount' => $verification['loan_debt'] ?? 0, 'route' => route('dashboard.cards.debt', $dashboardRouteParams), 'type' => 'Liability', 'color' => '#dc2626', 'icon' => 'debt', 'negative' => true], ['label' => 'Store Credit', 'amount' => $verification['store_credit_amount'] ?? 0, 'route' => route('dashboard.cards.store-credit', $dashboardRouteParams), 'type' => 'Shown separately', 'color' => '#db2777', 'icon' => 'wallet', 'muted' => true], ]; @endphp
Back to Dashboard
@if($filterActive) Clear Showing date-based components for {{ $dateFilter['label'] }} @else Default view uses live balances, today collections, and current month totals. @endif
Total Amount in Business
{{ $metrics->money($businessTotal, $currency) }}
Before liabilities {{ $metrics->money($businessGross, $currency) }}
Liabilities deducted กค store credit excluded
Total Investment
{{ $metrics->money($lockedInvestment, $currency) }}
Fixed baseline
{{ $profitLabel }}
{{ $profitLoss < 0 ? '-' : '' }}{{ $metrics->money(abs($profitLoss), $currency) }}
{{ number_format(abs($profitLossPercent), 2) }}% {{ $profitDirection }}
Total Liabilities
{{ $metrics->money($verification['liabilities_total'] ?? 0, $currency) }}
Credit cards + loans

Business Components

Click any card to open its detail page{{ $filterActive ? ' กค date-based values use '.$dateFilter['label'] : '' }}

{{ $currency }}
@foreach($componentCards as $card) @php $isNegative = (bool) ($card['negative'] ?? false); $isMuted = (bool) ($card['muted'] ?? false); $amountColor = $isNegative ? '#ef4444' : ($isMuted ? 'var(--muted)' : ($card['color'] ?? 'var(--text)')); $signedPrefix = $isNegative ? '-' : ''; $iconColor = $card['color'] ?? '#6366f1'; @endphp
@if($card['icon'] === 'bank') @elseif($card['icon'] === 'box') @elseif($card['icon'] === 'file') @elseif($card['icon'] === 'clock') @elseif($card['icon'] === 'wallet') @elseif($card['icon'] === 'debt') @else @endif
{{ $card['label'] }}
{{ $signedPrefix }}{{ $metrics->money($card['amount'], $currency) }}
{{ $card['type'] }}
@endforeach

Business Position

Daily Total Amount in Business, after liabilities @if(!empty($positionYear['window_start'])) กค {{ \Illuminate\Support\Carbon::parse($positionYear['window_start'])->format('d M Y') }} to {{ \Illuminate\Support\Carbon::parse($positionYear['window_end'])->format('d M Y') }} @endif

{{ $profitLabel }}
Total Investment
{{ $metrics->money($lockedInvestment, $currency) }}
Current Business Total
{{ $metrics->money($latestPosition, $currency) }}
{{ $profitLabel }} vs Investment
{{ $profitLoss < 0 ? '-' : '' }}{{ $metrics->money(abs($profitLoss), $currency) }}
{{ number_format(abs($profitLossPercent), 2) }}% {{ $profitDirection }}
Today Net Movement
{{ $latestDailyNet < 0 ? '-' : '' }}{{ $metrics->money(abs($latestDailyNet), $currency) }}
Profit minus expenses
@push('scripts') @endpush @endsection