@extends('layouts.app') @section('title', 'Sale Details') @section('content')

Sale Details

{{ $sale->sale_no }}

🖨 Print Invoice @if(auth()->user()->role === 'owner') Edit @endif ← Back
{{-- ========================================================= --}} {{-- SUCCESS MESSAGE --}} {{-- ========================================================= --}} @if(session('success'))
{{ session('success') }}
@endif {{-- ========================================================= --}} {{-- ERROR MESSAGE --}} {{-- ========================================================= --}} @if($errors->any())
Please fix the following:
@endif {{-- ========================================================= --}} {{-- SALE INFORMATION --}} {{-- ========================================================= --}}
Sale Information
{{-- Sale Number --}}
Sale Number
{{ $sale->sale_no }}
{{-- Customer --}}
Customer
{{ $sale->customer_name ?: 'Walk-in Customer' }} @if($sale->customer_phone)
{{ $sale->customer_phone }}
@endif
{{-- Sale Date --}}
Sale Date
{{ $sale->sale_date ? $sale->sale_date->format('d-m-Y') : '-' }}
{{-- Invoice Number --}}
Invoice Number
{{ $sale->invoice_no ?: '-' }}
{{-- Payment Status --}}
Payment Status
@if($sale->payment_status === 'Paid') Paid @elseif($sale->payment_status === 'Partial') Partial @else Unpaid @endif
{{-- Created By --}}
Created By
{{ $sale->creator->name ?? 'N/A' }}
@if($sale->notes)
Notes
{{ $sale->notes }}
@endif
{{-- ========================================================= --}} {{-- SOLD PRODUCTS --}} {{-- ========================================================= --}}
Sold Products
@if(auth()->user()->role === 'owner') @endif @if(auth()->user()->role === 'owner') @endif @forelse($sale->items as $item) @if(auth()->user()->role === 'owner') @endif @if(auth()->user()->role === 'owner') @endif @empty @endforelse
# Product Qty Cost Price Selling Price MRP GST % Tax Line Total Profit
{{ $loop->iteration }} @if($item->product) {{ $item->product->name }} @if($item->product->sku)
SKU: {{ $item->product->sku }}
@endif @else Product Deleted @endif
{{ number_format((float) $item->qty, 2) }} @if((float) $item->free_qty > 0)
+{{ number_format((float) $item->free_qty, 2) }} Free
@endif
₹{{ number_format((float) $item->cost_price, 2) }} ₹{{ number_format((float) $item->selling_price, 2) }} ₹{{ number_format((float) $item->mrp, 2) }} {{ number_format((float) $item->gst_rate, 2) }}% ₹{{ number_format((float) $item->tax_amount, 2) }} ₹{{ number_format((float) $item->line_total, 2) }} @if((float) $item->profit >= 0) ₹{{ number_format((float) $item->profit, 2) }} @else ₹{{ number_format((float) $item->profit, 2) }} @endif
No products found for this sale.
{{-- ========================================================= --}} {{-- SALE SUMMARY + PAYMENT SUMMARY --}} {{-- ========================================================= --}} @php $totalProfit = $sale->items->sum( fn ($item) => (float) $item->profit ); $paidAmount = $sale->payments->sum( fn ($payment) => (float) $payment->amount ); $grandTotal = (float) $sale->grand_total; $outstandingAmount = max( 0, $grandTotal - $paidAmount ); @endphp
{{-- ===================================================== --}} {{-- SALE SUMMARY --}} {{-- ===================================================== --}}
Sale Summary
Subtotal ₹{{ number_format((float) $sale->subtotal, 2) }}
Discount ₹{{ number_format((float) $sale->discount, 2) }}
GST Total ₹{{ number_format((float) $sale->gst_total, 2) }}

Grand Total
₹{{ number_format($grandTotal, 2) }}
@if(auth()->user()->role === 'owner')
Total Profit ₹{{ number_format($totalProfit, 2) }}
@endif
{{-- ===================================================== --}} {{-- PAYMENT SUMMARY --}} {{-- ===================================================== --}}
Payment Summary
Grand Total ₹{{ number_format($grandTotal, 2) }}
Paid Amount ₹{{ number_format($paidAmount, 2) }}
Outstanding ₹{{ number_format($outstandingAmount, 2) }}

Status @if($outstandingAmount <= 0) Paid @elseif($paidAmount > 0) Partial @else Unpaid @endif
{{-- ========================================================= --}} @if(auth()->user()->role === 'owner') {{-- ADD PAYMENT --}} {{-- ========================================================= --}} @if($outstandingAmount > 0)
Add Payment
@csrf
{{-- Amount --}}
Outstanding: ₹{{ number_format($outstandingAmount, 2) }}
{{-- Payment Method --}}
{{-- Payment Date --}}
{{-- Reference --}}
{{-- Notes --}}
{{-- Button --}}
@endif {{-- ========================================================= --}} @endif {{-- PAYMENT HISTORY --}} {{-- ========================================================= --}}
Payment History
@forelse($sale->payments->sortByDesc('payment_date') as $payment) @empty @endforelse
# Date Method Reference Notes Added By Amount
{{ $loop->iteration }} {{ $payment->payment_date ? $payment->payment_date->format('d-m-Y') : '-' }} @if($payment->payment_method === 'Cash') Cash @elseif($payment->payment_method === 'UPI') UPI @elseif($payment->payment_method === 'Bank') Bank @elseif($payment->payment_method === 'Card') Card @else Other @endif {{ $payment->reference_no ?: '-' }} {{ $payment->notes ?: '-' }} {{ $payment->creator->name ?? 'N/A' }} ₹{{ number_format((float) $payment->amount, 2) }}
No payments recorded yet.
{{-- ========================================================= --}} {{-- STOCK IMPACT --}} {{-- ========================================================= --}} @if($sale->stockLedgers->count())
Stock Impact
@foreach($sale->stockLedgers as $ledger) @endforeach
Product Transaction Qty In Qty Out Balance
{{ $ledger->product->name ?? 'Product Deleted' }} {{ ucfirst($ledger->transaction_type) }} {{ number_format((float) $ledger->qty_in, 2) }} {{ number_format((float) $ledger->qty_out, 2) }} {{ number_format((float) $ledger->balance, 2) }}
@endif @endsection