@extends('admin.admin_dashboard') @section('admin')
{{-- LEFT: Details --}}
{{-- FILTER BOX (Template style) --}}
Filter
List
{{-- SALE DETAILS BOX (Template style) --}}
Sale Order: {{ $productSale->sale_no }} @if($productSale->status === 'draft') Draft @elseif($productSale->status === 'completed') Completed @elseif($productSale->status === 'cancelled') Cancelled @else Unknown @endif

Customer: @if($productSale->customer_type === 'student' && $productSale->student) {{ $productSale->student->student_name_english }} ({{ $productSale->student->admission_roll }}) @else {{ $productSale->customer_name ?? 'Walk-in Customer' }} @endif

Customer Type: {{ ucfirst($productSale->customer_type) }}

Sale Date: {{ optional($productSale->sale_date)->format('d M Y') }}

Sold By: {{ $productSale->soldBy->name ?? 'N/A' }}

@if($productSale->completed_at)

Completed At: {{ $productSale->completed_at->format('d M Y H:i') }}

@endif

Sale Items
@foreach($productSale->items as $item) @endforeach
# Product Quantity Unit Price Total
{{ $loop->iteration }} {{ $item->product->name ?? 'N/A' }} {{ $item->quantity }} ৳{{ number_format($item->unit_price, 2) }} ৳{{ number_format($item->total_price, 2) }}
Total Amount: ৳{{ number_format($productSale->total_amount, 2) }}
Cost: ৳{{ number_format($productSale->total_cost, 2) }}
Profit: ৳{{ number_format($productSale->profit_amount, 2) }}
@if($productSale->notes)
Notes: {{ $productSale->notes }}
@endif {{-- ACCOUNTING (Template style, only completed) --}} @if($productSale->status === 'completed')

Accounting Entries
@if(!$productSale->revenueEntry && !$productSale->cogsEntry)
Completed sale কিন্তু কোনো accounting entry পাওয়া যায়নি। Data integrity চেক করুন।
@endif @if($productSale->revenueEntry)
Revenue Entry

Entry No: {{ $productSale->revenueEntry->entry_no }}

Date: {{ $productSale->revenueEntry->entry_date->format('d M Y') }}

@foreach($productSale->revenueEntry->lines as $line) @endforeach
Account Debit Credit
{{ $line->account->name ?? 'N/A' }} {{ $line->debit > 0 ? '৳'.number_format($line->debit, 2) : '-' }} {{ $line->credit > 0 ? '৳'.number_format($line->credit, 2) : '-' }}
@endif @if($productSale->cogsEntry)
COGS Entry

Entry No: {{ $productSale->cogsEntry->entry_no }}

Date: {{ $productSale->cogsEntry->entry_date->format('d M Y') }}

@foreach($productSale->cogsEntry->lines as $line) @endforeach
Account Debit Credit
{{ $line->account->name ?? 'N/A' }} {{ $line->debit > 0 ? '৳'.number_format($line->debit, 2) : '-' }} {{ $line->credit > 0 ? '৳'.number_format($line->credit, 2) : '-' }}
@endif
@endif
{{-- RIGHT: Actions + Summary (Template style) --}}
Actions
@if($productSale->status === 'draft')
@csrf
Edit Sale
@csrf @method('DELETE')
@endif @if($productSale->status === 'completed')
@csrf
@endif Back to List
Summary

Total Items: {{ $productSale->items->count() }}

Total Quantity: {{ $productSale->items->sum('quantity') }}

Revenue: ৳{{ number_format($productSale->total_amount, 2) }}

Cost: ৳{{ number_format($productSale->total_cost, 2) }}

Profit: ৳{{ number_format($productSale->profit_amount, 2) }}

@if($productSale->total_amount > 0)

Profit Margin: {{ number_format(($productSale->profit_amount / $productSale->total_amount) * 100, 2) }}%

@endif
@endsection @section('customjs') @endsection