@extends('layouts.layout-horizontal') @section('title', 'Sales Invoices') @section('css') @endsection @section('content')
{{-- Header with filters --}}
Sales {{-- Quick date pills --}}
@php [$fyStartFilter, $fyEndFilter] = financial_year_range(); $isToday = ($dateFrom === now()->toDateString() && $dateTo === now()->toDateString()); $isThisMonth = ($dateFrom === now()->startOfMonth()->toDateString() && $dateTo === now()->toDateString()); $isLast30 = ($dateFrom === now()->subDays(30)->toDateString() && $dateTo === now()->toDateString()); @endphp Today This Month Last 30d
{{-- Date range --}}
to
{{-- Party filter --}}
@if(request('party_id') || $dateFrom !== $fyStartFilter->toDateString() || $dateTo !== $fyEndFilter->toDateString()) Clear @endif
{{-- Right: New Sale + count --}}
{{ $sales->count() }} invoices New Sale
@if(($companyMode ?? 'bill') !== 'cash') @endif @if(($companyMode ?? 'bill') !== 'cash') @endif @php $avatarColors = ['#6366f1','#ec4899','#f59e0b','#10b981','#3b82f6','#8b5cf6','#ef4444','#14b8a6','#f97316','#06b6d4']; $grouped = $sales->groupBy(fn($s) => $s->invoice_date->format('Y-m-d')); @endphp @forelse ($grouped as $date => $dateSales) {{-- Date group header --}} @php $dateObj = \Carbon\Carbon::parse($date); $dateLabel = $dateObj->isToday() ? 'Today' : ($dateObj->isYesterday() ? 'Yesterday' : $dateObj->format('d M Y')); $dayTotal = $dateSales->sum('grand_total'); @endphp @foreach ($dateSales as $sale) @php $initial = strtoupper(substr($sale->party?->name ?? '?', 0, 1)); $colorIdx = ($sale->party_id ?? 0) % count($avatarColors); @endphp @if(($companyMode ?? 'bill') !== 'cash') @endif @if(($companyMode ?? 'bill') !== 'cash') @endif @endforeach @empty @endforelse @if ($sales->count()) @if(($companyMode ?? 'bill') !== 'cash') @endif @endif
Party Bill NoTypeAmountTaxGrand Total Actions
{{ $dateLabel }} ({{ $dateSales->count() }}) ₹{{ indian_number($dayTotal, 2) }}
{{ $initial }} {{ $sale->party?->name ?? '—' }}
{{ $sale->bill_no ?: '—' }} @if(($companyMode ?? 'bill') === 'cash' && !empty($transfersBySource[$sale->id]))
@foreach($transfersBySource[$sale->id] as $tr) @if($tr->targetSale) {{ $tr->targetSale->bill_no }} · {{ $tr->targetCompany->name ?? '' }} @endif @endforeach
@endif @if($sale->party && $sale->party->is_sez) @if($sale->arn_no) ARN ✓ @else ARN @endif
@endif
@if($sale->bill_type == 'cash') Cash @elseif($sale->bill_type == 'cash memo') Memo @else Bill @endif {{ indian_number($sale->amount_total, 2) }}{{ indian_number($sale->tax_total, 2) }}₹{{ indian_number($sale->grand_total, 2) }}
@if($sale->mode === 'cash') @endif @php $needsPdfScaleModal = $sale->mode === 'bill' && $sale->bill_type === 'bill' && $sale->items_count > 10; @endphp @if($needsPdfScaleModal) @else @endif @if($sale->mode !== 'cash') @endif @if($sale->party && $sale->party->mobile) @endif @if(auth()->user()->role === 'admin') @endif
@include('partials._empty-state', [ 'icon' => 'ph-receipt', 'title' => 'No invoices found', 'subtitle' => 'Try changing the date range or create a new invoice.', 'action' => route('sale.create'), 'actionLabel' => 'Create Invoice', ])
{{ $sales->count() }} invoices {{ indian_number($sales->sum('amount_total'), 2) }}{{ indian_number($sales->sum('tax_total'), 2) }}₹{{ indian_number($sales->sum('grand_total'), 2) }}
@endsection @push('scripts') @if(session('print_sale_id')) @endif @php $companyName = currentCompany()->name ?? config('app.name'); @endphp @if(($companyMode ?? 'bill') === 'bill' && $sales->contains(fn ($sale) => $sale->mode === 'bill' && $sale->bill_type === 'bill' && $sale->items_count > 10)) @include('sales.partials.pdf_scale_modal') @endif @if(($companyMode ?? 'bill') !== 'cash') @include('sales._ewb-modal') @endif @endpush