@extends('layouts.finance') @section('title', 'Factory Expense Detail') @section('subtitle', 'Factory expenses from expense records and factory payments') @section('content') @php $displayCurrency = 'PKR'; $fmt = fn($usd) => $metrics->moneyIn($usd, 'USD', $displayCurrency); $rowCount = $rows->count(); $latestDate = $rows->max(fn($row) => $row['date']?->toDateString()); $sourceTotals = $rows ->groupBy('source') ->map(fn($items) => $items->sum('amount_usd')) ->sortDesc(); @endphp
Back to Dashboard

Filters

{{ $filters['mode'] === 'date' ? 'Date wise' : 'Monthly' }}
Reset
Factory Expense
{{ $fmt($totalUsd) }}
{{ \Illuminate\Support\Carbon::parse($filters['from'])->format('M d, Y') }} - {{ \Illuminate\Support\Carbon::parse($filters['to'])->format('M d, Y') }}
Expense Rows
{{ number_format($rowCount) }}
Records found
Average Expense
{{ $fmt($rowCount > 0 ? $totalUsd / $rowCount : 0) }}
Per factory row
Latest Expense
{{ $latestDate ? \Illuminate\Support\Carbon::parse($latestDate)->format('M d, Y') : '-' }}
Most recent row
@if($sourceTotals->isNotEmpty())
@foreach($sourceTotals as $source => $sourceTotal)
{{ $source }}
{{ $fmt($sourceTotal) }}
{{ number_format($rows->where('source', $source)->count()) }} row(s)
@endforeach
@endif

Expense Details

{{ $displayCurrency }}
@forelse($rows as $row) @empty @endforelse
Date Source Account Paid To Description Reference Amount PKR Equivalent View
{{ $row['date']?->format('d M Y') ?: '-' }} {{ $row['source'] }} {{ $row['account'] ?: '-' }} {{ $row['counterparty'] ?: '-' }} {{ $row['description'] ?: '-' }} {{ $row['reference'] ?: '-' }} {{ $metrics->money($row['amount'], $row['currency']) }} {{ $fmt($row['amount_usd']) }} @if($row['transaction']) Open @else - @endif
No factory expense rows found for this period.
@endsection