@extends('reports.pdf.layout') @section('title', 'Relatório de Categorias') @section('content')

Informações do Relatório

@if(isset($filters['date_from']) && $filters['date_from'])
Data Inicial: {{ \Carbon\Carbon::parse($filters['date_from'])->format('d/m/Y') }}
@endif @if(isset($filters['date_to']) && $filters['date_to'])
Data Final: {{ \Carbon\Carbon::parse($filters['date_to'])->format('d/m/Y') }}
@endif @if(isset($filters['bank_account_id']) && $filters['bank_account_id'])
Conta Bancária: {{ $filters['bank_account_name'] ?? 'ID: ' . $filters['bank_account_id'] }}
@endif
Total Categorias {{ $stats['total_categories'] }}
Valor Total R$ {{ number_format($stats['total_amount'], 2, ',', '.') }}
Média por Categoria R$ {{ number_format($stats['avg_per_category'], 2, ',', '.') }}
@forelse($categorySummary as $categoryId => $types) @foreach($types as $type) @endforeach @empty @endforelse
Categoria Tipo Quantidade Total Média Mínimo Máximo
{{ $categoryId ?: 'Sem categoria' }} {{ $type->type == 'credit' ? 'Crédito' : 'Débito' }} {{ number_format($type->count, 0, ',', '.') }} R$ {{ number_format($type->total, 2, ',', '.') }} R$ {{ number_format($type->average, 2, ',', '.') }} R$ {{ number_format($type->min_amount, 2, ',', '.') }} R$ {{ number_format($type->max_amount, 2, ',', '.') }}
Nenhuma categoria encontrada com os filtros aplicados.
@if($categorySummary->count() > 20)
@endif @if($categorySummary->count() > 0)

Top 5 Categorias por Volume

@php $topCategories = $categorySummary->map(function($types, $categoryId) { return [ 'category' => $categoryId, 'total' => $types->sum('total') ]; })->sortByDesc('total')->take(5); $grandTotal = $stats['total_amount']; @endphp @foreach($topCategories as $index => $category) @endforeach
Posição Categoria Total % do Total
{{ $index + 1 }}º {{ $category['category'] ?: 'Sem categoria' }} R$ {{ number_format($category['total'], 2, ',', '.') }} {{ $grandTotal > 0 ? number_format(($category['total'] / $grandTotal) * 100, 1) : 0 }}%
@endif @endsection