@extends('layouts.app') @section('title', $product->brand_name) @php $routePrefix = strtolower(auth()->user()->role->name); $canEdit = auth()->user()->hasPermissionName('products.edit'); $canDelete = auth()->user()->hasPermissionName('products.delete'); $canInvoices = auth()->user()->hasPermissionName('invoices.view'); $statusColors = [ 'Active' => 'primary', 'Discontinued' => 'danger', 'Under Registration' => 'warning', ]; @endphp @section('content')

{{ $product->brand_name }}

{{ $product->status }}
Product detail, pricing, and catalogue information.
Back @if($canEdit) Edit Product @endif @if($canDelete)
@csrf @method('DELETE')
@endif
@if(session('success'))
{{ session('success') }}
@endif
{{-- ── Left Column ──────────────────────────────────────────────── --}}
{{-- Product Overview --}}
Product Overview
Core product, regulatory, and catalogue information.
Brand Name {{ $product->brand_name }}
Generic / Composition {{ $product->composition }}
Dosage Form {{ $product->dosage_form }}
Packing Type {{ $product->packing_type }}
Pack Size {{ $product->pack_size ?? '—' }}
Therapeutic Category {{ $product->therapeutic_category ?? '—' }}
HSN Code {{ $product->hsn_code }}
Dossier / Documents @if($product->dossier) Download / View @else @endif
Status {{ $product->status }}
Added On {{ $product->created_at->format('d M Y') }}
{{-- ── Linked Records ──────────────────────────────────────── --}} @if($canInvoices) @php $invoiceStatusColors = [ 'Draft' => 'secondary', 'Sent' => 'info', 'Paid' => 'success', 'Partially Paid' => 'warning', 'Overdue' => 'danger', 'Cancelled' => 'dark', ]; // Summary stats across all invoice items for this product $totalQtySold = $linkedInvoices->sum('pivot_quantity'); $totalRevenue = $linkedInvoices->sum('pivot_total'); $paidRevenue = $linkedInvoices ->where('invoice_status', 'Paid') ->sum('pivot_total'); @endphp {{-- Sales Summary Cards --}}
Total Units Sold
{{ number_format($totalQtySold) }}
Total Invoiced
₹{{ number_format($totalRevenue, 2) }}
Paid Revenue
₹{{ number_format($paidRevenue, 2) }}
{{-- Invoice Lines Table --}}
Linked Invoices
Invoices where this product appears as a line item.
{{ $linkedInvoices->count() }} invoice{{ $linkedInvoices->count() !== 1 ? 's' : '' }}
@if($linkedInvoices->isEmpty())
receipt_long

This product has not appeared on any invoice yet.

@else
@foreach($linkedInvoices as $inv) @endforeach
Invoice No. Customer Date Qty Unit Price Line Total Status
{{ $inv->invoice_number }} {{ $inv->customer_name }} {{ \Carbon\Carbon::parse($inv->invoice_date)->format('d M Y') }} {{ $inv->pivot_quantity }} ₹{{ number_format($inv->pivot_price, 2) }} ₹{{ number_format($inv->pivot_total, 2) }} {{ $inv->invoice_status }}
Totals {{ number_format($totalQtySold) }} ₹{{ number_format($totalRevenue, 2) }}
@endif
@else {{-- User has no invoice permission — show placeholder --}}
Linked Records
Invoices linked to this product.

You do not have permission to view invoice records.

@endif
{{-- ── Right Column ─────────────────────────────────────────────── --}}
{{-- Pricing & Tax --}}
Pricing & Tax
MRP, GST, and price breakdown.
MRP (excl. GST)
₹{{ number_format($product->mrp, 2) }}
GST Rate {{ $product->gst_rate }}%
GST Amount ₹{{ number_format($product->mrp * $product->gst_rate / 100, 2) }}
Price incl. GST ₹{{ number_format($product->mrp * (1 + $product->gst_rate / 100), 2) }}
{{-- Price History --}}
Price History
Recent changes to product MRP.
@if($product->priceHistories->isEmpty())
No price history available.
@else
    @foreach($product->priceHistories->sortByDesc('created_at')->take(10) as $h)
  • ₹{{ number_format($h->new_price, 2) }}
    {{ $h->created_at->format('d M Y H:i') }} @if($h->user) · {{ $h->user->name }} @endif
    @if(!is_null($h->old_price))
    Was ₹{{ number_format($h->old_price, 2) }}
    @php $diff = $h->new_price - $h->old_price; @endphp
    {{ $diff > 0 ? '+' : '' }}₹{{ number_format($diff, 2) }}
    @else
    Initial price
    @endif
  • @endforeach
@endif
@endsection